Login to the cognito user pool
You'll be redirected to a new URL after signing in, copy the value of the access_token query string parameter to pass in with the HTTP "Authentication" header.
MOVIE_API_TOKEN=<access_token>
The API will respond in JSON.
curl --header "Authentication: Bearer "$MOVIE_API_TOKEN \
-X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "title=Star Wars&format=VHS&length=127&release_year=1976&rating=5" \
http://localhost/api/v1/movies
- parameters:
- title (required unless imdb_id is set)
- (text, max 50 characters)
- format (required)
- one of (DVD|VHS|Streaming)
- length (required)
- (integer between 0 and 500)
- release_year (required unless imdb_id is set)
- (integer between 1800 and 2100)
- rating (required unless imdb_id is set)
- (integer between 1 and 5)
- imdb_id (optional)
- (alphanumeric IMDB id)
- title (required unless imdb_id is set)
- JSON response
{
"messages": [
"movie created"
],
"success": true,
"movie_id": 24
}
curl --header "Authentication: Bearer "$MOVIE_API_TOKEN \
http://localhost/api/v1/movies
- parameters
- sort_field
- (optional) default title
- options (title|etc)
- sort_dir
- (optional) default value: asc
- options (asc|desc)
- sort_field
- JSON response
{
"success": true,
"data": [
{
"id": 1,
"title": "Star Wars",
"format": "VHS",
"length": 243,
"release_year": 1976,
"rating": 5
},
{
"id": 2,
"title": "Lord of the Rings",
"format": "DVD",
"length": 359,
"release_year": 2001,
"rating": 4
}
]
}
curl --header "Authentication: Bearer "$MOVIE_API_TOKEN \
http://localhost/api/v1/movies/1
- JSON response
{
"success": true,
"data": [
{
"id": 1,
"title": "Star Wars",
"format": "VHS",
"length": 243,
"release_year": 1976,
"rating": 5
}
]
}
curl --header "Authentication: Bearer "$MOVIE_API_TOKEN \
-X PUT \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "release_year=1972&rating=4" \
http://localhost/api/v1/movies/24
- parameters: (at least one required)
- title
- (text, max 50 characters)
- format
- one of (DVD|VHS|Streaming)
- length
- (integer between 0 and 500)
- release_year
- (integer between 1800 and 2100)
- rating
- (integer between 1 and 5)
- title
- JSON response
{
"messages": [
"movie updated"
],
"success": true
}
curl --header "Authentication: Bearer "$MOVIE_API_TOKEN \
-X DELETE \
http://localhost/api/v1/movies/24
- JSON response
{
"messages": [
"movie deleted"
],
"success": true
}