Skip to main content

Introduction

JSONsilo supports searching data within silos. This feature allows you to search and interact with silo data programmatically. By adding specific search query parameters to your silo URL, you can search for precise information within 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 search feature is powerful, it currently has some limitations:
  • Only private silos are supported; public silos are not yet available.
  • Search works on silos whose data is a JSON array at the top level.
  • output parameter is not supported in search functionality.
  • When you send several conditions, all of them must match. There is no “or”.
  • Sorting and pagination are not supported.

Usage

To search data from your private silo, you need to add specific query parameters to your silo URL. These parameters allow you to retrieve data dynamically based on your requirements.
  • q: The path in the silo data to search.
  • value: The value to search for at the specified path.
  • op: The search operator to use (see the list of supported operators below).
Notes:
  • The order of the parameters in the URL doesn’t matter.
  • q and value are required for the search to work.
  • Default operator is eq (equal to) if op is not specified.
  • Default response format is Array of Objects.
Send your Access Key in the X-SILO-KEY header, as with any private silo request.

Supported Operators

The following search operators are available:
Notes:
  • gt and lt compare values as numbers.
  • eq and ne compare as numbers when value is a number, and as text otherwise.
  • lk and il currently behave the same way: both ignore letter case.

How It Works

The search functionality works by evaluating each object in a JSON array against the specified query parameters. The q parameter defines the path to the field you want to search, the value parameter specifies the value to look for, and the op parameter indicates the comparison operator to use. Suppose you have a private silo containing an array of objects like this:
data.json
Find objects where age is greater than 25
  • Use ?q=age to specify the field to search.
  • Use &value=25 to set the value to compare against.
  • Use &op=gt to set the operator to “greater than”.
Example Request:
Response:

Example 2: Nested Field

Use a dot (.) in q to reach a field inside a nested object. Suppose your silo data looks like this:
data.json
Find objects where profile.age is less than 30.
  • Use ?q=profile.age to specify the field to search.
  • Use &value=30 to set the value to compare against.
  • Use &op=lt to set the operator to “less than”.
Example Request:
Response:

Example 3: Multiple Conditions

To search on more than one field, repeat q, value, and op once per condition. An object is returned only when it matches all of the conditions. Suppose your silo data looks like this:
data.json
Find objects where age is greater than 25 and role is equal to admin.
Example Request:
Response:
Notes:
  • The first q goes with the first value and the first op, the second with the second, and so on.
  • Send the same number of q, value, and op parameters. Otherwise the API returns 400.
  • Only one object matches here, so it is returned on its own. See Response Format.

Example 4: Pattern Match

The lk and il operators match a pattern. Use % as a wildcard for any number of characters. Using the data from Example 1, find objects whose name starts with ch:
Example Request:
Response:
In a URL, write % as %25. For example, send ch% as value=ch%25.

Example 5: Field Inside a Nested Array

Use a double dot (..) in q when the field you want to match is inside an array on each object. The object matches when any item in that array matches. Suppose your silo data looks like this:
data.json
Find objects that have a tag whose label is equal to red:
Example Request:
Response:
Note: An object is returned once for each item in the array that matches. If two of an object’s tags were red, that object would appear twice in the response.

Combining parameter with path

You can combine the search parameters with the path parameter to extract specific fields from the matched objects.

How It Works

When combining the path parameter with search parameters, the search is performed first to filter the objects based on the criteria defined by q, value, and op. After filtering, the path parameter is applied to extract the specified field from each of the matched objects. Suppose your silo data looks like this:
data.json
If you want to find the name of users whose profile.age is greater than 25, you would construct your request as follows:
  • Use ?q=profile.age to specify the field to search.
  • Use &value=25 to set the value to compare against.
  • Use &op=gt to set the operator to “greater than”.
  • Use &path=profile.name to extract the name field from the matched objects.
Example Request:
Response:
Notes:
  • The path parameter can extract nested fields as well.
  • When using the path parameter, ensure that the specified path exists in the matched objects to avoid null values in the response.

Response Format

The shape of the response depends on how many objects match. If your code expects a list, check whether the response is an array before you loop over it.

Caching

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

Rate Limits

Searches count as private silo reads. See Rate Limits.