Skip to main content

Python API to interact with Airtable

Project description

AirtablePy

build status

Python API to interact with Airtable

Table of Contents

  1. Installation
  2. API Token
  3. Simple Interface
  4. License

Installation

AirtablPy is available on pypi. Install using pip.

pip install AirtablePy

API Token

To use the Airtable API, you need a valid token. You may setup an environment variable called AIRTABLE_API_KEY which this interface will use.

Simple Interface

from AirtablePy import AirtableAPI
from AirtablePy.utils import retrieve_keys
from AirtablePy.query import date_query

# Instantiate interface with valid token.
# If token is not specified, it will search for environment variable AIRTABLE_API_KEY
api = AirtableAPI(token="keyXXXXXXXXXXXXXX")

# Construct a valid url
base_id = "appXXXXXXXXXXXXXX"
table_name = "Example Table"
url = api.construct_url(base_id, table_name)

# Retrieve records from a table, with or without a query filter
records = api.get(url, query=date_query(column_name="date", start="20220401", end="20220415"))

# Upload new data entries
data = {"Column 1": [1, 2, 3], "Column 2": [4, 5, 6]}
response_upload = api.push(url=url, data=data)

# Collect a list of record id's from upload
record_ids = retrieve_keys(response_upload, "id")

# Update records with additional (or modified) data
data_update = {"Column 3": [7, 8, 9]}  # data will be present in all three columns
response_update = api.update(url=url, data=data_update, record_id=record_ids)

# Replace existing records with different data
data_replace = {"Column 2": [10, 11, 12]}  # only column 2 will have data
response_replace = api.replace(url=url, data=data_replace, record_id=record_ids)

# Delete existing Records
response_delete = api.delete(url=url, record_id=record_ids)

License

MIT

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

AirtablePy-0.1.3.tar.gz (12.0 kB view hashes)

Uploaded Source

Built Distribution

AirtablePy-0.1.3-py3-none-any.whl (12.6 kB view hashes)

Uploaded Python 3

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