Simple Example
Below is a collection of simpler queries.
All examples use the following context details.
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
}
Search by type and location with exact match
{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query": [
{
"@type": "schema:LocalBusiness",
"schema:address": {
"schema:addressLocality": "Jena"
}
}
]
}
Search by type and location with contains in, ignore case match
{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query": [
{
"@type": "schema:LocalBusiness",
"schema:address": {
"schema:addressLocality": {
"sq:value": "Jena",
"sq:op": "iContains"
}
}
}
]
}
Search for objects belonging to the POI DS with nearby
{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query": [
{
"ds:compliesWith": {
"sq:value": "https://semantify.it/ds/sloejGAwT",
"sq:datatype": "iri"
},
"schema:geo": {
"sq:nearby": {
"sq:latitude": "$LAT",
"sq:longitude": "$LONG",
"sq:distance": "$DIST"
}
}
}
]
}
Search by type and domain specification filter
Here is a search for objects belonging to the DZT POI domain specification, with an additional filter for a specific type.
{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query": [
{
"ds:compliesWith": {
"sq:value": "https://semantify.it/ds/sloejGAwT",
"sq:datatype": "iri"
},
"@type": "schema:Museeum"
}
]
}
Search for objects belonging to one of several types and domain specification filter
{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query": [
{
"ds:compliesWith": {
"sq:value": "https://semantify.it/ds/sloejGAwT",
"sq:datatype": "iri"
},
"@type": [
"schema:Museeum",
"schema:ParkingFacility"
]
}
]
}
Search for objects given a text string in different properties
If you want to search for an object which contains a certain string in one more properties then you can define a query such as the following: Here we search for an object that contains the string Vienna in either the name or description of the object.
{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query": [
{
"sq:or": [
{
"schema:name": {
"sq:value": "Jena",
"sq:op": "iContains"
}
},
{
"schema:description": {
"sq:value": "Jena",
"sq:op": "iContains"
}
}
]
}
]
}
Search for objects which are in a given radius to a defined lat /long pair
Another use case is to find objects in a certain radius/geo-proximity to a point. To do so, we can run the following shape query which searches for objects whose schema:geo property (with a schema:GeoCoordindate) has a certain straight line distance to a defined lat/long pair.
{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query": [
{
"schema:geo": {
"sq:nearby": {
"sq:latitude": "LAT_VALUE",
"sq:longitude": "LONG_VALUE",
"sq:distance": "DIST_IN_KM"
}
}
}
]
}
Search for objects in or around a given city
In the following query, we define two search conditions that are joined by an OR
statement. The city name to search for is "Jena". For the second condition, we define a nearby statement where we search around a given point within 10 kilometres. If a "thing" matches condition one, two or both, it will be in the query's result set.
{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query": [
{
"sq:or": [
{
"schema:address": {
"schema:addressLocality": {
"sq:op": "iContains",
"sq:value": "Jena"
}
}
},
{
"schema:geo": {
"sq:nearby": {
"sq:latitude": "50.9225599",
"sq:longitude": "11.5447746",
"sq:distance": "10"
}
}
}
]
}
]
}
Search for music events changed between a certain date
In the following query, we define a filter by Music Events modified after a given date.
In line 17, we filter for the Domain Specification ODAT Event. In line 22, we filter for Music Events. In lines 25 to 38, we filter twice for the dateModified property to restrict the time frame in which the entry was modified.
{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"schema": "https://schema.org/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/",
"onlim": "http://onlim.com/schema/",
"query": {
"@container": "@set"
}
},
"sq:query": [
{
"sq:and": [
{
"ds:compliesWith": {
"sq:value": "https://semantify.it/ds/BJfiOVFdvBak",
"sq:datatype": "iri"
}
},
{
"@type": "schema:MusicEvent"
},
{
"http://onlim.com/meta/dateModified": {
"sq:value": "2024-11-03T00:00:00",
"sq:datatype": "dateTime",
"sq:op": ">"
}
},
{
"http://onlim.com/meta/dateModified": {
"sq:value": "2024-11-03T23:59:59",
"sq:datatype": "dateTime",
"sq:op": "<"
}
}
]
}
],
"sq:select": []
}
Example API call
V1 is deprecated, please use V2
Version 1 of this endpoitn is deprecated, please use V2. The difference in calling the API is minor (the
/v1
needs to be replaced with/v2
). The changes in the response concern the quantity and nesting-depth of the properties. While V1 was responding with all properties of an object, V2 will only respond with the@id
,@type
andds:compliesWith
property. The actual data lookup needs to happen in a second step over the endpoint to retrieve an entity by id: https://changelog-dzt-kg.readme.io/reference/getthingbyid.
Note: The cURL request needs to be sent as an HTTP POST request to send the shape query payload (the --data-raw
part correctly.
curl --location 'https://proxy.opendatagermany.io/api/ts/v2/kg/things' \
--header 'Content-Type: application/ld+json' \
--header 'page-size: 50' \
--header 'page: 1' \
--header 'x-api-key: <APIKEY>' \
--data-raw '{
"@context": {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query": [
{
"@type": "schema:LocalBusiness",
"schema:address": {
"schema:addressLocality": "Jena"
}
}
]
}'
Updated about 2 months ago