APIs & 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 projects and infrastructure).
Runtime APIs
Management API
The Management API at https://api.spice.ai/v1/ uses personal access tokens or OAuth tokens (not project API keys).
Projects, deployments, API keys, secrets, and organization members are all managed through it. Every operation is listed in the Management API reference, which renders the published OpenAPI specification.
SDKs
Official SDKs handle authentication, serialization, and connection management for you.
Quick example (Python)
Choosing HTTP vs. Arrow Flight
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 acceleration 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 project API keys. Generate a token under Profile → Personal Access Tokens.
Further Reading
Last updated
Was this helpful?