RestAPI reference¶
On this page you can check the RestAPI endpoints.¶
Note
The API has build in csrf protection you may need to attach Cookie with value csrftoken=token to work proparly
Authentication¶
Create admin user¶
POST /api/auth/signup
Payload¶
authentication.UserSerializer
{
"username": "username",
"password": "password",
"is_superuser": true
}
Headers¶
name | type | data type | description |
---|---|---|---|
X-Auth-Header |
required |
UUID |
Header used for authentication with the API |
Responses¶
http code | content-type | response |
---|---|---|
201 |
application/json |
User created successfully |
400 |
application/json |
{"username":["user with this username already exists."]} |
Example cURL¶
Obtain access token¶
POST /api/auth/token
Payload¶
Headers¶
name | type | data type | description |
---|---|---|---|
X-Auth-Header |
required |
UUID |
Header used for authentication with the API |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
{"token":"token","user":{"username":"username","is_superuser":true}} |
404 |
application/json |
{"detail":"No User matches the given query."} |
403 |
application/json |
{"detail": "You must use authentication header"} |
Example cURL¶
Recipe¶
Search for recipes¶
GET /api/recipe/home/
Parameters¶
name | type | data type | description |
---|---|---|---|
name |
query (optional) |
string |
Part or fulll name of the recipe.Recipe object |
page |
query (optional) |
int |
Page number if there a mutilple pages result |
Headers¶
name | type | data type | description |
---|---|---|---|
X-Auth-Header |
required |
UUID |
Header used for authentication with the API |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
{"count":int,"next":string,"previous":string,"results":[recipe.Recipe obj list]} |
403 |
application/json |
{"detail":"You must use authentication header"} |
Example cURL¶
Get favorite recipes¶
GET /api/recipe/home/favorites
Headers¶
name | type | data type | description |
---|---|---|---|
X-Auth-Header |
required |
UUID |
Header used for authentication with the API |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
{"count":int,"next":string,"previous":string,"results":[recipe.Recipe obj list]} |
404 |
application/json |
{"detail":"No Recipe matches the given query."} |
403 |
application/json |
{"detail":"You must use authentication header"} |
Example cURL¶
Get trending recipes¶
GET /api/recipe/trending
Headers¶
name | type | data type | description |
---|---|---|---|
X-Auth-Header |
required |
UUID |
Header used for authentication with the API |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
[recipe.Recipe objects list] |
403 |
application/json |
{"detail":"You must use authentication header"} |
Example cURL¶
Update favorite status¶
PATCH /api/recipe/int:pk/favorite
Parameters¶
name | type | data type | description |
---|---|---|---|
<int:pk> |
path (required) |
int |
Recipe primary key to be favorited or unfavorited |
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint example "token 443c104be8c6daeeaf86df634e69b97668b99900" |
Responses¶
http code | content-type | response |
---|---|---|
201 |
application/json |
"Success favorite recipe" |
201 |
application/json |
"Success unfavorite recipe" |
403 |
application/json |
`{"detail":"You must use authentication header"} |
404 |
application/json |
Not Found |
Example cURL¶
Create recipe¶
POST /api/recipe/
Payload¶
recipe.Recipe object
{
"image": file,
"name": string,
"serves": int,
"video": file (optional),
"category": <int:pk>,
"tag": <int:pk>,
"prep_time": int,
}
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint example "token 443c104be8c6daeeaf86df634e69b97668b99900" |
Content-Type |
multipart/form-data |
Recipe object |
Recipe multipart/form-data object |
Responses¶
http code | content-type | response |
---|---|---|
201 |
application/json |
{recipe.Recipe object} |
400 |
application/json |
{"tag":["Incorrect type. message"]} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |
Example cURL¶
Update recipe main info (without ingredients and steps)¶
PUT /api/recipe/int:pk
Payload¶
recipe.Recipe object
{
"image": file,
"name": string,
"serves": int,
"video": file (optional),
"category": <int:pk>,
"tag": <int:pk>,
"prep_time": int,
}
Parameters¶
name | type | data type | description |
---|---|---|---|
<int:pk> |
path (required) |
int |
Recipe primary key to be updated |
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint example "token 443c104be8c6daeeaf86df634e69b97668b99900" |
Content-Type |
multipart/form-data |
Recipe object |
Recipe multipart/form-data object |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
{recipe.Recipe object} |
400 |
application/json |
{"tag":["Incorrect type. message"]} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |
Example cURL¶
Category¶
Get all categories¶
GET /api/recipe/trending
Headers¶
name | type | data type | description |
---|---|---|---|
X-Auth-Header |
required |
UUID |
Header used for authentication with the API |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
[recipe.Category objects list] |
403 |
application/json |
{"detail":"You must use authentication header"} |
Example cURL¶
Get all categories recipes¶
GET /api/recipe/category/int:pk/recipes
Parameters¶
name | type | data type | description |
---|---|---|---|
<int:pk> |
path (required) |
int |
Category primary key |
Headers¶
name | type | data type | description |
---|---|---|---|
X-Auth-Header |
required |
UUID |
Header used for authentication with the API |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
[recipe.Recipe objects list] |
403 |
application/json |
{"detail":"You must use authentication header"} |
Example cURL¶
Create category¶
POST /api/recipe/category/add
Payload¶
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint example "token 443c104be8c6daeeaf86df634e69b97668b99900" |
Content-Type |
application/json |
`Applicaton Json content header |
Responses¶
http code | content-type | response |
---|---|---|
201 |
application/json |
{recipe.Category object} |
400 |
application/json |
{"tag":["Incorrect type. message"]} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |
Example cURL¶
Update category¶
PUT /api/recipe/category/int:pk
Payload¶
Parameters¶
name | type | data type | description |
---|---|---|---|
<int:pk> |
path (required) |
int |
Category primary key |
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint example "token 443c104be8c6daeeaf86df634e69b97668b99900" |
Content-Type |
application/json |
`Applicaton Json content header |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
{recipe.Recipe object} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |
404 |
application/json |
{"detail":"No Category matches the given query."} |
Example cURL¶
Tag¶
Get all tags¶
GET /api/recipe/tags
Headers¶
name | type | data type | description |
---|---|---|---|
X-Auth-Header |
required |
UUID |
Header used for authentication with the API |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
[recipe.Tag objects list] |
403 |
application/json |
{"detail":"You must use authentication header"} |
Example cURL¶
Get all recipes from tag¶
GET /api/recipe/tag/int:pk/recipes
Parameters¶
name | type | data type | description |
---|---|---|---|
<int:pk> |
path (required) |
int |
Tag primary key |
Headers¶
name | type | data type | description |
---|---|---|---|
X-Auth-Header |
required |
UUID |
Header used for authentication with the API |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
{"count":int,"next":string,"previous":string,"results":[recipe.Recipe obj list]} |
403 |
application/json |
{"detail":"You must use authentication header"} |
Example cURL¶
Create tag¶
POST /api/recipe/tag/add
Payload¶
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint example "token 443c104be8c6daeeaf86df634e69b97668b99900" |
Content-Type |
application/json |
`Applicaton Json content header |
Responses¶
http code | content-type | response |
---|---|---|
201 |
application/json |
{recipe.Category object} |
400 |
application/json |
{"tag":["Incorrect type. message"]} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |
Example cURL¶
Update tag¶
PUT /api/recipe/tag/int:pk
Payload¶
Parameters¶
name | type | data type | description |
---|---|---|---|
<int:pk> |
path (required) |
int |
Tag primary key |
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint example "token 443c104be8c6daeeaf86df634e69b97668b99900" |
Content-Type |
application/json |
`Applicaton Json content header |
Responses¶
http code | content-type | response |
---|---|---|
200 |
application/json |
{recipe.Tag object} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |
404 |
application/json |
{"detail":"No Category matches the given query."} |
Example cURL¶
Ingredients¶
POST /api/recipe/int:pk/ingredients
Payload¶
recipe.Igredient object list
[
{
"name": "string,
"quantity": string,
"metric": "string
},
{
"name": "string,
"quantity": string,
"metric": "string
},
....
]
Parameters¶
name | type | data type | description |
---|---|---|---|
<int:pk> |
path (required) |
int |
Recipe primary key to which to link the ingredients |
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint example "token 443c104be8c6daeeaf86df634e69b97668b99900" |
Content-Type |
application/json |
`Applicaton Json content header |
Responses¶
http code | content-type | response |
---|---|---|
201 |
application/json |
[{recipe.Ingrediant object}] |
400 |
application/json |
{"tag":["Incorrect type. message"]} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |
Example cURL¶
Steps¶
POST /api/recipe/int:pk/steps
Payload¶
Parameters¶
name | type | data type | description |
---|---|---|---|
<int:pk> |
path (required) |
int |
Recipe primary key to which to link the steps |
Headers¶
name | type | data type | description |
---|---|---|---|
Authorization |
required |
Access Token |
Token obtained from login endpoint example "token 443c104be8c6daeeaf86df634e69b97668b99900" |
Content-Type |
application/json |
`Applicaton Json content header |
Responses¶
http code | content-type | response |
---|---|---|
201 |
application/json |
[{recipe.Step object}] |
400 |
application/json |
{"tag":["Incorrect type. message"]} |
401 |
application/json |
{"detail":"Authentication credentials were not provided."} |