SDA: Querying Data
- 🔍 You can check out the available queries for your org via
GET /queries
- see the List Queries endpoint page for details. - 🧰 Then, using the query id and any variables required you are ready to setup the payload for executing the query:
Example POST /queries/execute
Payload
{
"id": "dfcee886-231d-4a9d-9bdd-857f74XXXXX",
"variables": {
"service": "Netflix"
}
}
-
🏁 You can now use the
POST /queries
endpoint to retrieve the results - check out the Execute Queries endpoint page for details. You can find an example below:- 1️⃣ Node info acquisition details can be found on the Access page
- 2️⃣ Token acquisition details can be found on the Generatin API Tokens page
Code Samples
- Python
- TypeScript
nildb/secretvault_python/nildb_api.py
loading...
const queryCredentials = async (
nodeName: NodeName,
query: string,
service?: string
): Promise<Credential[]> => {
const node = config[nodeName];
try {
const response = await fetch(`${node.url}/queries/execute`, {
method: 'POST',
headers: {
Authorization: `Bearer ${node.jwt}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
id: query,
variables: {
service: service,
},
}),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const result = (await response.json()) as NodeResponse<Credential[]>;
return result.data || [];
} catch (error) {
console.error(`Error reading advanced credentials from ${nodeName}:`, error);
return [];
}
};