Run a scoped analytics query
curl --request POST \
--url https://app.bily.ai/api/customer/v1/ad-metrics/{resourceUrl}/query \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"sql": "SELECT customer_id, total_revenue FROM _ ORDER BY total_revenue DESC LIMIT 10"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sql: 'SELECT customer_id, total_revenue FROM _ ORDER BY total_revenue DESC LIMIT 10'
})
};
fetch('https://app.bily.ai/api/customer/v1/ad-metrics/{resourceUrl}/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://app.bily.ai/api/customer/v1/ad-metrics/{resourceUrl}/query"
payload = { "sql": "SELECT customer_id, total_revenue FROM _ ORDER BY total_revenue DESC LIMIT 10" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"dataset": "customer_ltv",
"resourceUrl": "<string>",
"resourceType": "website",
"storeUrl": "<string>",
"maxRows": 123,
"inputLimit": 123,
"page": 123,
"adAccountScope": 1,
"meta": [
{
"name": "<string>",
"type": "<string>"
}
],
"data": [
{}
],
"rows": 123,
"statistics": {
"elapsed": 123,
"rows_read": 123,
"bytes_read": 123
}
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}Analytics SQL
Run a scoped analytics query
Runs one read-only SQL query over the scoped _ alias for customer_ltv or cohorts on a Shopify resource. Discover supported datasets through query/catalog first. Other datasets return 400; use their dedicated endpoints. Website requests for LTV or cohorts return 400 resource_type_mismatch. SQL is limited to 5000 characters, with no comments, statement chaining, joins or external data sources.
POST
/
ad-metrics
/
{resourceUrl}
/
query
Run a scoped analytics query
curl --request POST \
--url https://app.bily.ai/api/customer/v1/ad-metrics/{resourceUrl}/query \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"sql": "SELECT customer_id, total_revenue FROM _ ORDER BY total_revenue DESC LIMIT 10"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sql: 'SELECT customer_id, total_revenue FROM _ ORDER BY total_revenue DESC LIMIT 10'
})
};
fetch('https://app.bily.ai/api/customer/v1/ad-metrics/{resourceUrl}/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://app.bily.ai/api/customer/v1/ad-metrics/{resourceUrl}/query"
payload = { "sql": "SELECT customer_id, total_revenue FROM _ ORDER BY total_revenue DESC LIMIT 10" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"dataset": "customer_ltv",
"resourceUrl": "<string>",
"resourceType": "website",
"storeUrl": "<string>",
"maxRows": 123,
"inputLimit": 123,
"page": 123,
"adAccountScope": 1,
"meta": [
{
"name": "<string>",
"type": "<string>"
}
],
"data": [
{}
],
"rows": 123,
"statistics": {
"elapsed": 123,
"rows_read": 123,
"bytes_read": 123
}
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}{
"error": "Store not found",
"requestId": "<string>",
"details": "<unknown>",
"retryAfter": "<string>"
}Authorizations
ApiKeyAuthBearerAuth
Headers
Path Parameters
Body
application/json
Response
Request completed successfully.