> For the complete documentation index, see [llms.txt](https://docs.spice.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.spice.ai/api/runtime-apis/sql-query/http-api.md).

# HTTP API

Data may be queried by posting SQL to the `/v1/sql` API and `/v1/firesql` API for Firecached data. For documentation on the Spice Firecache see [Broken mention](broken://pages/q4t8COjPZrT3eUwQXMBw).

See [Tables](broken://pages/raer32Dk4PPuKbzd1GLs) for a list of tables to query or browse the example queries listed in the menu.

#### Requirements and limitations

* An API key is required for all SQL queries.
* Results are limited to 500 rows. Use the [Apache Arrow Flight API](/api/runtime-apis/sql-query/apache-arrow-flight-api.md) to fetch up to 1M rows in a single query or the [Async HTTP API](broken://pages/INalDm4gLljuBB16j2bY) to fetch results with paging.
* Requests are limited to 90 seconds.

## SQL Query

> Execute a SQL query and return the results.\n\nThis endpoint allows users to execute SQL queries directly from an HTTP request. The SQL query is sent as plain text in the request body.

```json
{"openapi":"3.1.0","info":{"title":"Spice.ai Data-Platform","version":"1.0.0"},"tags":[],"servers":[{"description":"AWS Stamp, US East 1 region","url":"https://us-east-1-prod-aws-data.spiceai.io"},{"description":"AWS Stamp, US West 2 region","url":"https://us-west-2-prod-aws-data.spiceai.io"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"in":"header","name":"X-API-KEY","type":"apiKey"}}},"paths":{"/v1/sql":{"post":{"description":"Execute a SQL query and return the results.\\n\\nThis endpoint allows users to execute SQL queries directly from an HTTP request. The SQL query is sent as plain text in the request body.","parameters":[{"description":"The format of the response, one of 'application/json' (default), 'application/vnd.spiceai.sql.v1+json', 'text/csv' or 'text/plain'.","in":"header","name":"Accept","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object"}},"text/plain":{"schema":{"type":"object"}}},"description":"SQL query to execute as JSON","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"oneOf":[{"type":"object"},{"type":"string"},{"type":"string"},{"type":"object"}]}},"application/vnd.spiceai.sql.v1+json":{"schema":{"type":"string"}},"text/csv":{"schema":{"type":"string"}},"text/plain":{"schema":{"type":"string"}}},"description":"SpiceAI SQL v1+json result"},"400":{"content":{"application/json":{"schema":{"type":"string"}}},"description":"Bad Request"},"500":{"content":{"application/json":{"schema":{"type":"string"}}},"description":"Internal Server Error"}},"summary":"SQL Query","tags":["SQL"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.spice.ai/api/runtime-apis/sql-query/http-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
