The following API takes advantage of AWS services, and with a use of Amazon's API Gateway, lambda functions and DynamoDB allows to add items to the DB and retrieve them.
It set up on the following URL: https://s113h98jyg.execute-api.us-east-1.amazonaws.com/prod/
It works with the following endpoints:
- /user
-
- /
POST
|GET
- /
Adds a user item to the DynamoDB and returns an id of created user.
- URL
https://s113h98jyg.execute-api.us-east-1.amazonaws.com/prod/users
-
Method:
POST
-
URL Params
None
-
Data Params
{
"body":
{
"firstName":[string]
"age":[number]
}
}
-
Success Response:
- Code: 201 CREATED
Content:{ statusCode:201, body: 'Successfully created item!', id:[id of the user created]};
- Code: 201 CREATED
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ statusCode:400,error: err }
- Code: 400 BAD REQUEST
-
Sample call:
-
- Body
{ "body": { "firstName":"John" "age":"22" } }
- Body
Allows to retrive user from the dynamoDB using its id.
- URL
https://s113h98jyg.execute-api.us-east-1.amazonaws.com/prod/users/id?=_id
-
Method:
GET
-
URL Params
-
Required:
_id:[string]
-
Data Params
None
-
Success Response:
- Code: 200 Successful request and response.
Content:{statusCode:200, object:[user object from the db] }
- Code: 200 Successful request and response.
-
Error Response:
- Code: 400 BAD REQUEST
Content:{statusCode:404, error:error.stack}
- Code: 400 BAD REQUEST
-
Sample call:
-
-
Body
None
-