Skip to main content

API

The crul API allows for programatic interaction with the crul query processor, among other auxiliary supporting systems. Access is provided through an API key that can be generated within the crul UI.

API Keys​

API Keys can be generated from the "API Keys" page in the crul UI.

API Keys Page

From the "API Keys" page click create.

API Keys Page

Provide a name for this key and copy the key value. Then click create.

API Keys Form

Service Endpoints​

API Service endpoints are fully documented and interactive using the API references listed per service in the services documentation.

API Request Examples​

Below are a few examples of API requests demonstrating how to use the API key to make requests to different crul services. More examples and interaction is available per service in the services documentation.

Query Dispatch (waits for completion)​

curl -X 'POST' \
'http://localhost:1968/v1/sirp/query/runner/dispatch' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: crul {token}" \
-d '{
"query": "devices"
}'

Queries with Filter Expressions​

Filter expressions can be tricky to handle due to escaping of quotes. Two options are described below, one demonstrating escaping the -d flag value, and another that relies on a data payload described in a file.

Escaping approach:

curl -X 'POST' 'http://localhost:1968/v1/sirp/query/runner/dispatch' -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"query\": \"open https://news.ycombinator.com/ || filter 'nodeName == \\\"A\\\"'\" }"

File approach:

curl -X 'POST' 'http://localhost:1968/v1/sirp/query/runner/dispatch' -H 'accept: application/json' -H 'Content-Type: application/json' -d @q.json

Configure a file (ex: q.json) containing:

{ "query": "open https://news.ycombinator.com/ || filter \"nodeName == 'A'\"" }

List Domain Policies​

curl -X 'GET' \
'http://localhost:1968/v1/gonogo/policies' \
-H "Authorization: crul {token}"