JQL
Custom JQL Query
POST
/
jql
Custom JQL Query
curl --request POST \
--url https://{regionAndDomain}.com/api/query/jql \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data 'script=function main(){
return Events(params)
.groupBy(
["name"],
mixpanel.reducer.count()
)
}
' \
--data 'params={
"from_date": 2016-01-01T00:00:00.000Z,
"to_date": 2016-01-07T00:00:00.000Z
}
'import requests
url = "https://{regionAndDomain}.com/api/query/jql"
payload = {
"script": "function main(){
return Events(params)
.groupBy(
[\"name\"],
mixpanel.reducer.count()
)
}
",
"params": "{
\"from_date\": 2016-01-01T00:00:00.000Z,
\"to_date\": 2016-01-07T00:00:00.000Z
}
"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
script: 'function main(){\n return Events(params)\n .groupBy(\n ["name"],\n mixpanel.reducer.count()\n )\n}\n',
params: '{\n "from_date": 2016-01-01T00:00:00.000Z,\n "to_date": 2016-01-07T00:00:00.000Z\n}\n'
})
};
fetch('https://{regionAndDomain}.com/api/query/jql', 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://{regionAndDomain}.com/api/query/jql",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "script=function%20main%28%29%7B%0A%20%20return%20Events%28params%29%0A%20%20%20%20.groupBy%28%0A%20%20%20%20%20%20%5B%22name%22%5D%2C%0A%20%20%20%20%20%20mixpanel.reducer.count%28%29%0A%20%20%20%20%29%0A%7D%0A¶ms=%7B%0A%20%20%22from_date%22%3A%202016-01-01T00%3A00%3A00.000Z%2C%0A%20%20%22to_date%22%3A%202016-01-07T00%3A00%3A00.000Z%0A%7D%0A",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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://{regionAndDomain}.com/api/query/jql"
payload := strings.NewReader("script=function%20main%28%29%7B%0A%20%20return%20Events%28params%29%0A%20%20%20%20.groupBy%28%0A%20%20%20%20%20%20%5B%22name%22%5D%2C%0A%20%20%20%20%20%20mixpanel.reducer.count%28%29%0A%20%20%20%20%29%0A%7D%0A¶ms=%7B%0A%20%20%22from_date%22%3A%202016-01-01T00%3A00%3A00.000Z%2C%0A%20%20%22to_date%22%3A%202016-01-07T00%3A00%3A00.000Z%0A%7D%0A")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{regionAndDomain}.com/api/query/jql")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("script=function%20main%28%29%7B%0A%20%20return%20Events%28params%29%0A%20%20%20%20.groupBy%28%0A%20%20%20%20%20%20%5B%22name%22%5D%2C%0A%20%20%20%20%20%20mixpanel.reducer.count%28%29%0A%20%20%20%20%29%0A%7D%0A¶ms=%7B%0A%20%20%22from_date%22%3A%202016-01-01T00%3A00%3A00.000Z%2C%0A%20%20%22to_date%22%3A%202016-01-07T00%3A00%3A00.000Z%0A%7D%0A")
.asString();require 'uri'
require 'net/http'
url = URI("https://{regionAndDomain}.com/api/query/jql")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "script=function%20main%28%29%7B%0A%20%20return%20Events%28params%29%0A%20%20%20%20.groupBy%28%0A%20%20%20%20%20%20%5B%22name%22%5D%2C%0A%20%20%20%20%20%20mixpanel.reducer.count%28%29%0A%20%20%20%20%29%0A%7D%0A¶ms=%7B%0A%20%20%22from_date%22%3A%202016-01-01T00%3A00%3A00.000Z%2C%0A%20%20%22to_date%22%3A%202016-01-07T00%3A00%3A00.000Z%0A%7D%0A"
response = http.request(request)
puts response.read_body[
{}
]JQL is currently in maintenance mode. We recommend discontinuing use of JQL and using an alternate method to get the data you need. Below are alternatives for common use cases and you need help deciding the best method for you, reach out to support.
- Raw Event export: Export API or Data Pipelines
- User Profile export: Engage Query API or Data Pipelines
- Other reporting: Query API or in-app Core Reports
curl https://mixpanel.com/api/query/jql \
-u YOUR_API_SECRET: \
--data-urlencode script@my_query.js
curl --request POST \
--url https://mixpanel.com/api/query/jql \
--header 'accept: application/json' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'script=function main(){
return Events(params)
.groupBy(
["name"],
mixpanel.reducer.count()
)
}
' \
--data 'params={
"scriptParam": "paramValue"
}
'
- The Query API has a rate limit of 60 queries per hour and a maximum of 5 concurrent queries.
- Queries will timeout after 2 minutes of run-time.
- You cannot make remote network requests (using XMLHttpRequest) from JavaScript.
- Queries to the JQL endpoint contribute to Query API rate limit and have their own individual limit as well. There is a maximum of 5 concurrent queries and of 60 queries per hour. There is also a 5 GB limit on data that can be processed in a single query, and a 2 GB limit on the resulting output data.
Authorizations
ServiceAccountProjectSecret
Service Account
Query Parameters
Required if using service account to authenticate request.
The id of the workspace if applicable.
Body
application/x-www-form-urlencoded
Response
200 - application/json
Success
Was this page helpful?
Custom JQL Query
curl --request POST \
--url https://{regionAndDomain}.com/api/query/jql \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data 'script=function main(){
return Events(params)
.groupBy(
["name"],
mixpanel.reducer.count()
)
}
' \
--data 'params={
"from_date": 2016-01-01T00:00:00.000Z,
"to_date": 2016-01-07T00:00:00.000Z
}
'import requests
url = "https://{regionAndDomain}.com/api/query/jql"
payload = {
"script": "function main(){
return Events(params)
.groupBy(
[\"name\"],
mixpanel.reducer.count()
)
}
",
"params": "{
\"from_date\": 2016-01-01T00:00:00.000Z,
\"to_date\": 2016-01-07T00:00:00.000Z
}
"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
script: 'function main(){\n return Events(params)\n .groupBy(\n ["name"],\n mixpanel.reducer.count()\n )\n}\n',
params: '{\n "from_date": 2016-01-01T00:00:00.000Z,\n "to_date": 2016-01-07T00:00:00.000Z\n}\n'
})
};
fetch('https://{regionAndDomain}.com/api/query/jql', 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://{regionAndDomain}.com/api/query/jql",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "script=function%20main%28%29%7B%0A%20%20return%20Events%28params%29%0A%20%20%20%20.groupBy%28%0A%20%20%20%20%20%20%5B%22name%22%5D%2C%0A%20%20%20%20%20%20mixpanel.reducer.count%28%29%0A%20%20%20%20%29%0A%7D%0A¶ms=%7B%0A%20%20%22from_date%22%3A%202016-01-01T00%3A00%3A00.000Z%2C%0A%20%20%22to_date%22%3A%202016-01-07T00%3A00%3A00.000Z%0A%7D%0A",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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://{regionAndDomain}.com/api/query/jql"
payload := strings.NewReader("script=function%20main%28%29%7B%0A%20%20return%20Events%28params%29%0A%20%20%20%20.groupBy%28%0A%20%20%20%20%20%20%5B%22name%22%5D%2C%0A%20%20%20%20%20%20mixpanel.reducer.count%28%29%0A%20%20%20%20%29%0A%7D%0A¶ms=%7B%0A%20%20%22from_date%22%3A%202016-01-01T00%3A00%3A00.000Z%2C%0A%20%20%22to_date%22%3A%202016-01-07T00%3A00%3A00.000Z%0A%7D%0A")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{regionAndDomain}.com/api/query/jql")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("script=function%20main%28%29%7B%0A%20%20return%20Events%28params%29%0A%20%20%20%20.groupBy%28%0A%20%20%20%20%20%20%5B%22name%22%5D%2C%0A%20%20%20%20%20%20mixpanel.reducer.count%28%29%0A%20%20%20%20%29%0A%7D%0A¶ms=%7B%0A%20%20%22from_date%22%3A%202016-01-01T00%3A00%3A00.000Z%2C%0A%20%20%22to_date%22%3A%202016-01-07T00%3A00%3A00.000Z%0A%7D%0A")
.asString();require 'uri'
require 'net/http'
url = URI("https://{regionAndDomain}.com/api/query/jql")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "script=function%20main%28%29%7B%0A%20%20return%20Events%28params%29%0A%20%20%20%20.groupBy%28%0A%20%20%20%20%20%20%5B%22name%22%5D%2C%0A%20%20%20%20%20%20mixpanel.reducer.count%28%29%0A%20%20%20%20%29%0A%7D%0A¶ms=%7B%0A%20%20%22from_date%22%3A%202016-01-01T00%3A00%3A00.000Z%2C%0A%20%20%22to_date%22%3A%202016-01-07T00%3A00%3A00.000Z%0A%7D%0A"
response = http.request(request)
puts response.read_body[
{}
]