> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://ocient.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://ocient.ferndocs.com/_mcp/server.

# Execute SQL statement with database specified in path (GET method)

GET /v1/execute/{database}

Alternative GET method for executing SQL statements with the database
specified in the URL path. Parameters are passed as URL query parameters.
Does not support the params field.

This endpoint is functionally identical to GET `/execute` but with the database
specified in the URL path. This can be more convenient for clients that
organize requests by database.

### Example

```
GET /v1/execute/retail?statement=SELECT%20*%20FROM%20customers%20LIMIT%2010&format=collection
```


Reference: https://ocient.ferndocs.com/api-reference/query-execution/execute-get-database

## Authentication

- `Authorization` header (bearer token, required) — Access token obtained from the login endpoint
- `Authorization` header (basic auth, required) — HTTP Basic authentication with username and password

## Request

### Path parameters

- `database` (string, required)

### Query parameters

- `statement` (string, required) — SQL statement to execute. The statement must be URL-encoded.
- `format` (enum, optional, default: array) — Response format: * array - Returns schema and data as arrays (more efficient for large datasets) * collection - Returns data as JSON objects (more convenient for client processing)
  - Allowed values: `array`, `collection`
- `fetch_size` (integer, optional, default: 100) — Number of rows to return in each chunk for streaming responses.

### Headers

- `Accept-Encoding` (string, optional) — Supported compression algorithms for responses. Multiple algorithms can be specified as a comma-separated list. Common values include 'gzip', 'deflate', 'br' (Brotli), or combinations like 'gzip, br'. Note that for large result sets, compression may produce suboptimal results. Without compression the result sets can be chunks of rows and processed in a streaming fashion. With compression the entire result set must be compressed before it is returned to the client. Thus the entire result set will be decompressed on the client before any rows can be processed
- `Accept` (enum, optional, default: application/json) — Supported response media types. Note that regardless of the Accept header, large queries results will always be returned via chunked encoding. Also see the note about compression in the AcceptEncoding section.
  - Allowed values: `application/json`, `application/stream+json`, `application/parquet`
- `Preferred-Encoding` (enum, optional) — Indicates the preferred encoding type from those specified in Accept-Encoding. This header provides fine-grained control when Accept-Encoding contains multiple values, allowing the client to explicitly specify which encoding is preferred for this specific request.
  - Allowed values: `gzip`, `br`
- `Preferred-Compression-Level` (integer, optional) — Specifies the desired compression level for the selected encoding algorithm. Values typically range from 1 (fastest, least compression) to 9 (slowest, maximum compression). The exact behavior depends on the specific compression algorithm being used.

## Response

### 200

Query executed successfully

- `Query Execution_execute_get_database_Response_200`
  - ArrayExecuteResponse
  - CollectionExecuteResponse

## Errors

### 401 Unauthorized Error

Unauthorized

- `status` (Status, required)

### 404 Not Found Error

Object not found

- `status` (Status, required)

### 500 Internal Server Error

Server Error

- `status` (Status, required)

## Types

### ArrayExecuteResponse

- `query_id` (string, required, nullable) — Unique identifier for the query.
- `status` (Status, required)
- `schema` (list of ArrayExecuteResponseSchemaItems, required) — Array of column metadata objects describing the structure of the result set. Each object contains the column name and data type.
- `data` (list of list of any, required) — Two-dimensional array containing the query results. The outer array represents rows, and each inner array contains column values in the same order as defined in the schema.

### CollectionExecuteResponse

- `query_id` (string, required, nullable) — Unique identifier for the query.
- `status` (Status, required)
- `data` (list of map from string to any, required) — Array of objects representing the query results. Each object has properties corresponding to the column names from the query.

### Status

- `reason` (string, required) — Human-readable description of the operation result
- `sql_state` (string, required) — SQL state code (see Error Handling section for common codes)
- `vendor_code` (integer, required) — Vendor-specific error code

### ArrayExecuteResponseSchemaItems

- `name` (string, required) — Column name
- `type` (string, required) — Column data type. Common types include: - INTEGER, BIGINT, SMALLINT (whole numbers) - DOUBLE, REAL, DECIMAL (floating point numbers) - VARCHAR, CHAR, TEXT (text data) - DATE, TIMESTAMP, TIME (temporal data) - BOOLEAN (true/false values) - ARRAY, MAP, TUPLE (complex types)

## Examples

**Response**

```json
{
  "query_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": {
    "reason": "Query executed successfully",
    "sql_state": "00000",
    "vendor_code": 0
  },
  "data": [
    {
      "station_id": "KORD",
      "temperature": 12.5,
      "timestamp": "2023-01-01T12:00:00Z"
    },
    {
      "station_id": "KORD",
      "temperature": 15.3,
      "timestamp": "2023-01-01T13:00:00Z"
    },
    {
      "station_id": "KORD",
      "temperature": 10.2,
      "timestamp": "2023-01-01T14:00:00Z"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://v1/execute/database"

querystring = {"statement":"SELECT * FROM customers LIMIT 10","format":"collection","fetch_size":"1000"}

headers = {
    "Accept-Encoding": "gzip, deflate, br",
    "Authorization": "Bearer <token>"
}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://v1/execute/database?statement=SELECT+*+FROM+customers+LIMIT+10&format=collection&fetch_size=1000';
const options = {
  method: 'GET',
  headers: {'Accept-Encoding': 'gzip, deflate, br', Authorization: 'Bearer <token>'}
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://v1/execute/database?statement=SELECT+*+FROM+customers+LIMIT+10&format=collection&fetch_size=1000"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Accept-Encoding", "gzip, deflate, br")
	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://v1/execute/database?statement=SELECT+*+FROM+customers+LIMIT+10&format=collection&fetch_size=1000")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Accept-Encoding"] = 'gzip, deflate, br'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://v1/execute/database?statement=SELECT+*+FROM+customers+LIMIT+10&format=collection&fetch_size=1000")
  .header("Accept-Encoding", "gzip, deflate, br")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://v1/execute/database?statement=SELECT+*+FROM+customers+LIMIT+10&format=collection&fetch_size=1000', [
  'headers' => [
    'Accept-Encoding' => 'gzip, deflate, br',
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://v1/execute/database?statement=SELECT+*+FROM+customers+LIMIT+10&format=collection&fetch_size=1000");
var request = new RestRequest(Method.GET);
request.AddHeader("Accept-Encoding", "gzip, deflate, br");
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Accept-Encoding": "gzip, deflate, br",
  "Authorization": "Bearer <token>"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://v1/execute/database?statement=SELECT+*+FROM+customers+LIMIT+10&format=collection&fetch_size=1000")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```