Skip to content

Instantly share code, notes, and snippets.

@fiatjaf
Created March 26, 2023 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiatjaf/2536370dd381f1e5d7fe448ac0f4d709 to your computer and use it in GitHub Desktop.
Save fiatjaf/2536370dd381f1e5d7fe448ac0f4d709 to your computer and use it in GitHub Desktop.
overview of an Airtable "base" using Go

just some boilerplate for demonstrative purposes and learning how the API works and how to access each field, where and what are the IDs of each table and so on.

package main
import (
"fmt"
"github.com/mehanizm/airtable"
)
func main() {
client := airtable.NewClient(TOKEN)
bases, _ := client.GetBases().WithOffset("").Do()
for _, base := range bases.Bases {
fmt.Println(base.ID, base.Name, base.PermissionLevel)
schema, _ := client.GetBaseSchema(base.ID).Do()
for _, table := range schema.Tables {
fmt.Println(" table", table.ID, table.Name)
fmt.Println(" fields")
for _, f := range table.Fields {
fmt.Println(" ", f.ID, f.Name, f.Type, f.Description, f.ID == table.PrimaryFieldID)
}
fmt.Println(" views")
for _, v := range table.Views {
fmt.Println(" ", v.ID, v.Name, v.Type)
}
fmt.Println(" records")
data := client.GetTable(base.ID, table.ID)
records, _ := data.GetRecords().MaxRecords(10000).Do()
for _, r := range records.Records {
fmt.Println(" ", r.ID)
for k, v := range r.Fields {
fmt.Println(" ", k, "=>", v)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment