| Title: | Access the Turkish Statistical Institute SDMX REST API |
|---|---|
| Description: | Provides an authenticated, metadata-driven R client for the Turkish Statistical Institute (TURKSTAT) SDMX REST API. Supports dataflow discovery, data structure definitions, concepts, codelists, metadata-based filter validation, SDMX query construction, statistical data retrieval, and observation-based availability exploration. Authentication supports an environment variable or an explicitly supplied API key argument. |
| Authors: | Muhammed Fatih Tuzen [aut, cre] |
| Maintainer: | Muhammed Fatih Tuzen <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-11-14 00:34:14 UTC |
| Source: | https://github.com/cran/tuiksdmx |
Parses attribute components and their coded representations from a DSD.
tuik_attributes(dsd)tuik_attributes(dsd)
dsd |
XML document returned by |
A tibble describing DSD attributes.
Returns values of a dimension that are actually present in data returned by
the selected Dataflow over a bounded period. This is intentionally distinct
from tuik_dimension_codes(), which returns the theoretical Codelist domain.
tuik_available_codes( profile, dimension, start_period, end_period, filters = NULL, labels = TRUE, api_key = NULL, query_mode = c("auto", "all"), allow_all = FALSE )tuik_available_codes( profile, dimension, start_period, end_period, filters = NULL, labels = TRUE, api_key = NULL, query_mode = c("auto", "all"), allow_all = FALSE )
profile |
A |
dimension |
Dimension ID whose observed values should be returned. |
start_period |
Required start period. |
end_period |
Required end period. |
filters |
Optional named list of dimension filters. Filter values are validated against Codelists, and reapplied locally to the returned data. |
labels |
Logical. If TRUE, attach Turkish and English Codelist labels when the dimension references a Codelist. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
query_mode |
|
allow_all |
Logical. Explicitly authorizes a potentially large
|
By default query_mode = "auto" uses a server-side key for complete
filters. Partial or absent filters require the explicit allow_all = TRUE
opt-in because the service may return a large all response.
query_mode = "all" also requires allow_all = TRUE.
Both period bounds are required.
Period bounds do not impose a limit on response size or memory usage.
This is observed data availability, not an SDMX ContentConstraint.
A tibble with observed code values, row counts and optional labels.
## Not run: tuik_available_codes( profile, dimension = "COICOP_2018", start_period = "2026-01", end_period = "2026-03", allow_all = TRUE # No filters: explicit broad-download opt-in ) tuik_available_codes( profile, dimension = "COICOP_2018", start_period = "2026-01", end_period = "2026-03", filters = list(FREQ = "M", REF_AREA = "TR"), allow_all = TRUE # Partial filters: downloaded data are filtered locally ) ## End(Not run)## Not run: tuik_available_codes( profile, dimension = "COICOP_2018", start_period = "2026-01", end_period = "2026-03", allow_all = TRUE # No filters: explicit broad-download opt-in ) tuik_available_codes( profile, dimension = "COICOP_2018", start_period = "2026-01", end_period = "2026-03", filters = list(FREQ = "M", REF_AREA = "TR"), allow_all = TRUE # Partial filters: downloaded data are filtered locally ) ## End(Not run)
Builds a series key using the exact dimension order defined by the DSD.
tuik_build_key(profile, filters)tuik_build_key(profile, filters)
profile |
A |
filters |
Named list of dimension selections. |
Each dimension may contain:
one value, e.g. "M"
multiple values, e.g. c("01", "02")
Multiple values are joined using the SDMX "+" separator.
At the current stage, all series dimensions must be supplied explicitly. This is intentional because blank-segment wildcard behaviour has not been reliably confirmed for the TÜİK service.
Character string containing the SDMX key.
## Not run: # Requires TUIK_SDMX_API_KEY in the environment. library(tuiksdmx) profile <- tuik_flow_profile("DF_TUFE_SDMX_TT01") key <- tuik_build_key( profile, filters = list( REF_AREA = "TR", FREQ = "M", SINIFLAMA_DUZEYI = "2", DEGISIM = "1", OZEL_KAPSAM_TUFE = "_Z", BASE_PER = "2025", YAYIM_DONEMI = "2026_01", COICOP_1999 = "_Z", COICOP_2018 = c("01", "02"), INDICATOR = "F_TFE" ) ) ## End(Not run)## Not run: # Requires TUIK_SDMX_API_KEY in the environment. library(tuiksdmx) profile <- tuik_flow_profile("DF_TUFE_SDMX_TT01") key <- tuik_build_key( profile, filters = list( REF_AREA = "TR", FREQ = "M", SINIFLAMA_DUZEYI = "2", DEGISIM = "1", OZEL_KAPSAM_TUFE = "_Z", BASE_PER = "2025", YAYIM_DONEMI = "2026_01", COICOP_1999 = "_Z", COICOP_2018 = c("01", "02"), INDICATOR = "F_TFE" ) ) ## End(Not run)
Resolves the concepts referenced by dimensions, measures and attributes in a flow profile and adds their Turkish/English labels and descriptions.
tuik_concepts(profile, refresh = FALSE, api_key = NULL)tuik_concepts(profile, refresh = FALSE, api_key = NULL)
profile |
A |
refresh |
Logical. If TRUE, refresh ConceptScheme metadata. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
A tibble with component-to-concept mappings and semantic metadata.
Retrieves the current Dataflow catalogue published by TÜİK.
tuik_dataflows( agency = "TR", version = "latest", refresh = FALSE, api_key = NULL )tuik_dataflows( agency = "TR", version = "latest", refresh = FALSE, api_key = NULL )
agency |
Dataflow agency. Defaults to "TR". |
version |
Version selector. Defaults to "latest". |
refresh |
Logical. If TRUE, ignore the cached catalogue and retrieve a fresh copy from the service. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
The returned table contains:
Dataflow agency, ID and version
Final/non-final status
Turkish and English names
Referenced DSD agency, ID and version
Results are cached in memory for the current R session. Use
refresh = TRUE to force a new request to the TÜİK SDMX service.
A tibble with one row per Dataflow.
## Not run: flows <- tuik_dataflows() # Force a fresh download flows <- tuik_dataflows(refresh = TRUE) ## End(Not run)## Not run: flows <- tuik_dataflows() # Force a fresh download flows <- tuik_dataflows(refresh = TRUE) ## End(Not run)
Joins dimension code labels from the Codelists referenced by a Dataflow profile. Original SDMX dimension codes and observations are preserved. The labels describe Codelist definitions, not observed availability.
tuik_decode_data( data, profile, dimensions = NULL, language = c("tr", "en", "both"), api_key = NULL )tuik_decode_data( data, profile, dimensions = NULL, language = c("tr", "en", "both"), api_key = NULL )
data |
A data frame returned by |
profile |
A |
dimensions |
NULL (all coded dimensions present in |
language |
One of |
api_key |
Optional API key. If NULL, |
A tibble containing the input columns plus DIMENSION_label_tr
and/or DIMENSION_label_en columns. Unknown code labels remain NA.
## Not run: # Requires TUIK_SDMX_API_KEY in the environment. library(tuiksdmx) profile <- tuik_flow_profile("DF_TUFE_SDMX_TT01") # Use the complete CPI filter set documented in tuik_get_data(). # Check current metadata before reuse; codes and availability may change. data <- tuik_get_data( profile, filters = list( REF_AREA = "TR", FREQ = "M", SINIFLAMA_DUZEYI = "2", DEGISIM = "1", OZEL_KAPSAM_TUFE = "_Z", BASE_PER = "2025", YAYIM_DONEMI = "2026_01", COICOP_1999 = "_Z", COICOP_2018 = "01", INDICATOR = "F_TFE" ), start_period = "2026-01", end_period = "2026-01" ) decoded <- tuik_decode_data(data, profile, dimensions = c("DEGISIM", "FREQ")) ## End(Not run)## Not run: # Requires TUIK_SDMX_API_KEY in the environment. library(tuiksdmx) profile <- tuik_flow_profile("DF_TUFE_SDMX_TT01") # Use the complete CPI filter set documented in tuik_get_data(). # Check current metadata before reuse; codes and availability may change. data <- tuik_get_data( profile, filters = list( REF_AREA = "TR", FREQ = "M", SINIFLAMA_DUZEYI = "2", DEGISIM = "1", OZEL_KAPSAM_TUFE = "_Z", BASE_PER = "2025", YAYIM_DONEMI = "2026_01", COICOP_1999 = "_Z", COICOP_2018 = "01", INDICATOR = "F_TFE" ), start_period = "2026-01", end_period = "2026-01" ) decoded <- tuik_decode_data(data, profile, dimensions = c("DEGISIM", "FREQ")) ## End(Not run)
Finds the Codelist referenced by a dimension and returns its codes.
tuik_dimension_codes( dimensions, dimension, search = NULL, language = c("both", "tr", "en"), limit = 50, api_key = NULL )tuik_dimension_codes( dimensions, dimension, search = NULL, language = c("both", "tr", "en"), limit = 50, api_key = NULL )
dimensions |
Dimension table returned by |
dimension |
Dimension ID, for example "FREQ" or "COICOP_2018". |
search |
Optional search term. |
language |
Search language: "both", "tr", or "en". |
limit |
Maximum number of rows to return. Use NULL for all rows. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
Optionally searches within code values and Turkish/English labels.
A tibble containing the dimension codes.
## Not run: tuik_dimension_codes( dimensions, "FREQ" ) tuik_dimension_codes( dimensions, "COICOP_2018", search = "food" ) ## End(Not run)## Not run: tuik_dimension_codes( dimensions, "FREQ" ) tuik_dimension_codes( dimensions, "COICOP_2018", search = "food" ) ## End(Not run)
Parses Dimension and TimeDimension components from a DSD.
tuik_dimensions(dsd)tuik_dimensions(dsd)
dsd |
XML document returned by |
A tibble describing DSD dimensions.
Displays structural components from a Dataflow's DSD without downloading
observations. Series dimensions are selected using filters; TIME_PERIOD
uses start_period and end_period in tuik_get_data(). A specific coded
dimension can be inspected on demand. Codelist entries are theoretical,
not necessarily observed in a selected time window.
tuik_explore( dataflow, dimension = NULL, search = NULL, language = c("both", "tr", "en"), limit = 50, api_key = NULL, filters = NULL )tuik_explore( dataflow, dimension = NULL, search = NULL, language = c("both", "tr", "en"), limit = 50, api_key = NULL, filters = NULL )
dataflow |
A Dataflow ID or a |
dimension |
Optional series dimension ID whose codes to display. |
search |
Optional search text for |
language |
One of |
limit |
Maximum codes to display for a selected dimension; default 50. |
api_key |
Optional API key; defaults to |
filters |
Optional named list of selected series-dimension codes. When
supplied without |
Without dimension, a tibble describing DSD components and how to
select them. If filters is supplied, also shows selections and missing
series dimensions. With dimension, a tibble of Codelist codes and labels.
## Not run: tuik_explore("DF_TUFE_SDMX_TT01") tuik_explore("DF_TUFE_SDMX_TT01", dimension = "DEGISIM") selections <- list(REF_AREA = "TR", FREQ = "M", DEGISIM = "1") tuik_explore("DF_TUFE_SDMX_TT01", filters = selections) data <- tuik_get_data("DF_TUFE_SDMX_TT01", filters = selections, filter_mode = "local", start_period = "2026-01", end_period = "2026-01") ## End(Not run)## Not run: tuik_explore("DF_TUFE_SDMX_TT01") tuik_explore("DF_TUFE_SDMX_TT01", dimension = "DEGISIM") selections <- list(REF_AREA = "TR", FREQ = "M", DEGISIM = "1") tuik_explore("DF_TUFE_SDMX_TT01", filters = selections) data <- tuik_get_data("DF_TUFE_SDMX_TT01", filters = selections, filter_mode = "local", start_period = "2026-01", end_period = "2026-01") ## End(Not run)
Returns the dimensions required to build a series key together with their referenced Codelists.
tuik_filter_dimensions(profile)tuik_filter_dimensions(profile)
profile |
A |
A tibble describing required filter dimensions.
Creates a named list containing all dimensions required for an SDMX series key. Each value is initially NULL and can be filled by the user.
tuik_filter_template(profile)tuik_filter_template(profile)
profile |
A |
TIME_PERIOD is excluded because time filtering is handled separately through startPeriod and endPeriod.
A named list with one element per series-key dimension.
## Not run: # Requires TUIK_SDMX_API_KEY in the environment. library(tuiksdmx) profile <- tuik_flow_profile("DF_TUFE_SDMX_TT01") filters <- tuik_filter_template(profile) filters$REF_AREA <- "TR" filters$FREQ <- "M" ## End(Not run)## Not run: # Requires TUIK_SDMX_API_KEY in the environment. library(tuiksdmx) profile <- tuik_flow_profile("DF_TUFE_SDMX_TT01") filters <- tuik_filter_template(profile) filters$REF_AREA <- "TR" filters$FREQ <- "M" ## End(Not run)
Retrieves a Dataflow, follows its referenced DSD and parses its structural components.
tuik_flow_profile( dataflow_id, agency = "TR", version = "latest", api_key = NULL )tuik_flow_profile( dataflow_id, agency = "TR", version = "latest", api_key = NULL )
dataflow_id |
Dataflow identifier. |
agency |
Dataflow agency. Defaults to "TR". |
version |
Dataflow version. Defaults to "latest". |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
A list with the following components:
dataflow
dsd
dimensions
measures
attributes
## Not run: profile <- tuik_flow_profile( "DF_TUFE_SDMX_TT01", version = "1.0" ) profile$dimensions ## End(Not run)## Not run: profile <- tuik_flow_profile( "DF_TUFE_SDMX_TT01", version = "1.0" ) profile$dimensions ## End(Not run)
Downloads and parses an SDMX Codelist.
tuik_get_codelist( codelist_id, agency, version = "latest", refresh = FALSE, api_key = NULL )tuik_get_codelist( codelist_id, agency, version = "latest", refresh = FALSE, api_key = NULL )
codelist_id |
Codelist identifier. |
agency |
Codelist agency. |
version |
Codelist version. |
refresh |
Logical. If TRUE, ignore the cache and download the Codelist again. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
Results are cached in memory for the current R session.
A tibble with code, Turkish label and English label.
Downloads and parses a ConceptScheme. Results are cached in memory for the current R session.
tuik_get_concept_scheme( concept_scheme_id, agency, version = "latest", refresh = FALSE, api_key = NULL )tuik_get_concept_scheme( concept_scheme_id, agency, version = "latest", refresh = FALSE, api_key = NULL )
concept_scheme_id |
ConceptScheme identifier. |
agency |
ConceptScheme agency. |
version |
ConceptScheme version. Defaults to "latest". |
refresh |
Logical. If TRUE, ignore the cache and download again. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
A tibble with Concept IDs and multilingual labels/descriptions.
Retrieves all series with filters = NULL, or builds a complete SDMX key
from supplied filters. Partial filters require explicit permission via
allow_all = TRUE or filter_mode = "local": the service's all data are retrieved
first and filters are applied in R. At least one period bound is required
unless allow_unbounded = TRUE. This is NOT server-side
filtering and can download large responses even for a short period.
Complete filters are always queried by SDMX key on the server.
tuik_get_data( profile, filters = NULL, start_period = NULL, end_period = NULL, parse_observation = TRUE, validate = TRUE, api_key = NULL, allow_unbounded = FALSE, labels = c("none", "tr", "en", "both"), label_dimensions = NULL, filter_mode = c("reject", "local"), allow_all = FALSE )tuik_get_data( profile, filters = NULL, start_period = NULL, end_period = NULL, parse_observation = TRUE, validate = TRUE, api_key = NULL, allow_unbounded = FALSE, labels = c("none", "tr", "en", "both"), label_dimensions = NULL, filter_mode = c("reject", "local"), allow_all = FALSE )
profile |
A |
filters |
NULL to request all series, or a named list of key-dimension
selections. Partial selections require |
start_period |
Optional start period, for example "2026-01". |
end_period |
Optional end period, for example "2026-03". |
parse_observation |
Logical. If TRUE, attempts to convert OBS_VALUE to numeric while preserving all SDMX dimensions and attributes as character columns. |
validate |
Logical. If TRUE, validate supplied filter values against the Codelists referenced by the Dataflow DSD before requesting data. Defaults to TRUE. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
allow_unbounded |
Logical. Must be TRUE to permit unfiltered or locally filtered requests with neither period bound supplied. This can download a very large dataset. Does not limit the server response size. |
labels |
Language of optional Codelist labels: |
label_dimensions |
Optional character vector of dimension IDs to
decode when |
filter_mode |
Legacy explicit mode: |
allow_all |
Logical, default FALSE. With incomplete |
A tibble containing SDMX observations. If labels are requested,
additional <DIMENSION>_label_tr and/or <DIMENSION>_label_en columns
are appended. Labels identify Codelist-defined values, not observed
availability.
## Not run: # Requires TUIK_SDMX_API_KEY in the environment. library(tuiksdmx) profile <- tuik_flow_profile("DF_TUFE_SDMX_TT01") data <- tuik_get_data( profile, filters = list( REF_AREA = "TR", FREQ = "M", SINIFLAMA_DUZEYI = "2", DEGISIM = "1", OZEL_KAPSAM_TUFE = "_Z", BASE_PER = "2025", YAYIM_DONEMI = "2026_01", COICOP_1999 = "_Z", COICOP_2018 = "01", INDICATOR = "F_TFE" ), start_period = "2026-01", end_period = "2026-03" ) ## End(Not run)## Not run: # Requires TUIK_SDMX_API_KEY in the environment. library(tuiksdmx) profile <- tuik_flow_profile("DF_TUFE_SDMX_TT01") data <- tuik_get_data( profile, filters = list( REF_AREA = "TR", FREQ = "M", SINIFLAMA_DUZEYI = "2", DEGISIM = "1", OZEL_KAPSAM_TUFE = "_Z", BASE_PER = "2025", YAYIM_DONEMI = "2026_01", COICOP_1999 = "_Z", COICOP_2018 = "01", INDICATOR = "F_TFE" ), start_period = "2026-01", end_period = "2026-03" ) ## End(Not run)
Retrieves metadata for one Dataflow and its referenced DSD.
tuik_get_dataflow( dataflow_id, agency = "TR", version = "latest", api_key = NULL )tuik_get_dataflow( dataflow_id, agency = "TR", version = "latest", api_key = NULL )
dataflow_id |
Dataflow identifier. |
agency |
Dataflow agency. Defaults to "TR". |
version |
Dataflow version. Defaults to "latest". |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
A one-row tibble.
## Not run: tuik_get_dataflow( "DF_TUFE_SDMX_TT01", version = "1.0" ) ## End(Not run)## Not run: tuik_get_dataflow( "DF_TUFE_SDMX_TT01", version = "1.0" ) ## End(Not run)
Retrieves a DSD from the TÜİK SDMX Web Service.
tuik_get_dsd(dsd_id, agency = "TR", version = "latest", api_key = NULL)tuik_get_dsd(dsd_id, agency = "TR", version = "latest", api_key = NULL)
dsd_id |
Data Structure Definition identifier. |
agency |
DSD agency. Defaults to "TR". |
version |
DSD version. Defaults to "latest". |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
An xml2 XML document.
## Not run: dsd <- tuik_get_dsd( "DSD_TUFE", version = "1.12" ) ## End(Not run)## Not run: dsd <- tuik_get_dsd( "DSD_TUFE", version = "1.12" ) ## End(Not run)
Extracts ordinary series dimensions from a TÜİK flow profile.
tuik_key_dimensions(profile)tuik_key_dimensions(profile)
profile |
A |
TimeDimension components such as TIME_PERIOD are excluded because they are supplied separately through time query parameters.
A tibble containing the key dimensions in DSD order.
Parses measure components from a DSD.
tuik_measures(dsd)tuik_measures(dsd)
dsd |
XML document returned by |
A tibble describing DSD measures.
Compares a filter list with the dimensions required by the DSD.
tuik_missing_filters(profile, filters)tuik_missing_filters(profile, filters)
profile |
A |
filters |
Named list of dimension selections. |
Character vector containing missing dimension IDs.
Searches component IDs, concept IDs, labels and descriptions in the concepts referenced by a flow profile.
tuik_search_concepts( profile, query, language = c("both", "tr", "en"), limit = 50, api_key = NULL )tuik_search_concepts( profile, query, language = c("both", "tr", "en"), limit = 50, api_key = NULL )
profile |
A |
query |
Search text. |
language |
One of "both", "tr", or "en". |
limit |
Maximum number of results. Use NULL for all matches. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
A filtered concept tibble.
Searches the TÜİK SDMX Dataflow catalogue using a keyword or phrase.
tuik_search_dataflows( query, language = c("both", "tr", "en"), final_only = FALSE, limit = 25, fuzzy = TRUE, refresh = FALSE, dataflows = NULL, api_key = NULL )tuik_search_dataflows( query, language = c("both", "tr", "en"), final_only = FALSE, limit = 25, fuzzy = TRUE, refresh = FALSE, dataflows = NULL, api_key = NULL )
query |
Character string containing the search term. |
language |
Which label language should be searched. One of "both", "tr", or "en". Defaults to "both". |
final_only |
Logical. If TRUE, return only final Dataflows. |
limit |
Maximum number of results. Use NULL for all matches. |
fuzzy |
Logical. If TRUE, perform fallback matching when the exact search returns no results. |
refresh |
Logical. If TRUE, refresh the Dataflow catalogue. |
dataflows |
Optional Dataflow catalogue supplied by the user. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used when retrieving the catalogue. |
Search fields:
Dataflow ID
Turkish Dataflow name
English Dataflow name
Referenced DSD ID
Search is case-insensitive and tolerant of Turkish characters.
For example:
"tüketici fiyat" "tuketici fiyat"
are treated equivalently.
If no exact substring match is found, an optional conservative fallback search is performed using shortened word variants. This may help with expressions such as "işsizlik" when catalogue labels contain "işsiz".
A tibble containing matching Dataflows.
## Not run: tuik_search_dataflows("tüketici fiyat") tuik_search_dataflows("tuketici fiyat") tuik_search_dataflows("işsizlik") tuik_search_dataflows( "consumer price", language = "en" ) ## End(Not run)## Not run: tuik_search_dataflows("tüketici fiyat") tuik_search_dataflows("tuketici fiyat") tuik_search_dataflows("işsizlik") tuik_search_dataflows( "consumer price", language = "en" ) ## End(Not run)
Checks whether supplied filter values exist in the Codelists referenced by the Dataflow's DSD.
tuik_validate_filters(profile, filters, stop_on_error = TRUE, api_key = NULL)tuik_validate_filters(profile, filters, stop_on_error = TRUE, api_key = NULL)
profile |
A |
filters |
Named list of dimension selections. |
stop_on_error |
Logical. If TRUE, stop when invalid codes are found. |
api_key |
Optional API key. If NULL, the TUIK_SDMX_API_KEY environment variable is used. |
A tibble with one row per supplied filter value.