Skip to main content

Awesome simple_baserow_api created by KuechlerO

Project description

simple_baserow_api

A lightweight Python wrapper for the Baserow REST API, developed by Oliver Kuechler, forked from xiamaz' python-baserow-simple.

📚 Full documentation available at: simple_baserow_api Documentation

🚀 Installation

pip install simple_baserow_api

🔧 Features

  • Intuitive access to Baserow tables, fields, and rows
  • Reading and writing table data (single and batch)
  • Field metadata, writable-field detection, and read-only handling
  • Optional linked-row resolution and field include/exclude
  • Lookup rows by column value (find_entries)
  • Synchronize / upsert a row from one table into another (synchronize_data)
  • Optional field-compatibility checks when writing
  • JWT login helpers and schema operations (create/delete database & tables)

🛠️ Basic Usage

1. Initialize the API

Database token (row data)

from simple_baserow_api import BaserowApi

api = BaserowApi(
    database_url="https://api.baserow.io",  # or your self-hosted URL
    token="your-database-token",
)

JWT from email / password (needed for schema changes)

api = BaserowApi.from_credentials(
    database_url="https://api.baserow.io",
    email="you@example.com",
    password="secret",
)

2. Retrieve Table Metadata

Get All Field Definitions

fields = api.get_fields(table_id=1)

Get Writable Fields (excluding read-only)

Some fields are read-only and cannot be written to (e.g. formula fields). This is useful when you want to add a new row to a table.

writable_fields = api.get_writable_fields(table_id=1)

Output

[
    {
        "id": 1,
        "table_id": 1,
        "name": "Name",
        "order": 0,
        "type": "text",
        "primary": True,
        "read_only": False,
        "description": None,
        "text_default": ""
    },
    ...
]

3. Read Table Data

Get All Rows

rows = api.get_data(table_id=1, writable_only=True)
# -> {row_id: {"Name": "...", ...}, ...}

Get a Single Row by ID

row = api.get_entry(table_id=1, row_id=1)

Find Rows by Column Value

matches = api.find_entries(table_id=1, column="Individuum ID", value="ABC-123")
# -> {row_id: {...}, ...}

4. Write Data

Add a New Row

row_id = api.add_data(table_id=1, data={"Name": "value"})

Update an Existing Row

row_id = api.add_data(table_id=1, row_id=1, data={"Name": "new_value"})

Field Compatibility Check

Validate that payload keys exist on the table before writing. On mismatch: warn (default) or raise when fail_on_error=True.

row_id = api.add_data(
    table_id=1,
    data={"Name": "value", "UnknownField": "x"},
    check_field_compatibility=True,
    fail_on_error=False,  # warn and continue
)

The same options exist on add_data_batch.

Add or Update Multiple Rows

# No ID: new row is created; with ID: existing row is updated
entries = [
    {"Name": "value1"},
    {"id": 2, "Name": "updated_value2"},
]

row_ids, errors = api.add_data_batch(table_id=1, entries=entries, fail_on_error=True)

5. Synchronize a Row Between Tables

Copy one source row into a target table. Matching uses an identifier column (update if found, otherwise create). Compatible fields are transferred; untransferable values produce warnings (or errors with fail_on_error=True). Link-row values are rematched in the target linked table.

target_row_id, messages = api.synchronize_data(
    source_table_id=10,
    source_row_id=5,
    target_table_id=20,
    identifier_column="Individuum ID",
    field_mapping={"Kommentar": "Kommentar Einschluss"},  # optional renames
    include_fields=["Individuum ID", "Vorname", "Nachname"],  # optional allowlist
    exclude_fields=["existierender Index"],  # optional skips
    fail_on_error=False,
)

# Preview without writing
target_row_id, messages = api.synchronize_data(
    source_table_id=10,
    source_row_id=5,
    target_table_id=20,
    identifier_column="Individuum ID",
    dry_run=True,
)
# messages include "dry_run: would create/update ..." and payload field names

6. Advanced Options

Include or Exclude Specific Fields

filtered_data = api.get_data(table_id=1, include=["Name", "Status"])
filtered_data = api.get_data(table_id=1, exclude=["InternalNotes"])

Resolve Linked Fields Automatically

row = api.get_entry(table_id=1, row_id=1, linked=True)

7. Schema Helpers (JWT)

Creating or deleting databases/tables requires a JWT-authenticated client (BaserowApi.from_credentials or jwt_token=True).

workspaces = api.list_workspaces()
database = api.create_database(workspace_id=workspaces[0]["id"], name="My DB")
table = api.create_table(
    database_id=database["id"],
    name="Samples",
    primary_field_name="Sample-ID",
    fields=[
        {"name": "Status", "type": "single_select",
         "select_options": [{"value": "open", "color": "blue"}]},
    ],
)
api.delete_table(table["id"])
api.delete_database(database["id"])

💻 Development

Want to contribute? See our CONTRIBUTING.md guide.

Integration tests create ephemeral tables against Baserow.io; see tests/conftest.py for credentials / env overrides (BASEROW_URL, BASEROW_EMAIL, BASEROW_PASSWORD).


Thank you for using simple_baserow_api.
Please report bugs or request features by opening an issue on the GitHub repository.

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

simple_baserow_api-0.2.1.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

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

simple_baserow_api-0.2.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file simple_baserow_api-0.2.1.tar.gz.

File metadata

  • Download URL: simple_baserow_api-0.2.1.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for simple_baserow_api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e011f64b5a24e74f5ab4e9e4b404068a865b6bf0facbac558af41d42280b2f4e
MD5 ea8ad507281c0ae9d8dbcb469a464eaa
BLAKE2b-256 515a72f0e6a04df0381b60aadceb82347144a5b0974f8aac589a1301059c6bd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_baserow_api-0.2.1.tar.gz:

Publisher: release.yml on KuechlerO/simple_baserow_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_baserow_api-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_baserow_api-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca1452232b0d659d629965b21cd40fbdd58b2c5214da12b878b07080463b7565
MD5 ee572391e91988d73c54d6e4d413d708
BLAKE2b-256 fedbc25d0ad8664608154c261a1e95264902f46a917455267028f19eeb230ccb

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_baserow_api-0.2.1-py3-none-any.whl:

Publisher: release.yml on KuechlerO/simple_baserow_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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