Skip to main content

NocoDB Client

A simple, Python-based wrapper and CLI for the NocoDB API v2, allowing you to interact with your NocoDB instances programmatically.

Features

  • Manage Bases: List, create, and delete bases.
  • Manage Tables: Create tables from JSON schema, list tables, view table metadata.
  • Data Operations: Insert, update, delete, and read records.
  • CLI Tools: Scripts to automate table creation and data ingestion.

Installation

From Source

Clone the repository and install using pip:

git clone <repository-url> nihook-client
cd nihook-client
pip install .

For Development

To install development dependencies (like pytest and requests-mock) along with the package:

pip install ".[dev]"

Configuration

The client relies on environment variables for connection details. You can set them in your shell or use a .env file manager.

Variable Description Default
NOCODB_HOST URL of your NocoDB instance http://localhost
NOCODB_TOKEN Your NocoDB API Token none
NOCODB_SSL_CERT True/False to enable/disable verification True

Example:

export NOCODB_HOST="https://my-nocodb.example.com"
export NOCODB_TOKEN="your-api-token-here"

Usage

As a Python Library

import os
from nihook_client import Nocodb

# Initialize client
client = Nocodb(
    host=os.getenv("NOCODB_HOST"),
    auth_token=os.getenv("NOCODB_TOKEN")
)

# List all bases
bases = client.list_bases()
print(bases)

# Get a specific base
base = client.get_base_object("My Project")

if base:
    # List tables in the base
    tables = base.list_tables()
    print(tables)
    
    # Get a specific table
    table = base.get_table_object("Employees")
    
    # Read records
    if table:
        records = table.list_records()
        for record in records['list']:
            print(record)

Error Handling

Failures raise exceptions that carry the message of the underlying problem — for NocoDB API failures that is the message NocoDB itself reported. Every exception derives from NihookClientError, so a single except clause can cover them all.

from nihook_client import NihookClientError, NocodbError, ReservedColumnError
from nihook_client.table_from_schema import create_new_table_from_schema

try:
    table_id = create_new_table_from_schema(host, token, ssl_cert, base_id, "Datasets", schema)

except ReservedColumnError as e:
    # the schema uses a key reserved for 'URL', 'status' or 'branch'
    print(f"rename '{e.column_name}' in the input schema: {e}")

except NocodbError as e:
    # e.response holds the decoded JSON body of the failed request
    print(f"NocoDB refused the request: {e} ({e.response})")

except NihookClientError as e:
    print(f"failed: {e}")
Exception Raised when
NihookClientError Base class of all of the below
SchemaError The input schema cannot be mapped to a table, e.g. a key without a type
ReservedColumnError The schema uses one of the reserved keys URL, status, branch
UnsupportedTypeError A key has a type that has no NocoDB column equivalent
NocodbError The NocoDB API rejected a request; .response holds the JSON body

The python3 -m nihook_client.* scripts catch these, print the message to stderr and exit with a non-zero status, so command line behaviour is unchanged.

CLI Command

The package installs a nihook-client command for checking versions and basic interaction.

nihook-client -v

Utility Scripts

The package includes several distinct modules that can be run to perform automation tasks.

1. Create Table from Schema Creates a new NocoDB table based on a JSON schema file.

python3 -m nihook_client.table_from_schema my_schema.json --base <base_id> --name "New Table"

2. Enter Dataset Imports data from a JSON file into an existing table.

python3 -m nihook_client.enter_dataset --file DATASET.json --base <base_id> --table "TableName"

Development

  1. Install in editable mode with dev dependencies:
    pip install -e ".[dev]"
    
  2. Run tests:
    pytest
    

Requirements

  • Python 3.12+
  • requests
  • pandas
  • python-dateutil
  • jsonschema

Metadata

Release files for nihook-client 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nihook-client 0.1.1
File Size Uploaded Provenance Actions
nihook_client-0.1.1.tar.gz 19.8 kB Without provenance Details for nihook_client-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nihook-client 0.1.1
File Interpreter ABI Platform Actions
nihook_client-0.1.1-py3-none-any.whl Python 3 none any Details for nihook_client-0.1.1-py3-none-any.whl

Total release size: 41.2 kB

Release files / nihook_client-0.1.1.tar.gz

Download URL nihook_client-0.1.1.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a6c900c582b1a4d04fafbbea20b0323f944377742b9622febefd0950bf707ec3
BLAKE2b-256 checksum
How to use checksums
35cebedf809af2f96a135de127ace39b2ff3e367022bf2853a9fe9187f7a47a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / nihook_client-0.1.1-py3-none-any.whl

Download URL nihook_client-0.1.1-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
659af6a354631ab1813df8166884fe43c28ec1fdaf521bf67ad751d7ffc4552a
BLAKE2b-256 checksum
How to use checksums
5c516f83c98ed2ba319f008f6bcf458662810dbb532b0dd8ee1aecec41a00e1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for nihook-client 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page