Neurelo Build Docs
Neurelo Build Docs
  • Introduction
    • Core Concepts
    • Key Features
  • Getting Started
    • Sign-in/Sign-up
    • Dashboard
      • Collapsible Sidebar
      • Light/Dark Mode
      • Account Settings
      • Audit Events
      • User Management
        • Permissions (Member v/s Admin)
      • Org Settings
    • Starting your Neurelo Project
      • Quick Start Guide
      • Step 1 - Add a Data Source
      • Step 2 - Build Definitions
      • Step 3 - Create an Environment
      • Step 4 - Create an API Key
      • Step 5 - Start Runners
      • Try your Neurelo APIs
  • "How to" Videos
    • Product Overview
    • Neurelo APIs & SDKs
    • Project Setup
    • Definitions
    • Environments
    • Data Sources
    • Organization Management
    • Creating and Using Custom Queries
    • Using the Schema Builder to build Relationships
    • Mock Data Generation
  • Definitions
    • Neurelo Schema Editor
      • Schema Builder
      • JSON/YAML Editor
      • Schema Visualization: Entity-Relationship Diagram (ERD)
    • Custom APIs for Complex Queries
      • Write and Commit Custom Queries
      • AI-Assisted Query Generation
      • Deploying Custom API Endpoints
      • Using Variables in your Custom Query
    • Branches and Commits
    • API Docs
  • Environments
    • Creating a new Environment
    • API Playground
    • Observability
    • Migrations
    • API Keys
  • Data Sources
    • PostgreSQL
    • MySQL
    • MongoDB
  • Guides
    • Provisioning Cloud Databases for using with Neurelo
      • PostgreSQL
        • AWS RDS (PostgreSQL)
      • MySQL
        • AWS RDS (MySQL)
      • MongoDB Atlas
    • Mock Data Generation
    • Wipe Data Source
    • Remote Git Repository for Definitions
      • Connecting a Remote Git Repo
      • Creating Commits from Neurelo
      • Syncing Branches
    • Data Viewer
    • Environment/Data Source Tags
    • How to work with Embedded documents and References in MongoDB
    • How to download and use the Postman Collection for your Project
    • Building Python applications with Postgres and FastAPI
    • CI Integration using Neurelo CLI
    • Schema Migrations
    • Schema AI Assist
    • Auto-Introspection
    • Access Policies
    • User Auth
      • Google
      • GitHub
      • GitLab
    • MongoDB Atlas - Migrate GraphQL to Neurelo
    • MongoDB Atlas - Migrate REST Data APIs to Neurelo
  • MongoDB Atlas - Migrate REST Data APIs to Neurelo
  • MongoDB Atlas - Migrate GraphQL APIs to Neurelo
  • Neurelo Schema Language (NSL)
    • Example 1 - DVD Rentals
    • Example 2 - Simple "Posts" App
    • Example 3 - Bookstore
  • Neurelo API Reference (REST)
    • Examples of Neurelo Auto-Generated REST API endpoints
      • Example 1 - Simple “Posts” application
      • Example 2 - "DVD Rentals" application
      • Example 3 - "Bookstore” application
      • cURL API Examples
  • Neurelo API Reference (GraphQL)
  • SDKs
    • TypeScript / JavaScript SDK
    • Go SDK
    • Python SDK
      • Python SDK Tutorial -- News Application
        • News Application using Neurelo’s Python SDKs
  • CLI (Preview Version)
  • Self-Hosted Neurelo Gateways
  • Tutorials
    • Building a Real Time Chat Application with Neurelo and MongoDB using Python
    • Building A Financial Terminal with Neurelo and MongoDB in Rust
    • Building a Restaurant Management System with Neurelo and MongoDB using GraphQL in just a few minutes
    • Bringing Neurelo’s Data APIs to Life Instantly with MySQL
  • Project Examples
  • References
    • Supported Databases
    • Supported OS and Browsers
  • Support
Powered by GitBook
On this page
  • Schema
  • GET endpoint examples
  • POST endpoint examples
  • PATCH endpoint examples
  • DELETE endpoint examples
  1. Neurelo API Reference (REST)
  2. Examples of Neurelo Auto-Generated REST API endpoints

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

JSON Schema
{
  "objects": {
    "links": {
      "properties": {
        "id": {
          "type": "integer",
          "default": {
            "function": "autoincrement"
          },
          "identifier": true
        },
        "link": {
          "type": "string",
          "sourceType": [
            "VarChar",
            500
          ],
          "nullable": true
        },
        "title": {
          "type": "string",
          "sourceType": [
            "VarChar",
            500
          ],
          "nullable": true
        },
        "topic_id": {
          "type": "integer",
          "nullable": true
        },
        "topics": {
          "nullable": true,
          "$ref": "#/objects/topics",
          "relation": {
            "attrKey": [
              "topic_id"
            ],
            "foreignAttrKey": [
              "id"
            ],
            "onUpdate": "NoAction",
            "onDelete": "NoAction"
          }
        }
      }
    },
    "posts": {
      "properties": {
        "content": {
          "type": "string",
          "nullable": true
        },
        "id": {
          "type": "integer",
          "default": {
            "function": "autoincrement"
          },
          "identifier": true
        },
        "title": {
          "type": "string",
          "sourceType": [
            "VarChar",
            200
          ],
          "nullable": true
        },
        "user_id": {
          "type": "integer",
          "nullable": true
        },
        "users": {
          "nullable": true,
          "$ref": "#/objects/users",
          "relation": {
            "attrKey": [
              "user_id"
            ],
            "foreignAttrKey": [
              "id"
            ],
            "onUpdate": "NoAction",
            "onDelete": "NoAction"
          }
        }
      }
    },
    "topics": {
      "properties": {
        "description": {
          "type": "string",
          "nullable": true
        },
        "id": {
          "type": "integer",
          "default": {
            "function": "autoincrement"
          },
          "identifier": true
        },
        "links": {
          "type": "array",
          "items": {
            "$ref": "#/objects/links"
          }
        },
        "title": {
          "type": "string",
          "sourceType": [
            "VarChar",
            200
          ],
          "nullable": true
        }
      }
    },
    "users": {
      "properties": {
        "email": {
          "type": "string",
          "sourceType": [
            "VarChar",
            200
          ],
          "nullable": true
        },
        "first_name": {
          "type": "string",
          "sourceType": [
            "VarChar",
            100
          ],
          "nullable": true
        },
        "id": {
          "type": "integer",
          "default": {
            "function": "autoincrement"
          },
          "identifier": true
        },
        "last_name": {
          "type": "string",
          "sourceType": [
            "VarChar",
            100
          ],
          "nullable": true
        },
        "password": {
          "type": "string",
          "sourceType": [
            "VarChar",
            500
          ],
          "nullable": true
        },
        "posts": {
          "type": "array",
          "items": {
            "$ref": "#/objects/posts"
          }
        }
      }
    }
  }
}

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": "new-user@example.com",
          "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": "multi-post@example.com",
      "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 1 year ago