Golang SDK for Spice.ai
The Go SDK gospice
is the easiest way to query Spice.ai from Go.
It uses Apache Arrow Flight to efficiently stream data to the client and Apache Arrow Records as data frames.
GoDocs are available at: pkg.go.dev/github.com/spiceai/gospice.
Go 1.22 (or later)
Get the gospice package.
1. Import the package.
2. Create a SpiceClient
by providing your API key. Get your free API key at spice.ai.
3. Initialize the SpiceClient
.
4. Execute a query and get back an Apache Arrow Record Reader.
5. Iterate through the reader to access the records.
Follow the quickstart guide to install and run spice locally.
Or using custom flight address:
Check Spice OSS documentation to learn more.
Run go run .
to execute a sample query and print the results to the console.
The SpiceClient
implements connection retry mechanism (3 attempts by default). The number of attempts can be configured via SetMaxRetries
:
Retries are performed for connection and system internal errors. It is the SDK user's responsibility to properly handle other errors, for example RESOURCE_EXHAUSTED (HTTP 429)
.
Contribute to or file an issue with the gospice
library at: https://github.com/spiceai/gospice