Query using the REST API
To query Pinot via a broker endpoint, complete the following steps:
Serverless Trial Users
- Generate a Pinot API token.
- In StarTree Cloud (opens in a new tab), click Go to Data Manager.
- Copy the name of the workspace from top-left corner of the screen.
- Click a dataset to test, and then highlight and copy the Broker URL.
- Access the Pinot REST API by invoking
POST
operation with a JSON body containing the parametersql
to the/query/sql
endpoint on a broker, including the broker URL.
Example when you are running the following curl for StarTree Serverless Trial:
$ curl --location --request POST 'https://broker.pinot.<your url>.startree.cloud:443/query/sql'
--header 'Authorization: Bearer <API Token>' \
--header 'Content-Type: application/json' \
--header 'database: <your workspace id>' \
--data-raw '{"sql":"select foo, count(*) from MyData group by foo order by foo desc limit 100"}'
StarTree Customers
- Generate a Pinot API token.
- In StarTree Cloud (opens in a new tab), click Go to Data Manager.
- Click a dataset to test, and then highlight and copy the Broker URL.
- Access the Pinot REST API by invoking
POST
operation with a JSON body containing the parametersql
to the/query/sql
endpoint on a broker, including the broker URL.
Example when you are running the following curl for StarTree Cloud:
$ curl --location --request POST 'https://broker.pinot.<your url>.startree.cloud/query/sql'
--header 'Authorization: Bearer <API Token>' \
--header 'Content-Type: application/json' \
--data-raw '{"sql":"select foo, count(*) from MyData group by foo order by foo desc limit 100"}'
The following example assumes broker is running on localhost:8099
and StarTree Cloud.
Example when you are running the following curl for localhost:
$ curl -H "Content-Type: application/json" -X POST \
-d '{"sql":"select foo, count(*) from myTable group by foo limit 100"}' \
http://localhost:8099/query/sql or https://broker.pinot.<your url>.startree.cloud:443/query/sql