mince-pie-challenge-api API documentation version 1
https://api.mincepiechallenge.com
/
Provides available actions and Cognito authentication pool identifiers.
get /
Provides available actions and Cognito authentication pool identifiers.
HTTP status code 200
Body
Media type: application/hal+json
Type: object
Example:
{
"_links": {
"self": { "href": "/" },
"list": { "href": "/pies" },
"add": { "href": "/pies" },
"view": {
"href": "/pies/{id}",
"templated": true
}
},
"cognito": {
"poolId": "eu-west-1_BXXROsWOu",
"clientId": "3qf6pqo467hr1tcbm3kf5sn2v3"
},
"baseEndpointUrl": "https://api.mincepiechallenge.com"
}
/pies
List all available mince pie's in the challenge.
Add a new mince pie to the challenge.
get /pies
List all available mince pie's in the challenge.
HTTP status code 200
Body
Media type: application/hal+json
Type: object
Example:
{
"_links": {
"self": { "href": "/pies" }
},
"_embedded": {
"pies": [
{
"_links": {
"self": { "href": "/pies/9d197f40" }
},
"id": "9d197f40",
"name": "Awesome Mince Pie",
"thumbnail": "http://s3.com/9d197f40.jpg",
"rating": {
"avg": 5,
"total": 1
}
}
]
},
"total": 1
}
post /pies
Add a new mince pie to the challenge.
Requires a valid JSON Web Token be provided.
Body
Media type: application/json
Type: object
Example:
{
"name": "Awesome Mince Pie"
}
HTTP status code 201
Headers
- Location: required (string)
Example:
/pies/9d197f40
Body
Media type: application/hal+json
Type: object
Example:
{
"_links": {
"self": { "href": "/pies/9d197f40" },
"photo": { "href": "/pies/9d197f40/photo" }
},
"id": "9d197f40",
"name": "Awesome Mince Pie",
"addedAt": "2018-06-11T12:00:00.000Z",
"rating": {
"avg": 0,
"total": 0
}
}
HTTP status code 400
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Bad Request",
"detail": "Invalid request body",
"errors": [
{ "name": "name", "reason": "You must supply the pie's name." }
]
}
Secured by strict-jwt
Headers
- Authorization: required (string)
Used to send a JSON Web Token with the request.
HTTP status code 401
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Unauthorized",
"detail": "Service requires an authenticated user"
}
/pies/{id}
View a specified mince pie.
Remove a specified mince pie from the challenge.
get /pies/{id}
View a specified mince pie.
Optionally provide a valid JSON Web Token.
URI Parameters
- id: required (string)
HTTP status code 200
Body
Media type: application/hal+json
Type: object
Example:
{
"_links": {
"self": { "href": "/pies/9d197f40" },
"photo?": { "href": "/pies/9d197f40/photo" },
"rate?": { "href": "/pies/9d197f40/rate" },
"remove?": { "href": "/pies/9d197f40" }
},
"id": "9d197f40",
"name": "Awesome Mince Pie",
"addedAt": "2018-06-11T12:00:00.000Z",
"photo": "http://s3.com/original/9d197f40.jpg",
"thumbnail": "http://s3.com/9d197f40.jpg",
"rating": {
"avg": 0,
"total": 0
}
}
HTTP status code 404
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Not Found",
"detail": "Unable to find the specified mince pie."
}
Secured by optional-jwt
Headers
- Authorization: (string)
Used to send a JSON Web Token with the request.
delete /pies/{id}
Remove a specified mince pie from the challenge.
Requires a valid JSON Web Token be provided.
URI Parameters
- id: required (string)
HTTP status code 204
Successfully deleted the mince pie.
HTTP status code 403
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Forbidden",
"detail": "This mince pie does not belong to you."
}
HTTP status code 404
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Not Found",
"detail": "Unable to find the specified mince pie."
}
Secured by strict-jwt
Headers
- Authorization: required (string)
Used to send a JSON Web Token with the request.
HTTP status code 401
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Unauthorized",
"detail": "Service requires an authenticated user"
}
/pies/{id}/rate
Rate a specified mince pie.
put /pies/{id}/rate
Rate a specified mince pie.
Requires a valid JSON Web Token be provided.
URI Parameters
- id: required (string)
Body
Media type: application/json
Type: object
Example:
{
"rating": 5
}
HTTP status code 204
Successfully rated the mince pie.
HTTP status code 400
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Bad Request",
"detail": "Invalid request body",
"errors": [
{ "name": "rating", "reason": "You must supply a valid pie rating." }
]
}
HTTP status code 403
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Forbidden",
"detail": "You have already rated this mince pie."
}
HTTP status code 404
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Not Found",
"detail": "Unable to find the specified mince pie."
}
Secured by strict-jwt
Headers
- Authorization: required (string)
Used to send a JSON Web Token with the request.
HTTP status code 401
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Unauthorized",
"detail": "Service requires an authenticated user"
}
/pies/{id}/photo
Request a new photo upload URL.
put /pies/{id}/photo
Request a new photo upload URL.
Requires a valid JSON Web Token be provided.
URI Parameters
- id: required (string)
Body
Media type: application/json
Type: object
Example:
{
"fileExtension": "jpg",
"contentType": "image/jpg"
}
HTTP status code 201
Headers
- Location: required (string)
Example:
http://s3.com/upload/9d197f40
Body
Media type: application/hal+json
Type: object
Example:
{
"_links": {
"self": { "href": "http://s3.com/upload/9d197f40" }
},
"url": "http://s3.com/upload/9d197f40"
}
HTTP status code 400
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Bad Request",
"detail": "Invalid request body",
"errors": [
{ "name": "fileExtension", "reason": "You must supply the file extension." },
{ "name": "contentType", "reason": "You must supply the content-type." }
]
}
HTTP status code 403
Body
Media type: application/problem+json
Type: object
Examples:
not-owner:
{
"title": "Forbidden",
"detail": "This mince pie does not belong to you."
}
photo-present:
{
"title": "Forbidden",
"detail": "This mince pie already has a photo."
}
HTTP status code 404
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Not Found",
"detail": "Unable to find the specified mince pie."
}
Secured by strict-jwt
Headers
- Authorization: required (string)
Used to send a JSON Web Token with the request.
HTTP status code 401
Body
Media type: application/problem+json
Type: object
Example:
{
"title": "Unauthorized",
"detail": "Service requires an authenticated user"
}