GQL Resource
This resource executes a GS SQL statement and returns the results.
It is not api_key compatible because GS SQL execution requires running under a user so that results are filtered by content store permissions.
GET gql
| Executes
a GS SQL statement and returns the
results. |
Resource Information | |
| Rate Limited? | Yes | |
| session, oauth and org tokens compatible? | Yes | |
| api_key compatible? | No | |
Resource URL
http://grovestreams.com/api/gql
Parameters
| s | required |
The URL encoded GS SQL statement. |
| tz | optional |
The time
zone id to use if the SQL returns dynamic rolllup samples or if
any date functions do not include a time zone id. |
| h | optional |
true/false. Defaults to false. Indicates if the result contains the header. Only applies to compact (c=true) queries. |
| c | optional |
true/false. Defaults to false. Indicates if the result is returned in a JSON compact format. |
Example Requests
Request
Execute the following GS SQL statement. Return column headers. Return compact format. Notice that the GS SQL is encoded:
Select _component_name, _name, _folder_path from system.stream Where StartsWith(_folder_path, '/Components')
gql?org=00000000-0000-0000-0000-000000000001&c=true&h=true&tz=US%2FCentral&s=select%20_component_name%2C%20_name%2C%20_folder_path%20from%20system.stream%20where%20StartsWith(_folder_path%2C%20%27%2FComponents%27)
Response Body
{
"success": true,
"message": "",
"cols": [
{
"valueType": "STRING",
"name": "_component_name"
},
{
"valueType": "STRING",
"name": "_name"
},
{
"valueType": "STRING",
"name": "_folder_path"
}
],
"rows": [
[
"Refrigerator Smart Plug Sensor",
"Ongoing Monthly Cost (Euros)",
"/Components"
],
[
"Refrigerator Smart Plug Sensor",
"cost - dollars",
"/Components"
],
[
"Refrigerator Smart Plug Sensor",
"current - rolling 3pt avg",
"/Components"
],
[
"Refrigerator Smart Plug Sensor",
"current",
"/Components"
],
[
"Garage Temperature and Light Sensor",
"light",
"/Components"
],
[
"Garage Temperature and Light Sensor",
"low_battery",
"/Components"
]
]
}
Request
Execute the following GS SQL statement. Return not in the compact format. Notice that the GS SQL is encoded:
select _component_name, _name, _folder_path from system.stream where StartsWith(_folder_path, '/Components') order by _component_name limit 3
gql?org=00000000-0000-0000-0000-000000000001&c=false&h=true&tz=US%2FCentral&s=select%20 _component_name%2C%20_name%2C%20_folder_path%20from%20system.stream%20where%20StartsWith(_folder_path%2C%20%27%2FComponents%27)%20order%20by%20_component_name%20limit%203&_dc=1648578504815
Response Body
{
"success": true,
"message": "",
"rows": [
{
"_folder_path": "/Components",
"_component_name": "Currency Exchange Rates",
"_name": "EUR/USD Conversion Rate"
},
{
"_folder_path": "/Components",
"_component_name": "Garage Temperature and Light Sensor",
"_name": "light"
},
{
"_folder_path": "/Components",
"_component_name": "Garage Temperature and Light Sensor",
"_name": "low_battery"
}
]
}
POST gql
| Executes
a GS SQL statement passed in the request body and returns the
results. Use this method for large statements that may exceed URL length limits. |
Resource Information | |
| Rate Limited? | Yes | |
| session, oauth and org tokens compatible? | Yes | |
| api_key compatible? | No | |
Resource URL
http://grovestreams.com/api/gql
Query String Parameters
| tz | optional |
The time
zone id to use if the SQL returns dynamic rolllup samples or if
any date functions do not include a time zone id. |
| h | optional |
true/false. Defaults to false. Indicates if the result contains the header. Only applies to compact (c=true) queries. |
| c | optional |
true/false. Defaults to false. Indicates if the result is returned in a JSON compact format. |
Request Body
The GS SQL statement as plain text. The statement does not need to be URL encoded.Example Requests
curl Example
Execute a GS SQL statement via POST. The statement is passed as the request body:
curl -X POST "https://grovestreams.com/api/gql?org=00000000-0000-0000-0000-000000000001&c=true&h=true&tz=US/Central" \
-H "Cookie: JSESSIONID=your_session_id" \
-d "select _component_name, _name, _folder_path from system.stream where StartsWith(_folder_path, '/Components')"
Response Body
The response format is identical to the GET method.
