Skip to content

Instantly share code, notes, and snippets.

@d10r
Created March 25, 2025 19:47
Show Gist options
  • Save d10r/091743ac265bb2c97d1435a3cd7d9902 to your computer and use it in GitHub Desktop.
Save d10r/091743ac265bb2c97d1435a3cd7d9902 to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage: airtable-to-json.sh <airtable-url-from-browser> > my-data.json
AIRTABLE_URL=$1
API_KEY=${AIRTABLE_API_KEY}
# Check if API_KEY is set
if [ -z "$API_KEY" ]; then
echo "Error: AIRTABLE_API_KEY environment variable is not set"
echo "Please set it with: export AIRTABLE_API_KEY=your_api_key"
exit 1
fi
URL_PARTS=$(echo "$AIRTABLE_URL" | cut -d '?' -f 1)
BASE_AND_TABLE=$(echo "$URL_PARTS" | cut -d '/' -f 4-5)
VIEW=$(echo "$URL_PARTS" | cut -d '/' -f 6)
REQUEST_URL="https://api.airtable.com/v0/${BASE_AND_TABLE}?view=${VIEW}"
curl -s -X GET \
${REQUEST_URL} \
-H 'Authorization: Bearer '$API_KEY \
-H 'Content-Type: application/json' | jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment