Skip to main content

A simple NocoDB API v2 wrapper

Project description

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)

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nihook_client-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nihook_client-0.1.0-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file nihook_client-0.1.0.tar.gz.

File metadata

  • Download URL: nihook_client-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for nihook_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7d24d092742072a5214cdbab5bd1234727ca3336e55322d033a635ee607390f
MD5 e70500d604c6e0deb7a2c7a226f8e52f
BLAKE2b-256 64216f3eacadfeeaa9563bc4c3428d120d9fe3378333f2c4b7da96a29559f528

See more details on using hashes here.

File details

Details for the file nihook_client-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nihook_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for nihook_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1711696cd21f50021ff420dc96eb80fc9e28bb18d8c317a4d4fd6c9513d6eef3
MD5 f4ed7869a79425071dd971f751911276
BLAKE2b-256 e5e34b4dad52aeabe8fe2817dde86bb0ee4132cb43c7ff38dacc6e1879e6666a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page