This repo includes a st.connection for Airtable which wraps the popular community created and maintained pyAirtable library.
The initial focus of this connector is on read-only operations: specifically listing records and retrieving the schema of an Airtable base. Write-back support may be added in the future.
A live demo of the code example in examples/explore.py can be accessed on Streamlit Cloud at http://marks-airtable-connection-demo.streamlit.app [demo video]. Provide your Open AI API key to be able to ask questions about the data in the selected Airtable table. The underlying data can be viewed and cloned here.
See examples/ for additional examples
[connections.your_connection_name] personal_access_token = "patXXX" # REQUIRED base_id = "appXXX" # optional table_id = "tblXXX" # optional ℹ️ The Airtable personal access token you use should have both data.records:read and schema.bases:read scopes to use all functionality of this connector.
import streamlit as st from streamlit_airtable import AirtableConnection # Create connection conn = st.connection("your_connection_name", type=AirtableConnection) # Retrieve base schema base_schema = conn.get_base_schema() with st.expander("Base schema"): st.json(base_schema) # Get the first table's ID first_table = base_schema["tables"][0] st.markdown(f"First table ID: `{first_table['id']}` (named `{first_table['name']}`)") # Retrieve all records for the first table (pyAirtable paginates automatically) # (Note you can also pass in parameters supported by pyAirtable # (https://pyairtable.readthedocs.io/en/stable/api.html#parameters) such as as # max_records, view, sort, and formula into conn.query() like so: # table_records = conn.query(first_table["id"], max_records=25, view='viwXXX') table_records = conn.query(table_id=first_table["id"]) st.markdown(f"{len(table_records)} records retrieved") st.dataframe(table_records)- Clone/download this repo
- Install the connector (
pip install -e .) - Move into the
examples/dir (cd examples/) - Copy
.streamlit/secrets.toml.exampleto.streamlit/secrets.tomland provide your own values - Run
streamlit run minimal_example.py
- Streamlit connection examples: Google Sheets & DuckDB
- pyAirtable