NocoDB Simple Client

1.3.2 · active · verified Thu Apr 16

A simple and powerful Python client for the NocoDB REST API, allowing interaction with NocoDB projects, tables, and records. It handles API authentication and provides a Pythonic interface for CRUD operations. The current version is 1.3.2, and it follows NocoDB's API changes with new releases.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the NocoDB client using environment variables for sensitive details, then lists tables and fetches records from an example table. This helps verify basic connectivity and authentication.

import os
from nocodb_simple_client import NocoDBClient

# It is recommended to use environment variables for sensitive data
BASE_URL = os.environ.get("NOCODB_BASE_URL", "http://localhost:8080")
AUTH_TOKEN = os.environ.get("NOCODB_AUTH_TOKEN", "YOUR_AUTH_TOKEN_HERE") # X-NocoDB-Auth token
PROJECT_ID = os.environ.get("NOCODB_PROJECT_ID", "p00000000000000000000000000") # Replace with your actual Project ID

try:
    client = NocoDBClient(
        base_url=BASE_URL,
        auth_token=AUTH_TOKEN,
        project_id=PROJECT_ID
    )

    # Example: List all tables in the project
    # This requires the AUTH_TOKEN and PROJECT_ID to be valid.
    tables_response = client.tables.list()
    print(f"Tables in project: {[t['title'] for t in tables_response.get('list', [])]}")

    # Example: Get records from a specific table
    # Replace 'MyTable' with an actual table name from your NocoDB project
    TABLE_NAME = os.environ.get("NOCODB_EXAMPLE_TABLE", "TestTable")
    print(f"\nAttempting to fetch records from table: {TABLE_NAME}")
    records = client.tables.get_all(TABLE_NAME)
    print(f"First 3 records from {TABLE_NAME}: {records[:3]}")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure NOCODB_BASE_URL, NOCODB_AUTH_TOKEN, and NOCODB_PROJECT_ID are correctly set.")
    print("Also verify the NOCODB_EXAMPLE_TABLE exists and is accessible by the provided token.")

view raw JSON →