Example 1 - Simple “Posts” application
Schema
This is a simple representative schema for a PostgreSQL datasource, which has 4 objects (tables) - links, posts, topics, users - with relationships between these objects.
This schema is in the Neurelo Schema Language JSON specification
GET endpoint examples
Retrieve all posts
GET https://$ENV_API_URL/rest/posts
Retrieve a specific post by id
GET https://$ENV_API_URL/rest/posts/3
or
GET https://$ENV_API_URL/rest/posts?filter={"id":3}
Retrieve a specific user
GET https://$ENV_API_URL/rest/users?filter={"first_name":"Jane", "last_name":"Doe"}
Retrieve the first 5 posts
GET https://$ENV_API_URL/rest/posts?take=5
Retrieve all users and their posts
GET https://$ENV_API_URL/rest/users?select={"$scalars": true, "posts": true}
Retrieve user with id 3 and all their posts
GET https://$ENV_API_URL/rest/users/3?select={"$scalars": true, "posts": true}
Retrieve specific user and all their posts
GET https://$ENV_API_URL/rest/users?select={"$scalars": true, "posts": true}&filter={"first_name":"Jane", "last_name":"Doe"}
POST endpoint examples
Create a new post
POST https://$ENV_API_URL/rest/posts { "content": "This is my first blog post", "title": "My first blog post" }
Create a new post, a new user, and link them to each other
POST https://$ENV_API_URL/rest/posts { "content": "New POST", "title": "The new post", "users": { "create": { "email": "[email protected]", "first_name": "new", "last_name": "user", "password": "password" } } }
Create a new user, 3 posts, link the posts to the user AND return the user scalars + related data (the 3 posts we just created)
POST https://$ENV_API_URL/rest/users?select={"$scalars": true, "$related": true} { "email": "[email protected]", "first_name": "multi", "last_name": "post", "password": "manymanyposts", "posts": { "createMany": { "data": [ { "content": "this is the first one", "title": "first one" }, { "content": "this is the second one", "title": "second one" }, { "content": "this is the third one", "title": "third one" } ] } } }
PATCH endpoint examples
Update a post
PATCH https://$ENV_API_URL/rest/posts/7 { "content": "This is my seventh blog post", "title": "My seventh blog post" }
Update a post and its linked user
PATCH https://$ENV_API_URL/rest/posts/1 { "content": "Newest post", "title": "The new post (revised)", "users": { "update": { "first_name": "updated", "last_name": "name" } } }
DELETE endpoint examples
Delete a post
DELETE https://$ENV_API_URL/rest/posts/4
PreviousExamples of Neurelo Auto-Generated REST API endpointsNextExample 2 - "DVD Rentals" application
Last updated