{"openapi":"3.1.0","info":{"title":"Regionkoll API","description":"Swedish regional statistics for your website, dashboard or app. Authenticate with an API key from your organisation's API page: `Authorization: Bearer rs_…`. Calls are limited per organisation per minute and per month; see the X-RateLimit headers.","version":"1.0.0"},"paths":{"/api/v1/public/indicators":{"get":{"tags":["public-api"],"summary":"List indicators","description":"Published indicators the caller may see: public ones, those opened to them, and their own.","operationId":"list_indicators_api_v1_public_indicators_get","parameters":[{"name":"q","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"description":"Search in names and keys","title":"Q"},"description":"Search in names and keys"},{"name":"category","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Category"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-api-key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/IndicatorOut"},"title":"Response List Indicators Api V1 Public Indicators Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/public/indicators/{key}":{"get":{"tags":["public-api"],"summary":"One indicator","operationId":"get_indicator_api_v1_public_indicators__key__get","parameters":[{"name":"key","in":"path","required":true,"schema":{"type":"string","title":"Key"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-api-key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IndicatorOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/public/regions":{"get":{"tags":["public-api"],"summary":"List regions at a level","operationId":"list_regions_api_v1_public_regions_get","parameters":[{"name":"level","in":"query","required":true,"schema":{"type":"string","description":"kommun, lan, la, fa, nuts1-3 or riket","title":"Level"},"description":"kommun, lan, la, fa, nuts1-3 or riket"},{"name":"edition","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"LA/FA edition, e.g. LA2023","title":"Edition"},"description":"LA/FA edition, e.g. LA2023"},{"name":"q","in":"query","required":false,"schema":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Q"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-api-key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Region"},"title":"Response List Regions Api V1 Public Regions Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/public/query":{"post":{"tags":["public-api"],"summary":"Values for indicators × regions × periods","description":"The same query and answer as the web app: series per region with\ncomparisons, indicator metadata and the data licence. Refused with 403 when the licence of\nany dataset behind the indicators does not allow API access.","operationId":"public_query_api_v1_public_query_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-api-key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Query"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Public Query Api V1 Public Query Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/public/embeds/{public_id}/token":{"post":{"tags":["public-api"],"summary":"Token for a private embed","description":"For embeds published as private (\"token\"): your server mints a short-lived token with its\nAPI key and puts it in the page it serves, e.g. an intranet page for signed-in staff:\n`<rs-chart id=\"…\" token=\"…\">` or `/embed/c/{public_id}?token=…`. Never mint tokens in the\nbrowser: the API key must stay on your server.","operationId":"embed_token_api_v1_public_embeds__public_id__token_post","parameters":[{"name":"public_id","in":"path","required":true,"schema":{"type":"string","title":"Public Id"}},{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-api-key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"GeoMode":{"type":"string","enum":["historical","fixed"],"title":"GeoMode"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"IndicatorOut":{"properties":{"key":{"type":"string","title":"Key"},"name_sv":{"type":"string","title":"Name Sv"},"name_en":{"type":"string","title":"Name En"},"description_sv":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description Sv"},"description_en":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description En"},"category":{"type":"string","title":"Category"},"country":{"type":"string","title":"Country","default":"SE"},"unit":{"type":"string","title":"Unit"},"decimals":{"type":"integer","title":"Decimals"},"type":{"type":"string","title":"Type"},"aggregation":{"type":"string","title":"Aggregation"},"available_levels":{"items":{"type":"string"},"type":"array","title":"Available Levels"},"available_dims":{"items":{"type":"string"},"type":"array","title":"Available Dims"},"source_text_sv":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Text Sv"},"source_text_en":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Text En"},"status":{"type":"string","title":"Status"},"own":{"type":"boolean","title":"Own","default":false},"higher_is_better":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Higher Is Better"},"origin":{"type":"string","enum":["data","analysis"],"title":"Origin","default":"data"},"group":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Group"},"tables":{"items":{"$ref":"#/components/schemas/TableTag"},"type":"array","title":"Tables"}},"type":"object","required":["key","name_sv","name_en","description_sv","description_en","category","unit","decimals","type","aggregation","available_levels","available_dims","source_text_sv","source_text_en","status"],"title":"IndicatorOut"},"PeriodSelection":{"properties":{"from":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"From"},"to":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"To"},"last":{"anyOf":[{"type":"integer","maximum":200.0,"minimum":1.0},{"type":"null"}],"title":"Last"},"type":{"type":"string","enum":["year","half","quarter","month","week","interval"],"title":"Type","default":"year"},"codes":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Codes"}},"type":"object","title":"PeriodSelection"},"Query":{"properties":{"spec_version":{"type":"integer","const":1,"title":"Spec Version","default":1},"indicators":{"items":{"type":"string"},"type":"array","maxItems":10,"title":"Indicators"},"raw_fields":{"items":{"$ref":"#/components/schemas/RawFieldRef"},"type":"array","maxItems":10,"title":"Raw Fields"},"regions":{"$ref":"#/components/schemas/RegionSelection"},"level":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Level"},"geo_mode":{"$ref":"#/components/schemas/GeoMode","default":"historical"},"geo_editions":{"additionalProperties":{"type":"string"},"type":"object","title":"Geo Editions"},"periods":{"$ref":"#/components/schemas/PeriodSelection"},"breakdown":{"additionalProperties":{"items":{"type":"string"},"type":"array"},"type":"object","title":"Breakdown"},"transform":{"anyOf":[{"$ref":"#/components/schemas/Transform"},{"type":"null"}]},"prefer_published":{"type":"boolean","title":"Prefer Published","default":true}},"type":"object","required":["regions"],"title":"Query"},"RawFieldRef":{"properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{2,99}$","title":"Key"},"dataset_id":{"type":"integer","title":"Dataset Id"},"measure":{"type":"string","title":"Measure"},"filters":{"additionalProperties":{"items":{"type":"string"},"type":"array"},"type":"object","title":"Filters"}},"type":"object","required":["key","dataset_id","measure"],"title":"RawFieldRef","description":"A measure taken straight from a dataset, not through a published indicator — the \"any\ncolumn\" field a free-form builder needs. Filter codes are summed exactly the way an\nindicator's own InputRef sums them (app/query/loader.py): the SQL-level completeness check\nthat turns a combination touching any suppressed cell into \"missing\" applies unchanged, so\nthis reuses the query engine's existing disclosure-control guarantee rather than needing a\nnew one. Only a plain sum is offered for now — averaging or taking a min/max live across a\ndataset's own dimension values is not yet safe to expose (a suppressed cell must still make\nthe whole aggregate unknown, which is only proven for sum).\n\n``key`` is chosen by the caller (the builder chart type's Values/Tooltip well, ADR 0029),\nnot derived from the field's own definition — a saved chart's ``chart.visual`` and its\n``query.raw_fields`` are built by the same client action and must agree on the same id\nwithout either one reconstructing a hash the other computed."},"Region":{"properties":{"key":{"type":"string","title":"Key"},"level":{"type":"string","title":"Level"},"code":{"type":"string","title":"Code"},"edition":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Edition"},"name_sv":{"type":"string","title":"Name Sv"},"name_en":{"type":"string","title":"Name En"},"valid_from":{"type":"string","format":"date","title":"Valid From"},"valid_to":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Valid To"}},"type":"object","required":["key","level","code","edition","name_sv","name_en","valid_from","valid_to"],"title":"Region"},"RegionSelection":{"properties":{"ids":{"items":{"type":"string"},"type":"array","maxItems":300,"title":"Ids"},"include_comparisons":{"items":{"type":"string"},"type":"array","title":"Include Comparisons"},"all_at_level":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"All At Level"},"within":{"anyOf":[{"type":"string","maxLength":40},{"type":"null"}],"title":"Within"}},"type":"object","title":"RegionSelection"},"TableTag":{"properties":{"dataset_id":{"type":"integer","title":"Dataset Id"},"ref":{"type":"string","title":"Ref"},"name_sv":{"type":"string","title":"Name Sv"},"name_en":{"type":"string","title":"Name En"},"source_key":{"type":"string","title":"Source Key"},"source_name":{"type":"string","title":"Source Name"},"current_version":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Current Version"},"row_count":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Row Count"}},"type":"object","required":["dataset_id","ref","name_sv","name_en","source_key","source_name"],"title":"TableTag","description":"The table (dataset) an indicator is built on, and the database (source) it came from: what\nlets a person find an indicator by where its numbers were fetched, and see if they were."},"TokenIn":{"properties":{"ttl_seconds":{"type":"integer","maximum":3600.0,"minimum":30.0,"title":"Ttl Seconds","default":900}},"type":"object","title":"TokenIn"},"TokenOut":{"properties":{"token":{"type":"string","title":"Token"},"expires_at":{"type":"integer","title":"Expires At"},"url":{"type":"string","title":"Url"}},"type":"object","required":["token","expires_at","url"],"title":"TokenOut"},"Transform":{"properties":{"type":{"type":"string","enum":["index","yoy_change","rolling_mean","cumulative"],"title":"Type"},"base":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Base"},"unit":{"type":"string","enum":["percent","absolute"],"title":"Unit","default":"percent"},"n":{"type":"integer","maximum":12.0,"minimum":2.0,"title":"N","default":3}},"type":"object","required":["type"],"title":"Transform"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer"}}},"security":[{"apiKey":[]}]}