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
  • Overview
  • Installation
  • Usage
  • API Usage
  • Example Applications
  1. SDKs

Python SDK

PreviousGo SDKNextPython SDK Tutorial -- News Application

Last updated 10 months ago

Overview

The generated Neurelo Python SDK provides easy access to your Neurelo APIs for Python applications.

Refer to this guide Python SDK Tutorial -- News Application for a detailed tutorial on downloading, installing, and using the Python SDKs with FastAPI.

Installation

Download the Custom Python SDK for your Project from the APIs page under the Neurelo environment that you want to interact with.

A gzip compressed tar archive (.tgz) SDK file should be downloaded. First, uncompress this file to get the underlying folder. Doing so, you are likely to see a directory as follows:

The downloaded SDK file will be named - neurelo-sdk-python-cmt_xxxxxx.tgz (where xxxxxx are the last 6 digits of the definition commit applied to the environment)

To install the necessary dependencies for this SDK, we will use the requirements.txt as follows:

$ python3 -m pip install -r ./requirements.txt

If you have used Neurelo SDK’s in the past, to ensure that the older version of neurelo package is uninstalled, do a python3 -m pip uninstall neurelo and rerun your requirements.txt command from above.

Usage

API Usage

Basic usage requires instantiating both a Configuration and an ApiClient class:

from neurelo.configuration import Configuration
from neurelo.api_client import ApiClient

configuration = Configuration(
	host=NEURELO_API_HOST,
	api_key={'ApiKey': NEURELO_API_KEY}
)

api_client = ApiClient(configuration=configuration)

Each object defined in your Neurelo data definition has a class that can be instantiated by passing the ApiClient instance into the constructor of the object's class. For example, if your data definition contains a 'User' object, you can instantiate the User class by passing the ApiClient instance into its constructor as shown below:

from neurelo.api.user_api import UserApi

user_api = UserApi(api_client)

To obtain the NEURELO_API_HOST, simply copy the host name mentioned in the Environments tab.

$ export NEURELO_API_KEY="<YOUR-API-KEY>"
$ export NEURELO_API_HOST="<HOST-NAME>"

When calling operations with body, the body is encapsulated within specific classes. To use it, create an instance of the respective class and use the parameter values, as shown below:

from neurelo import models

payload = models.UserCreateInput(
  email=email,
  fullname=fullname,
  password=password,
)

user = user_api.create_one_user(payload)

Similarly, when calling operations with parameters (for example, fetching all user info containing a email as XYZ), the parameters are also encapsulated within specific classes. To use these parameters, we create an instance of the respective class and use it as the parameter value, as shown below.

filtered = models.UserWhereInput.from_dict({"email": {"equals": template_email}})
users = user_api.find_user(filter=filtered)

Although you can directly make API calls with parameters using the object API class as follows: user_api.find_user(filter=<filter-condition>), we do not recommend this approach. Instead, use the models submodule to create the parameters.

Type hints are available for all parameters, for all operations to aid in understanding which class is should be used with each parameter.

Example Applications

The following applications are provided to demonstrate how to use Neurelo, and Neurelo’s generated Python SDK.

Additionally, you can generate a NEURELO_API_KEY by from the “API Keys” tab. You can export these values using a command similar to the following in our terminal:

It is important to use our models submodule to create these parameters. The resulting parameter expression, like {"email": {"equals": template_email}}, is standard with our REST API. More information on this can be found in our .

To review more examples of applications built using Neurelo's SDK, please visit

creating a new API Key
Neurelo API Reference (REST) guide
Python SDK Tutorial (News Application)
Python FastAPI + Jinja FullStack App
Projects built using Neurelo SDKs