CKAN Data API

Access resource data via a web API with powerful query support. Further information in the main CKAN Data API and DataStore documentation.

Code examples:

Get 5 results containing "SE1" in any field:
curl https://data.svk.se/en_GB/api/action/datastore_search \
  -d '
{
  "resource_id": "cf392ef3-7345-4e98-970e-83088c185570",
  "limit": 5,
  "q": "SE1"
}'
const resp = await fetch(`https://data.svk.se/en_GB/api/action/datastore_search`, {
    method: 'POST',
    headers: {
        'content-type': 'application/json'
    },
    body: JSON.stringify({
        resource_id: 'cf392ef3-7345-4e98-970e-83088c185570',
        limit: 5,
        q: 'SE1'
    })
})
await resp.json()
$json = @'
{
  "resource_id": "cf392ef3-7345-4e98-970e-83088c185570",
  "limit": 5,
  "q": "SE1"
}
'@
$response = Invoke-RestMethod https://data.svk.se/en_GB/api/action/datastore_search`
  -Method Post -Body $json
$response.result.records

(using the ckanapi client library)

from ckanapi import RemoteCKAN

rc = RemoteCKAN('https://data.svk.se/en_GB/')
result = rc.action.datastore_search(
    resource_id="cf392ef3-7345-4e98-970e-83088c185570",
    limit=5,
    q="SE1",
)
print(result['records'])
library(httr2)

req <- request("https://data.svk.se/en_GB/api/action/datastore_search")
result <- req %>% 
    req_body_json(list(
        resource_id = 'cf392ef3-7345-4e98-970e-83088c185570',
        limit = 5,
        q = 'SE1'))
    req_perform %>% 
    resp_body_json
Get results filtered by the contents of specific fields:
curl https://data.svk.se/en_GB/api/action/datastore_search \
-d '
{
  "resource_id": "cf392ef3-7345-4e98-970e-83088c185570",
  "filters": {
    "start_time_sweden": "2022-10-24T10:00:00",
    "start_time_utc": "2022-10-24T08:00:00"
  }
}'
const resp = await fetch(`https://data.svk.se/en_GB/api/action/datastore_search`, {
    method: 'POST',
    headers: {
        'content-type': 'application/json'
    },
    body: JSON.stringify({
        resource_id: 'cf392ef3-7345-4e98-970e-83088c185570',
        filters: {
            start_time_sweden: "2022-10-24T10:00:00"
            ,
            start_time_utc: "2022-10-24T08:00:00"

        }
    })
})
await resp.json()
$json = @'
{
  "resource_id": "cf392ef3-7345-4e98-970e-83088c185570",
  "filters": {
    "start_time_sweden": "2022-10-24T10:00:00",
    "start_time_utc": "2022-10-24T08:00:00"
  }
}
'@
$response = Invoke-RestMethod https://data.svk.se/en_GB/api/action/datastore_search`
  -Method Post -Body $json
$response.result.records
from ckanapi import RemoteCKAN

ck = RemoteCKAN('https://data.svk.se/en_GB/')
result = ck.action.datastore_search(
  resource_id="cf392ef3-7345-4e98-970e-83088c185570",
  filters={
        "start_time_sweden": "2022-10-24T10:00:00",
        "start_time_utc": "2022-10-24T08:00:00"
    },
)
print(result['records'])
library(httr2)

req <- request("https://data.svk.se/en_GB/api/action/datastore_search")
result <- req %>%
    req_body_json(list(
        resource_id = 'cf392ef3-7345-4e98-970e-83088c185570',
        filters = list(
            start_time_sweden = "2022-10-24T10:00:00",
            start_time_utc = "2022-10-24T08:00:00")))
    req_perform %>%
    resp_body_json

Some API endpoints may be accessed using a GET query string.

Query example (first 5 results)

https://data.svk.se/en_GB/api/action/datastore_search?resource_id=cf392ef3-7345-4e98-970e-83088c185570&limit=5

Query example (results containing 'SE1')

https://data.svk.se/en_GB/api/action/datastore_search?resource_id=cf392ef3-7345-4e98-970e-83088c185570&q=SE1