Skip to main content

API wrapper for Airtable written in Python

Project description

airtable-python

airtable-python is an API wrapper for Airtable, written in Python

  • Use this library if you are interested in Oauth authentication and webhook notifications.

Installing

pip install airtable-python

Usage

from airtable.client import Client
client = Client(client_id, client_secret, redirect_uri, code_verifier)

Note: If you already have an access token, you can initiate Client without any parameters and directly set token with the access token you have as a dictionary client.set_token({"access_token": token})

Get access_token

To get the access token using Oauth2 follow the next steps. Check https://airtable.com/developers/web/api/oauth-reference for more info:

  1. Get authorization URL to receive code
url = client.authorization_url(state)
  1. Get access token using code
token = client.token_creation(code)
  1. Set access token
client.set_token(access_token)

If your access token expired, you can get a new one using refresh_token:

response = client.refresh_access_token(refresh_token)

And then set access token again...

Get current user

user = client.get_current_user()

List Bases

bases = client.list_bases()

List Tables

tables = client.list_base_tables(baseId)

List records

records = client.list_records(
    baseId, 
    tableId, 
    pageSize=None, 
    maxRecords=None, 
    filter_field=None, 
    filter_value=None, 
    sort_field=None, 
    sort_direction=None
)
# baseId and tableId are required
# sort_direction options are 'desc' or 'asc'

Create Records

records = [
    {
        "fields": {
          "Projects": "Project from python",
          "Status": "In progress",
          "Complete?": False
        }
    },
]
records = client.create_records(baseId, tableId, records)

Update Record

data = {
    "Status": "Complete",
    "Complete?": True
}
record = client.update_record(baseId, tableId, recordId, data)

Update Multiple Records

records = [
    {
        "id": "recB4UscNECOHnT7y",
        "fields": {
            "Number": 10000,
        },
    },
    {
        "id": "recFkktx671jlvyj8",
        "fields": {
            "Number": 20000,
        },
    },
]
updated_records = client.update_record(baseId, tableId, records)

List Collaborators (needs enterprise scopes access)

collabs = client.list_collaborators(baseId)

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

airtable_python-0.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

airtable_python-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file airtable_python-0.1.1.tar.gz.

File metadata

  • Download URL: airtable_python-0.1.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for airtable_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5dc6e5be6c2422bc187831e89635bd686c666258f72f2b69515a4df29f873ef7
MD5 9b720f178c04a2ee4e93e77ced8936d7
BLAKE2b-256 61ac909f9da9b21bc1d179183de254c4c188cada687156a0e33d66c5fde0dba2

See more details on using hashes here.

File details

Details for the file airtable_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for airtable_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9da8a08575b8f91f22de33699159ca68e297ee5392a2eb4e65f1ceb2c4f9805a
MD5 5afb5a15c79fda5f9c826d23e0650bfe
BLAKE2b-256 0abd68399f71ce61fb35db8dda6a17796686b0e0c13a326edddd88391b280a4f

See more details on using hashes here.

Supported by

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