Skip to main content

Introduction

JSONsilo supports querying data from silos. This feature lets you dynamically retrieve and interact with silo data programmatically. By appending specific query parameters to your silo URL, you can extract precise information from your JSON data without needing to download or manually parse the entire dataset.
This feature is currently supported only for Private Silos.

Limitations

While the query functionality is a powerful feature, it has some limitations:
  • Selecting a range of indices is not supported. idx selects one item.
  • Query performance may vary depending on the size and complexity of the silo data.
  • Only private silos are supported; public silos are not yet supported.

Usage

Below are the available query parameters you can use:
  • idx: Specifies the index of the item to retrieve.
  • path: Specifies the path to a specific field within the JSON data.
  • output: Specifies the desired output format or data type.
Add them to your private silo URL and send your Access Key in the X-SILO-KEY header, as with any private silo request.
Note: The order of the parameters in the URL doesn’t matter.

Parameters

idx

The idx parameter stands for “index” and is used to retrieve a specific item from an array in your silo data. It is helpful when your silo data is an array of objects, and you want to access an object based on its position in the array.

How It Works

Suppose your silo data looks like this:
data.json
You can use the idx parameter to specify which object you want to retrieve by its index (starting from 0). To get the first object in the array (John Doe), you would use:
Example Request:
Response:
Note:
  • idx must be a whole number, 0 or greater.
  • If you use idx on non-array data, or the index is out of range, the API returns 404.
  • You can combine the idx parameter with the path parameter for more advanced queries.

path

The path parameter lets you specify a path within the silo data to retrieve specific fields or nested data. This is useful for working with complex JSON structures that contain objects, arrays, or both.

How It Works

The path parameter uses dot notation to navigate through the JSON structure. Each segment separated by a dot (.) represents a key or index in the JSON object or array. Suppose your silo data looks like this:
data.json

Retrieving a Specific Field

To retrieve a specific field, you provide the path to that field using dot (.) notation. To retrieve the value of the filePath field, use the following URL:
Example Request:
Response:

Retrieving a Nested Object

If you want to retrieve an entire nested object, you can specify the path to that object. To retrieve the entire backup object, use:
Example Request:
Response:

Accessing Array Elements

If your data.json contains arrays, you can use numeric indices in the path. For example:
data.json
To retrieve the name of the first user:
Example Request:
Response:

Notes

  • The path parameter is case-sensitive and must match the exact structure of your data.
  • A path may contain letters, numbers, underscores (_), and dots (.) only. Any other character returns 400.
  • If the specified path does not exist, the API returns 404.
  • You can combine the path parameter with other parameters (such as idx and output) for more advanced queries.

output

This parameter only works together with path. It is ignored when you send it on its own or with idx alone.
The output parameter lets you choose the format or data type of the response. By default, the API returns data in json format, but you can use the output parameter to convert the result to a format that fits your needs.

How It Works

Suppose your silo data looks like this:
data.json
To retrieve the value of backup.maxBackups as its default type (string), you would use:
Example Request:
Response:
To convert the value of backup.maxBackups to an integer, you would use:
Example Request:
Response:

To retrieve the value of backup.retentionDays as its default type (number), you would use:
Example Request:
Response:
To convert the value of backup.retentionDays to a string, you would use:
Example Request:
Response:

Supported Output Types

Notes:
  • Booleans are converted as numbers. With text, int, or bool, the value true becomes 1 and false becomes 0. Leave output out to get true or false.
  • If the conversion is not possible (e.g., converting a non-numeric string to int), the result is 0.
  • An unsupported output type returns 400.
  • The output parameter can be combined with path and idx for advanced queries.
  • Ensure the data at the specified path is compatible with the requested output type.

Combining idx and path Parameters

You can combine the idx and path parameters to perform detailed queries on array-based JSON data. This is useful for selecting a specific item from an array and extracting a particular field from that item.

How It Works

Suppose your silo data looks like this:
data.json

Basic Example

Suppose you want to retrieve the name field from the object at index 1:
  • Use ?idx=1 to select the second object in the array.
  • Use &path=name to extract the name field from that object.
Example Request:
Response:

Advanced Example: Nested Fields

Suppose you want to retrieve a nested field, such as the email from the contacts object of the user at index 2.
  • Use ?idx=2 to select the third object in the array.
  • Use &path=contacts.email to extract the email field from that object.
Example Request:
Response:
Notes:
  • If the specified idx or path does not exist, the API returns 404.
  • The path parameter is case-sensitive and must match the exact structure of your data.
  • You can combine idx, path, and output for advanced queries, such as converting the result to a specific type.
    • Example: ?idx=2&path=age&output=text
    • Output: "50" (convert int to text)

Which Parameters Take Priority

A request runs as one kind of query. If you send parameters for more than one, the first match in this list wins:
  1. q runs a search. An optional path picks a field from each match.
  2. idx runs an index query. An optional path picks a field from that item.
  3. path on its own runs a path query.
  4. With none of them, the whole silo is returned.

Caching

Query results are cached for up to 5 minutes. A query made right after you update a silo may briefly return the previous data.

Rate Limits

Queries count as private silo reads. See Rate Limits.