This API allows users to register, login, and manage recipes using REST or GraphQL.
https://recipebook.fly.dev
The API uses JWT tokens. Include the token in the Authorization header:
Authorization: Bearer <token>
curl -X POST https://recipebook.fly.dev/register \
-H "Content-Type: application/json" \
-d '{
"user": {
"email": "user@example.com",
"password": "password",
"password_confirmation": "password"
}
}'
Response
{
"token": "your_jwt_token"
}
curl -X POST https://recipebook.fly.dev/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "password"
}'
Response
{
"token": "your_jwt_token"
}
curl https://recipebook.fly.dev/recipes
Response
[
{
"id": 1,
"name": "Tacos",
"ingredients": "Tortillas, Beef, Lettuce",
"instructions": "Cook beef and assemble tacos"
}
]
curl https://recipebook.fly.dev/recipes/1
curl -X POST https://recipebook.fly.dev/recipes \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"recipe": {
"name": "Pizza",
"ingredients": "Flour, Cheese, Tomato",
"instructions": "Bake at 220ยฐC"
}
}'
curl -X PATCH https://recipebook.fly.dev/recipes/1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{
"recipe": {
"name": "Updated Pizza"
}
}'
curl -X DELETE https://recipebook.fly.dev/recipes/1 \
-H "Authorization: Bearer <token>"
Response
{
"message": "Recipe deleted"
}
https://recipebook.fly.dev/graphql
{
"query": "query { recipes { id name ingredients } }"
}
{
"query": "query { recipe(id: 1) { id name instructions } }"
}
{
"query": "mutation {
createRecipe(input: {
name: \"Burger\",
ingredients: \"Beef, Bun, Cheese\",
instructions: \"Cook and assemble\"
}) {
recipe {
id
name
}
errors
}
}"
}
{
"query": "mutation {
updateRecipe(input: {
id: 1,
name: \"Updated Burger\"
}) {
recipe {
id
name
}
errors
}
}"
}
{
"query": "mutation {
deleteRecipe(input: {
id: 1
}) {
success
errors
}
}"
}