api.integrations.airtable ========================= .. py:module:: api.integrations.airtable .. autoapi-nested-parse:: 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 ---------- .. toctree:: :maxdepth: 1 /reference/api/integrations/airtable/schema/index Attributes ---------- .. autoapisummary:: api.integrations.airtable.Record Functions --------- .. autoapisummary:: api.integrations.airtable.api api.integrations.airtable.table api.integrations.airtable.get_record api.integrations.airtable.list_records api.integrations.airtable.get_records api.integrations.airtable.create_record api.integrations.airtable.create_records api.integrations.airtable.update_record api.integrations.airtable.update_records api.integrations.airtable.delete_record api.integrations.airtable.upload_attachment api.integrations.airtable.base_schema api.integrations.airtable.select_choices api.integrations.airtable.ids_by_name api.integrations.airtable.names_by_id api.integrations.airtable.clear_caches Package Contents ---------------- .. py:data:: Record .. py:function:: api(token: str | None = None) -> pyairtable.Api A pyAirtable client: the main base's token by default. .. py:function:: table(name: str) -> pyairtable.Table A table of the main base. .. py:function:: get_record(table_name: str, record_id: str) -> Record .. py:function:: 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. .. py:function:: get_records(table_name: str, record_ids: list[str]) -> list[Record] These records, in this order; ids that no longer exist are left out. .. py:function:: create_record(table_name: str, fields: dict[str, Any]) -> Record .. py:function:: create_records(table_name: str, fields_list: list[dict[str, Any]]) -> list[Record] .. py:function:: update_record(table_name: str, record_id: str, fields: dict[str, Any]) -> Record .. py:function:: update_records(table_name: str, updates: list[Record]) -> list[Record] `updates` is `[{"id": ..., "fields": {...}}, ...]`. .. py:function:: delete_record(table_name: str, record_id: str) -> None .. py:function:: 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. .. py:function:: base_schema() -> list[dict[str, Any]] The main base's tables and fields, as Airtable describes them (cached). .. py:function:: select_choices(table_name: str, field: str) -> list[str] The options of a single or multiple select field, in Airtable's order. .. py:function:: 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). .. py:function:: names_by_id(table_name: str, name_field: str = 'Name') -> dict[str, str] .. py:function:: clear_caches() -> None Forget the cached structure and names (after a change in Airtable).