Run a SQL SELECT across the datasets
curl --request POST \
--url https://api.dataville.com/api/v1/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sql": "SELECT title, author FROM gutenberg LIMIT 10",
"datasetIds": [
"<string>"
]
}
'import requests
url = "https://api.dataville.com/api/v1/query"
payload = {
"sql": "SELECT title, author FROM gutenberg LIMIT 10",
"datasetIds": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({sql: 'SELECT title, author FROM gutenberg LIMIT 10', datasetIds: ['<string>']})
};
fetch('https://api.dataville.com/api/v1/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dataville.com/api/v1/query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sql' => 'SELECT title, author FROM gutenberg LIMIT 10',
'datasetIds' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.dataville.com/api/v1/query"
payload := strings.NewReader("{\n \"sql\": \"SELECT title, author FROM gutenberg LIMIT 10\",\n \"datasetIds\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dataville.com/api/v1/query")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sql\": \"SELECT title, author FROM gutenberg LIMIT 10\",\n \"datasetIds\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dataville.com/api/v1/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sql\": \"SELECT title, author FROM gutenberg LIMIT 10\",\n \"datasetIds\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"row_count": 10,
"rows": [
{}
],
"sql_executed": "<string>",
"available_tables": [
"<string>"
],
"usage": {
"rows_charged": 123,
"request_cost": 123,
"credits_remaining": 123
}
}{
"status": "error",
"message": "Only SELECT statements are allowed."
}{
"status": "error",
"message": "Authentication required. Include your API key in the Authorization header."
}{
"status": "error",
"account_state": "authenticated",
"error": "insufficient_credit",
"data": {
"error": "<string>",
"code": "INSUFFICIENT_CREDIT"
},
"credits": {
"remaining_usd": 123,
"request_cost_usd": 123
}
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "Export rate limit exceeded. Maximum 1,000 exports per day per account."
}Export and SQL
Run a SQL SELECT across the datasets
Execute a read-only SQL query over the datasets in DuckDB. Only SELECT
statements are accepted; anything else is rejected by the validator.
- Table names are the source names (
gutenberg,arxiv,edgar, …). - Connected Google Sheets can be joined in by passing their ids in
datasetIdsand referencing them by their alias (never the internal view name). - Queries are capped at 10,000 characters, 1,000 rows and 30 seconds.
- Charged per row returned.
curl -X POST https://api.dataville.com/api/v1/query \
-H "Authorization: Bearer $DATAVILLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"sql":"SELECT title, author FROM gutenberg LIMIT 10"}'
POST
/
api
/
v1
/
query
Run a SQL SELECT across the datasets
curl --request POST \
--url https://api.dataville.com/api/v1/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sql": "SELECT title, author FROM gutenberg LIMIT 10",
"datasetIds": [
"<string>"
]
}
'import requests
url = "https://api.dataville.com/api/v1/query"
payload = {
"sql": "SELECT title, author FROM gutenberg LIMIT 10",
"datasetIds": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({sql: 'SELECT title, author FROM gutenberg LIMIT 10', datasetIds: ['<string>']})
};
fetch('https://api.dataville.com/api/v1/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dataville.com/api/v1/query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sql' => 'SELECT title, author FROM gutenberg LIMIT 10',
'datasetIds' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.dataville.com/api/v1/query"
payload := strings.NewReader("{\n \"sql\": \"SELECT title, author FROM gutenberg LIMIT 10\",\n \"datasetIds\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dataville.com/api/v1/query")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sql\": \"SELECT title, author FROM gutenberg LIMIT 10\",\n \"datasetIds\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dataville.com/api/v1/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sql\": \"SELECT title, author FROM gutenberg LIMIT 10\",\n \"datasetIds\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"row_count": 10,
"rows": [
{}
],
"sql_executed": "<string>",
"available_tables": [
"<string>"
],
"usage": {
"rows_charged": 123,
"request_cost": 123,
"credits_remaining": 123
}
}{
"status": "error",
"message": "Only SELECT statements are allowed."
}{
"status": "error",
"message": "Authentication required. Include your API key in the Authorization header."
}{
"status": "error",
"account_state": "authenticated",
"error": "insufficient_credit",
"data": {
"error": "<string>",
"code": "INSUFFICIENT_CREDIT"
},
"credits": {
"remaining_usd": 123,
"request_cost_usd": 123
}
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "Export rate limit exceeded. Maximum 1,000 exports per day per account."
}Authorizations
A Dataville API key, sent as Authorization: Bearer dataville_.... Clients
that cannot set headers may pass the same key as ?token=.
Body
application/json
Was this page helpful?