Created
March 25, 2025 19:47
-
-
Save d10r/091743ac265bb2c97d1435a3cd7d9902 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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