🆕
Go SDK
Golang SDK for Spice.xyz
It uses Apache Apache Flight to efficiently stream data to the client and Apache Arrow Records as data frames.
Get the gospice package.
go get github.com/spiceai/gospice
spice := gospice.NewSpiceClient()
defer spice.Close()
2. Initialize the SpiceClient.
if err := spice.Init("API Key"); err != nil {
panic(fmt.Errorf("error initializing SpiceClient: %w", err))
}
3. Execute a query and get back an Apache Arrow Reader.
reader, err := spice.Query(context.Background(), "SELECT * FROM eth.recent_blocks ORDER BY number LIMIT 10")
if err != nil {
panic(fmt.Errorf("error querying: %w", err))
}
defer reader.Release()
4. Iterate through the reader to access the records.
for reader.Next() {
record := reader.Record()
defer record.Release()
fmt.Println(record)
}
Run
go run .
to execute a sample query and print the results to the console.Last modified 2mo ago