api.integrations.airtable

Airtable, through pyAirtable (https://pyairtable.readthedocs.io).

The main base’s records as dictionaries:

from api.integrations import airtable
from api.integrations.airtable import schema
units = airtable.list_records(schema.ToutesLesUnites.TABLE, "{Statut commercial} = 'A vendre'")

or as typed objects, through the generated ORM classes of schema:

schema.ToutesLesUnites.all(formula=...)

pyAirtable retries a request refused for the rate limit (429) and never resends one that failed otherwise, so a creation cannot be duplicated. Other bases (the auctions base) use api().

Submodules

Attributes

Functions

api([token]) → pyairtable.Api

A pyAirtable client: the main base's token by default.

table(name) → pyairtable.Table

A table of the main base.

get_record(table_name, record_id) → Record

list_records(table_name[, formula, fields, view]) → list[Record]

Every record of the table, optionally filtered by an Airtable formula.

get_records(table_name, record_ids) → list[Record]

These records, in this order; ids that no longer exist are left out.

create_record(table_name, fields) → Record

create_records(table_name, fields_list) → list[Record]

update_record(table_name, record_id, fields) → Record

update_records(table_name, updates) → list[Record]

updates is [{"id": ..., "fields": {...}}, ...].

delete_record(table_name, record_id) → None

upload_attachment(table_name, record_id, field, ...[, ...]) → Record

Adds a file (5 MB max) to an attachment field; Airtable keeps its own copy.

base_schema() → list[dict[str, Any]]

The main base's tables and fields, as Airtable describes them (cached).

select_choices(table_name, field) → list[str]

The options of a single or multiple select field, in Airtable's order.

ids_by_name(table_name[, name_field]) → dict[str, str]

Record id of each name in the table (read once; see clear_caches).

names_by_id(table_name[, name_field]) → dict[str, str]

clear_caches() → None

Forget the cached structure and names (after a change in Airtable).

Package Contents

api.integrations.airtable.Record
api.integrations.airtable.api(token: str | None = None) → pyairtable.Api

A pyAirtable client: the main base’s token by default.

api.integrations.airtable.table(name: str) → pyairtable.Table

A table of the main base.

api.integrations.airtable.get_record(table_name: str, record_id: str) → Record
api.integrations.airtable.list_records(table_name: str, formula: str | None = None, *, fields: list[str] | None = None, view: str | None = None) → list[Record]

Every record of the table, optionally filtered by an Airtable formula.

api.integrations.airtable.get_records(table_name: str, record_ids: list[str]) → list[Record]

These records, in this order; ids that no longer exist are left out.

api.integrations.airtable.create_record(table_name: str, fields: dict[str, Any]) → Record
api.integrations.airtable.create_records(table_name: str, fields_list: list[dict[str, Any]]) → list[Record]
api.integrations.airtable.update_record(table_name: str, record_id: str, fields: dict[str, Any]) → Record
api.integrations.airtable.update_records(table_name: str, updates: list[Record]) → list[Record]

updates is [{“id”: …, “fields”: {…}}, …].

api.integrations.airtable.delete_record(table_name: str, record_id: str) → None
api.integrations.airtable.upload_attachment(table_name: str, record_id: str, field: str, content: bytes, filename: str, content_type: str = 'application/pdf') → Record

Adds a file (5 MB max) to an attachment field; Airtable keeps its own copy.

api.integrations.airtable.base_schema() → list[dict[str, Any]]

The main base’s tables and fields, as Airtable describes them (cached).

api.integrations.airtable.select_choices(table_name: str, field: str) → list[str]

The options of a single or multiple select field, in Airtable’s order.

api.integrations.airtable.ids_by_name(table_name: str, name_field: str = 'Name') → dict[str, str]

Record id of each name in the table (read once; see clear_caches).

api.integrations.airtable.names_by_id(table_name: str, name_field: str = 'Name') → dict[str, str]
api.integrations.airtable.clear_caches() → None

Forget the cached structure and names (after a change in Airtable).