Skip to content

Instantly share code, notes, and snippets.

@abduhbm
Created April 10, 2019 14:57
Show Gist options
  • Save abduhbm/e2f278c70913e8dbfa95d9097598f1e2 to your computer and use it in GitHub Desktop.
Save abduhbm/e2f278c70913e8dbfa95d9097598f1e2 to your computer and use it in GitHub Desktop.
Retrieve a table from Airtable to Pandas DataFrame
import requests
import pandas as pd
BASE_URL = 'https://api.airtable.com/v0/'
def airtable_to_dataframe(base_name, table_name, api_key):
header = {'Authorization': 'Bearer ' + api_key}
data = []
r = requests.get(BASE_URL + base_name + '/' + table_name, headers=header)
for x in r.json().get('records'):
x.update(x.get('fields'))
x.pop('fields')
data.append(x)
df = pd.DataFrame(data)
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment