Skip to content

API

Storage

The information in the API is stored as linked data, more specifically as RDF. The category of databases suitable for storing RDF is called triplestores. In the service, we have used the EntryStore platform, which offers a variety of functionality on top of a triplestore, including simplifying the development of web applications and search interfaces. An important feature of EntryStore that is used in the national API is that information is stored in different projects (technically called contexts). In other words, all objects that are managed.

API access

EntryStore offers a linked data API for searching entities. The API is described in full on the following web page https://entrystore.org/api/. As the API is general in nature and offers a variety of ways to access information, we have listed a number of common search queries below to help developers get started.

Accessing an individual object:

https://data.visitsweden.com/store/{contextId/metadata/{entryId}

You can obtain information in various formats via content negotiation or via an explicit parameter: https://data.visitsweden.com/store/{contextId/metadata/{entryId}?format=application/ld+json

Search for all objects of a certain type:

The API provides a paginated search interface where you can request all records of a certain type: https://data.visitsweden.com/store/search?type=solr&query=public:true+AND+rdfType:http%5C%3A%2F%2Fschema.org%2FLodgingBusiness&limit=10&rdfFormat=application/ld+json

Note that the parameter public:true is important for streamlining the call when communicating with the API without being logged in.

The parameter limit can be set to a maximum of 100. To get the next set of search results, add the parameter offset:

https://data.visitsweden.com/store/search?type=solr&query=public:true+AND+rdfType:http%5C%3A%2F%2Fschema.org%2FLodgingBusiness&limit=10&offset=10

In the example above, we have requested all accommodations by requesting their main type schema: LodgingBusiness. Currently, you must enter its full URI in the rdfType field. Since the query language has a special interpretation of the colon, you must escape that character and then perform a proper URL escape on the result. JavaScript code for escaping a main type searched for in the solr field rdfType [encodeURIComponent(“http\\://schema.org/LodingBusiness”)]

Search for multiple types:

Here, it is necessary to list all main types with OR between them. https://data.visitsweden.com/store/search?type=solr&query=public:true+AND+(rdfType:http%5C%3A%2F%2Fschema.org%2FFoodEstablishment+OR+rdfType:http%5C%3A%2F%2Fschema.org%2FEvent+OR+rdfType:http%5C%3A%2F%2Fschema.org%2FPlace+OR+rdfType:http%5C%3A%2F%2Fschema.org%2FStore+OR+rdfType:http%5C%3A%2F%2Fschema.org%2FLodgingBusiness+OR+rdfType:http%5C%3A%2F%2Fschema.org%2FTrip)&limit=100&rdfFormat=application/ld+json

There is support for wildcards in rdfType, so if you want to call everything that has an rdfType starting with schema.org, you can use: https://data.visitsweden.com/store/search?type=solr&query=public:true+AND+rdfType:http%5C%3A%2F%2Fschema.org%2F*& limit=100&rdfFormat=application/ld+json

You can see the exact breakdown of the main types with facetFields: https://data.visitsweden.com/store/search?type=solr&query=public:true+AND+rdfType:http%5C%3A%2F%2Fschema.org%2F*& limit=100&rdfFormat=application/ld+json&facetFields=rdfType

Search for all images:

The search is similar to the previous queries, only with a different rdfType. https://data.visitsweden.com/store/search?type=solr&query=public:true+AND+rdfType:http%5C%3A%2F%2Fschema.org%2FImageObject&limit=10

Search for all metadata for a specific object

The API supports a recursive function that provides all metadata (e.g., image license, copyright) for a specific tourism entry. Please note that this only works for individual entries:

https://data.visitsweden.com/store/183/metadata/7?recursive=vs&format=application/ld+json