|Facts collected from tagged text on this page|
|Facts about this page|
We changed domains: please change any mentions of silkapp.com in the code examples to silk.co.
Silk lets you query tags in a site. Querying is a very powerful feature that lets you select, search and filter information. Queries are the basis of all visualisations within Silk.
To perform a query (for example, list all countries in the Caribbean), do this
We will update a complete reference to our query language shortly, in the meanwhile here is a primer. We also have a guide if you exactly want to know how to perform certain queries.
The query language that Silk uses has has a syntax that is explained below, lets look at this query (continued from the example above):
Lets go through this query step by step. The query always begins with
To apply filter parameters, use the where clause (always use the complete url of the tag to refer to that tag)
this line filters out results without a region tag
the 'document has type ...' indicates to only select pages that have a specific category. You can select multiple categories.
this selects only the results that have 'Caribbean' as the value for the tag Region. It is also possible to add a contains (instead of is) operator to find results as 'Dutch Caribbean':
for numeric values, it is possible to do greater than and less than to filter results:
This filters the results to have GDP growth between 1 and 2.
For linked tags (e.g. a head of state on a country page is linked to its own page which has category 'Head of state') you can use this syntax to filter, this example only shows countries for which the head of state is a king:
The second part of the query selects the tags to be included in the response
This indicates to include the document name in the response
This indicates that the tag Region should be included in the response. You can add multiple lines to include more tags.
The third part of the query is optional, namely sorting. Sorting can be done on only one tag or document name:
The final part of the query, also optional, is slicing the results
the above line makes sure only the outputs 0 to 99 are included in the output. Slicing lets you limit the number of results and makes pagination possible.
The response of the API call is an HTML table with the results, for example, the results of all countries in the Caribbean
The table not only includes the results, but also the type of results and geo-locations for example. Additionaly, in the <table> tag in the example above, it shows that the slice requested was from 0 - 99 and that there are 14 results.
Just like in the structure of pages, the output includes -data attributes that specify the type of data (numeric, geo, currency, textual).