githubEdit

codeAPIs & SDKs

Spice.ai APIs, SDKs, endpoints, and query best practices.

API Endpoints

Spice.ai exposes two sets of APIs: runtime APIs (for querying data and AI) and the Management API (for managing apps and infrastructure).

Runtime APIs

API
Endpoint
Auth
Documentation

SQL (HTTP)

https://data.spiceai.io/v1/sql

X-API-Key header

SQL (Arrow Flight)

grpc+tls://flight.spiceai.io

Password in handshake

LLM Chat

https://data.spiceai.io/v1/chat/completions

X-API-Key header

Search

https://data.spiceai.io/v1/search

X-API-Key header

Health

https://data.spiceai.io/health

None

Management API

The Management API at https://api.spice.ai/v1/ uses personal access tokens or OAuth tokens (not app API keys).

See the full Management API referencearrow-up-right.

SDKs

Official SDKs handle authentication, serialization, and connection management for you.

Language
Package
Documentation

Quick example (Python)

Choosing HTTP vs. Arrow Flight

HTTP API
Arrow Flight API

Format

JSON

Apache Arrow (binary)

Best for

Simple queries, small results

Large datasets, production workloads

Row limits

Yes

No

Streaming

No

Yes

Performance

Good

Best

SDK support

All SDKs

All SDKs

Recommendation: Use Arrow Flight (via SDKs) for production workloads and large result sets. Use the HTTP API for quick testing, small queries, or REST-based integrations.

Query Best Practices

Use LIMIT and OFFSET for large results

Increment OFFSET to page through results. Always include ORDER BY for deterministic pagination.

Use recent tables for near-real-time data

Recent tables provide fast access to the last ~30 minutes of data, ideal for dashboards and monitoring.

Combine SQL with client-side processing

Use SQL for filtering, aggregation, and joins, then use client libraries (pandas, NumPy, etc.) for further processing:

Use data acceleration for repeated queries

Enable data accelerationarrow-up-right on frequently queried datasets to avoid hitting the source on every request.

Common Issues

Arrow Flight TLS errors

Set the GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable:

HTTP API returns truncated results

The HTTP API has built-in row and timeout limits. Switch to Arrow Flight or an SDK for unlimited streaming results.

Management API returns 401

The Management API uses personal access tokens, not app API keys. Generate a token under Profile → Personal Access Tokensarrow-up-right.

Further Reading

Last updated

Was this helpful?