Skip to main content

Python client library for AirTable

Project description

Python interface to the Airtable’s REST API - https://airtable.com - Build Status

For javascript enthusiasts: https://github.com/Airtable/airtable.js

Installation

Airtable Python uses Requests.py: make sure you have it installed by running

$ pip install requests

Getting started

Once you have created a new base and a new table through the Web interface, you’re ready to start using Airtable Python.

from airtable import airtable
at = airtable.Airtable('BASE_ID', 'API_KEY')
at.get('TABLE_NAME')

Here’s an example of response from the Restaurant’s example base

{u'records': [
  {u'fields': {u'Diet': u'Kosher or Halal',
    u'Friendly Restaurants': [u'recr0ITqq9C1I92FL', u'recGeAJLw0ZkbwdXZ'],
    u'Icon': [{u'filename': u'no-pig.jpg',
      u'id': u'attzKGOBbjndOx0FU',
      u'size': 34006,
      u'thumbnails': {u'large': {u'height': 202,
        u'url': u'https://dl.airtable.com/trmtq3BaRoa0sWnyffWZ_large_no-pig.jpg',
        u'width': 256},
       u'small': {u'height': 36,
        u'url': u'https://dl.airtable.com/yzuRv5CyRs2PVH4fDvCe_small_no-pig.jpg',
        u'width': 46}},
      u'type': u'image/jpeg',
      u'url': u'https://dl.airtable.com/DyGOjAASze6AIkQxFpDv_no-pig.jpg'}],
    u'People': [u'Annie', u'Maryam']},
   u'id': u'rec5sD6mBBd0SaXof'},
   ...

API Reference

The available methods closely mimick the REST API:

Get

Given a table name, fetched one or multiple records.

at.get(table_name, table_name, record_id=None, limit=0, offset=None,
       filter_by_formula=None, view=None, max_records=0, fields=[])

where

table_name (required) is a string representing the table name
record_id (optional) is a string, which fetches a specific item by id. If not specified, all items are fetched
limit (optional) is an integer, and it can only be specified if record_id is not present, and limits the number of items fetched (see pageSize in the AirTable documentation)
offset is a string representing the record id from which we start the offset
filter_by_formula (optional) is a string to filter the retrieving records (see filterByFormula in the AirTable documentation)
max_records (optional) is the total number of records that will be returned (see maxRecords in the AirTable documentation)
fields (optional) is a list of strings with the field names to be returned

Iterate

Given a table name, fetched all records.

at.iterate(table_name, table_name, limit=0, offset=None,
       filter_by_formula=None, view=None, max_records=0, fields=[])

where

table_name (required) is a string representing the table name
limit (optional) is an integer, and it can only be specified if record_id is not present, and limits the number of items fetched (see pageSize in the AirTable documentation)
offset is a string representing the record id from which we start the offset
filter_by_formula (optional) is a string to filter the retrieving records (see filterByFormula in the AirTable documentation)
max_records (optional) is the total number of records that will be returned (see maxRecords in the AirTable documentation)
fields (optional) is a list of strings with the field names to be returned

Note: this returns a generator instead, which you can use to loop each record:

# example with similar results of at.get
result = { "records": [] }
for r in self.at.iterate(self.table, fields=fields):
    result["records"].append(r)

Create

Creates a new entry in a table, and returns the newly created entry with its new ID.

at.create(table_name, data)

where

table_name (required) is a string representing the table name
data (required) is a dictionary containing the fields and the resepective values

Update

Updates some fields in a specific entry in the table. Fields which are not explicitely included will not get updated

at.update(table_name, record_id, data)

where

table_name (required) is a string representing the table name
record_id (required) is a string representing the item to update
data (required) is a dictionary containing the fields (and the resepective values) to be updated

Update All

Like the previous method, but updates all fields, clearing the ones that are not included in the request.

at.update_all(table_name, record_id, data)

Delete

Delete a specific record from the table

at.delete(table_name, record_id)

where

table_name (required) is a string representing the table name
record_id (required) is a string representing the item to update

Release

To release, tag the Git repo with a new version number, push that tag to GitHub then Travis CI will do the rest.

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-0.4.4.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

airtable-0.4.4-py2.py3-none-any.whl (8.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file airtable-0.4.4.tar.gz.

File metadata

  • Download URL: airtable-0.4.4.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for airtable-0.4.4.tar.gz
Algorithm Hash digest
SHA256 3e2adb300f7fd815c127999aa0bcf4025ffbd5c22dd6d0ff2d7ab8560247c63b
MD5 422ff3d88d0b4fd00005b5ca86cb6449
BLAKE2b-256 821265009bea3c7a346be94021ceae7bfb64ff8e80625b408aa2f7ed77a39c9f

See more details on using hashes here.

File details

Details for the file airtable-0.4.4-py2.py3-none-any.whl.

File metadata

  • Download URL: airtable-0.4.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for airtable-0.4.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 84305b039eeebbab54d4c5a16dd583c655a6ad5a8cb84c85a52223c20f506cbe
MD5 11bc6ec443d79620919a0df74131bc1f
BLAKE2b-256 adc2d3a8bd790f5c473b894545d0563a2f8a79ee334fa96600fc21e4806622f4

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