Simple Airtable client written in go
go get github.com/mottaquikarim/go-airtable
Let's make a simple request to the pokédex. You can copy this base by clicking the top right "Copy" button and test against this data yourself 👍.
import (
"github.com/mottaquikarim/go-airtable"
)
acc := airtable.Account{
ApiKey: "XXXX",
BaseId: "XXXX",
}
pokédex := airtable.NewTable("pokémon", acc)
original_generation, err := pokédex.List(airtable.Options{
// Airtable has an API limit of 100 records per page
MaxRecords: 100,
// override the default "Grid view" name
View: "All",
})
if err != nil {
// handle error
log.Printf("Error! %v", err)
}
// returned is []Record struct, which contains a Field prop
// that is map[string]interface{} - this can be used anyway
// you like
for _, pokémon := range original_generation {
log.Printf("ID: %s Name: %s", pokémon.Fields["ID"], pokémon.Fields["Name"])
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
make test-dev
make fmt
make lint
make build
Then,
make run arguments="-help"
Output:
Usage: ./airtbl [flags]
-api-key="XXXXX": Airtable API Key
-base-id="XXXXX": Airtable Base Id