This is a Node-Express API for having a RasperryPi post weather readings. Every reading can have a user post an associated review.
Use this as the basis for your own API documentation. Add a new third-level heading for your custom entities, and follow the pattern provided for the built-in user authentication documentation.
Scripts are included in curl-scripts
to test built-in actions. Feel free to use Postman for testing, using the curl scripts listed below and in the folder for setting up headers and request bodies.
Add your own scripts to test your custom API.
Verb | URI Pattern | Controller#Action |
---|---|---|
POST | /sign-up |
users#signup |
POST | /sign-in |
users#signin |
PATCH | /change-password/ |
users#changepw |
DELETE | /sign-out/ |
users#signout |
Request:
curl --include --request POST http://localhost:8000/sign-up \
--header "Content-Type: application/json" \
--data '{
"credentials": {
"email": "[email protected]",
"password": "an example password",
"password_confirmation": "an example password"
}
}'
curl-scripts/sign-up.sh
Response:
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 1,
"email": "[email protected]"
}
}
Request:
curl --include --request POST http://localhost:8000/sign-in \
--header "Content-Type: application/json" \
--data '{
"credentials": {
"email": "[email protected]",
"password": "an example password"
}
}'
curl-scripts/sign-in.sh
Response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 1,
"email": "[email protected]",
"token": "33ad6372f795694b333ec5f329ebeaaa"
}
}
Request:
curl --include --request PATCH http://localhost:8000/change-password/ \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/json" \
--data '{
"passwords": {
"old": "an example password",
"new": "super sekrit"
}
}'
TOKEN=33ad6372f795694b333ec5f329ebeaaa curl-scripts/change-password.sh
Response:
HTTP/1.1 204 No Content
Request:
curl --include --request DELETE http://localhost:8000/sign-out/ \
--header "Authorization: Bearer $TOKEN"
TOKEN=33ad6372f795694b333ec5f329ebeaaa curl-scripts/sign-out.sh
Response:
HTTP/1.1 204 No Content