Created
April 10, 2019 14:57
-
-
Save abduhbm/e2f278c70913e8dbfa95d9097598f1e2 to your computer and use it in GitHub Desktop.
Retrieve a table from Airtable to Pandas DataFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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