International Monetary Fund’s API - api

Data - IMF

Info

source dataset Title Updated
imf api NA NA

List of APIs

source dataset Title Updated
bdf api NA NA
bea api NA NA
bis api NA NA
bls api NA NA
dbnomics api NA NA
ecb api NA NA
eurostat api NA NA
imf api NA NA
insee api NA NA
oecd api OECD's API 2026-08-02
wdi api NA NA

All

  • Use the JSON RESTful Web Service. html

LAST_COMPILE

LAST_COMPILE
2026-08-17

Liste

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/Dataflow" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "Dataflows", "Dataflow") %>%
  setNames(gsub("@", "", names(.))) |>
  select(1:3) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

BOP

Components

Code
Sys.sleep(10)
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/BOP" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Dimension") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/BOP" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

REF_AREA

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_AREA_BOP" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

REF_AREA <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("REF_AREA", "Ref_area"))

REF_AREA |>
  mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Ref_area))),
         Flag = paste0('<img src="../../icon/flag/vsmall/', Flag, '.png" alt="Flag">')) |>
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

INDICATOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_INDICATOR_BOP" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

INDICATOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("INDICATOR", "Indicator"))

INDICATOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

CPI

Components

Code
Sys.sleep(10)
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/CPI" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Dimension") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/CPI" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

REF_AREA

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_AREA_CPI" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

REF_AREA <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("REF_AREA", "Ref_area"))

REF_AREA |>
  mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Ref_area))),
         Flag = paste0('<img src="../../icon/flag/vsmall/', Flag, '.png" alt="Flag">')) |>
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

INDICATOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_INDICATOR_CPI" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

INDICATOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("INDICATOR", "Indicator"))

INDICATOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Ex 1

Code
Sys.sleep(10)
"..PCPIH_IX" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/CPI/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  filter(!is.na(OBS_STATUS)) |>
  left_join(REF_AREA, by = "REF_AREA") |>
  group_by(REF_AREA, FREQ, Ref_area) |>
  summarise(Nobs = n()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

CPI, Housing

Code
# PCPI_IX: Consumer Price Index, All items
"Q.GB+FR+DE.PCPIH_IX" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/CPI/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  quarter_to_date2() |>
  mutate(OBS_VALUE = OBS_VALUE |> as.numeric()) |>
  na.omit() |>
  ggplot() + 
  geom_line(aes(x = date, y = OBS_VALUE, color = REF_AREA, linetype = REF_AREA)) + 
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = seq(1950, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_y_log10(breaks = seq(0, 200, 10),
                     labels = dollar_format(accuracy = 1, prefix = "")) +
  
  theme(legend.position = c(0.2, 0.80),
        legend.title = element_blank())

CPI, Harmonized Housing

Code
# PCPIHAH_IX: Housing, Water, Electricity, Gas and Other Fuels, Harmonized
"Q.GB+FR+DE.PCPIHAH_IX" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/CPI/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  quarter_to_date2() |>
  mutate(OBS_VALUE = OBS_VALUE |> as.numeric()) |>
  na.omit() |>
  ggplot() + 
  geom_line(aes(x = date, y = OBS_VALUE, color = REF_AREA, linetype = REF_AREA)) + 
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = seq(1950, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_y_log10(breaks = seq(0, 200, 10),
                     labels = dollar_format(accuracy = 1, prefix = "")) +
  
  theme(legend.position = c(0.8, 0.20),
        legend.title = element_blank())

CPI, All

Code
# PCPI_IX: Consumer Price Index, All items
"Q.GB+FR+DE.PCPI_IX" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/CPI/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  quarter_to_date2() |>
  mutate(OBS_VALUE = OBS_VALUE |> as.numeric()) |>
  ggplot() + 
  geom_line(aes(x = date, y = OBS_VALUE, color = REF_AREA, linetype = REF_AREA)) + 
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = seq(1950, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_y_log10(breaks = c(seq(1, 5, 1), seq(0, 200, 10)),
                     labels = dollar_format(accuracy = 1, prefix = "")) +
  
  theme(legend.position = c(0.2, 0.80),
        legend.title = element_blank())

DOTS

Components

Code
Sys.sleep(10)
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/DOT" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Dimension") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/DOT" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") |>
  select(1:5) %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

REF_AREA

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_AREA_DOT" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

REF_AREA <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("REF_AREA", "Ref_area"))

REF_AREA |>
  mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Ref_area))),
         Flag = paste0('<img src="../../icon/flag/vsmall/', Flag, '.png" alt="Flag">')) |>
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

INDICATOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_INDICATOR_DOT" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

INDICATOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("INDICATOR", "Indicator"))

INDICATOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Using the API

Code
"M.US.TXG_FOB_USD" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/DOT/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") %>%
  setNames(gsub("@", "", names(.))) |>
  select(-Obs) |>
  head() %>%
  {if (is_html_output()) print_table(.) else .}

World Exports

Code
"M.US+CN+JP+W00.TXG_FOB_USD.W00.?startPeriod=1972&endPeriod=2016" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/DOT/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") |>
  month_to_date() %>%
  setNames(gsub("@", "", names(.))) |>
  mutate(`OBS_VALUE` = `OBS_VALUE` |> as.numeric()) |>
  head() %>%
  {if (is_html_output()) print_table(.) else .}

Trade Balance

Code
"A..TBG_USD.W00.?startPeriod=2016&endPeriod=2017" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/DOT/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") |>
  select(-matches("\bObs\b")) %>%
  setNames(gsub("@", "", names(.))) |>
  mutate(OBS_VALUE = as.numeric(OBS_VALUE)) |>
  head() %>%
  {if (is_html_output()) print_table(.) else .}

World Share

Code
"M.FR+DE+IT+US+CN+W00.TXG_FOB_USD.W00.?startPeriod=1972&endPeriod=2020" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/DOT/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") |>
  select(-matches("\bObs\b")) %>%
  setNames(gsub("@", "", names(.))) |>
  month_to_date2() |>
  mutate(OBS_VALUE = as.numeric(OBS_VALUE)) |>
  select(date, REF_AREA, OBS_VALUE) |>
  group_by(date) |>
  mutate(OBS_VALUE = OBS_VALUE / OBS_VALUE[REF_AREA == "W00"]) |>
  filter(REF_AREA != "W00") |>
  ggplot() + theme_minimal() + ylab("World Share (%)") + xlab("") +
  geom_line(aes(x = date, y = OBS_VALUE, color = REF_AREA, linetype = REF_AREA)) +
  scale_color_manual(values = viridis(6)[1:5]) +
  theme(legend.position = c(0.45, 0.9),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(-7, 60, 1),
                     labels = scales::percent_format(accuracy = 1))
Code
"Q.FR+DE+IT+US+CN+W00.TXG_FOB_USD.W00.?startPeriod=1972&endPeriod=2020" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/DOT/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  quarter_to_date2() |>
  mutate(value = OBS_VALUE |> as.numeric()) |>
  select(date, iso2c = REF_AREA, value) |>
  group_by(date) |>
  mutate(value = value / value[iso2c == "W00"]) |>
  filter(iso2c != "W00") |>
  ggplot() + geom_line(aes(x = date, y = value, color = iso2c)) +
  scale_color_manual(values = viridis(6)[1:5]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.45, 0.9),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) +
  ylab("World Share (%)") + xlab("")
Code
"A.FR+DE+IT+US+CN+W00.TXG_FOB_USD.W00.?startPeriod=1972&endPeriod=2020" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/DOT/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  year_to_date2() |>
  mutate(value = OBS_VALUE |> as.numeric()) |>
  select(date, iso2c = REF_AREA, value) |>
  group_by(date) |>
  mutate(value = value / value[iso2c == "W00"]) |>
  filter(iso2c != "W00") |>
  ggplot() + geom_line(aes(x = date, y = value, color = iso2c)) +
  scale_color_manual(values = viridis(6)[1:5]) +
  theme_minimal() +
  scale_x_date(breaks = seq(1920, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  theme(legend.position = c(0.45, 0.95),
        legend.title = element_blank(),
        legend.direction = "horizontal") +
  scale_y_continuous(breaks = 0.01*seq(-7, 60, 1),
                     labels = scales::percent_format(accuracy = 1)) +
  ylab("World Share (%)") + xlab("")

FM

Components

Code
Sys.sleep(10)
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/FM" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Dimension") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/FM" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

REF_AREA

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_AREA_FM" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

REF_AREA <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("REF_AREA", "Ref_area"))

REF_AREA |>
  mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Ref_area))),
         Flag = paste0('<img src="../../icon/flag/vsmall/', Flag, '.png" alt="Flag">')) |>
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

INDICATOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_INDICATOR_FM" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

INDICATOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("INDICATOR", "Indicator"))

INDICATOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

GGCB_G01_PGDP_PT

Code
"A.US+CN+JP+W00.GGCB_G01_PGDP_PT?startPeriod=1972" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/FM/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  mutate(`OBS_VALUE` = `OBS_VALUE` |> as.numeric()) |>
  year_to_date2() |>
  head() %>%
  {if (is_html_output()) print_table(.) else .}

FSI

Components

Code
Sys.sleep(10)
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/FSI" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Dimension") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/FSI" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

INDICATOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_INDICATOR_FSI" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

INDICATOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("INDICATOR", "Indicator"))

INDICATOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

GFSE

Components

Code
Sys.sleep(10)
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/GFSE" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Dimension") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/GFSE" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

REF_AREA

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_AREA_GFSE" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

REF_AREA <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("REF_AREA", "Ref_area"))

REF_AREA |>
  mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Ref_area))),
         Flag = paste0('<img src="../../icon/flag/vsmall/', Flag, '.png" alt="Flag">')) |>
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

SECTOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_SECTOR_GFSE" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

SECTOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("SECTOR", "Sector"))

save(SECTOR, file = "CL_SECTOR_GFSE2.RData")

SECTOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

INDICATOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_INDICATOR_GFSE" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

INDICATOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("INDICATOR", "Indicator"))

save(INDICATOR, file = "CL_INDICATOR_GFSE2")

INDICATOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

ICSD

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/IFS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

INDICATOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_INDICATOR_IFS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

INDICATOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("INDICATOR", "Indicator"))

INDICATOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

IFS

Components

Code
Sys.sleep(10)
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/IFS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Dimension") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/IFS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

REF_AREA

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_AREA_IFS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

REF_AREA <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("REF_AREA", "Ref_area"))

REF_AREA |>
  mutate(Flag = gsub(" ", "-", str_to_lower(gsub(" ", "-", Ref_area))),
         Flag = paste0('<img src="../../icon/flag/vsmall/', Flag, '.png" alt="Flag">')) |>
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

INDICATOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_INDICATOR_IFS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

INDICATOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("INDICATOR", "Indicator"))

INDICATOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

Phillips Curves

Code
"A.US.EREER_IX+LUR_PT" %>%
  # EREER_IX: Exchange Rates, Real Effective Exchange Rate based on Consumer Price Index
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  year_to_date2() |>
  mutate(value = OBS_VALUE |> as.numeric()) |>
  select(date, variable = INDICATOR, value) |>
  spread(variable, value) |>
  na.omit() |>
  mutate(EREER_IX_d1ln = log(EREER_IX) - lag(log(EREER_IX), 1)) %>%
  lm(EREER_IX_d1ln ~ LUR_PT, data = .) |>
  summary()
Code
"A.DE.EREER_IX+LUR_PT" %>%
  # EREER_IX: Exchange Rates, Real Effective Exchange Rate based on Consumer Price Index
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  year_to_date2() |>
  mutate(value = OBS_VALUE |> as.numeric()) |>
  select(date, variable = INDICATOR, value) |>
  spread(variable, value) |>
  na.omit() |>
  mutate(EREER_IX_d1ln = log(EREER_IX) - lag(log(EREER_IX), 1)) %>%
  lm(EREER_IX_d1ln ~ LUR_PT, data = .) |>
  summary()

Financial Market Prices, Equities, Index - FPE_IX

Code
# FR: France
# ENDE_XDC_USD_RATE
"Q.GB+FR+DE+US.FPE_IX" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  quarter_to_date2() |>
  mutate(OBS_VALUE = OBS_VALUE |> as.numeric()) |>
  ggplot() + 
  geom_line(aes(x = date, y = OBS_VALUE, color = REF_AREA, linetype = REF_AREA)) + 
  theme_minimal() + xlab("") + ylab("Market Values") +
  scale_x_date(breaks = seq(1950, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_y_log10(breaks = c(seq(0, 100, 10), 200, 300, 500, 1000),
                     labels = dollar_format(accuracy = 1, prefix = "")) +
  
  theme(legend.position = c(0.8, 0.20),
        legend.title = element_blank())

Exchange Rates

Code
Sys.sleep(10)
tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  filter(id %in% c("ENDE_XDC_USD_RATE", "EREER_ULC_IX", "EREER_IX",
                   "ENEER_ULC_IX", "ENEER_IX")) %>%
  {if (is_html_output()) print_table(.) else .}

ENDE_XDC_USD_RATE - Exchange Rates

Code
# FR: France
# ENDE_XDC_USD_RATE
"Q.GB+FR+DE+US.ENDE_XDC_USD_RATE" %>%
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  quarter_to_date2() |>
  mutate(OBS_VALUE = OBS_VALUE |> as.numeric()) |>
  ggplot() + 
  geom_line(aes(x = date, y = OBS_VALUE, color = REF_AREA, linetype = REF_AREA)) + 
  theme_minimal() + xlab("") + ylab("Exchange Rate ($1 = ?National Currency)") +
  scale_x_date(breaks = seq(1960, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = seq(0, 10, 1),
                     labels = dollar_format(accuracy = 0.1, prefix = "", suffix = "../$")) +
  
  theme(legend.position = c(0.8, 0.80),
        legend.title = element_blank())

EREER_ULC_IX - REER based on ULC

Code
"Q.GB+FR+DE+US.EREER_ULC_IX" %>%
  # EREER_ULC_IX: Exchange Rates, Real Effective Exchange Rate based on Unit Labor Costs, Index
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  quarter_to_date2() |>
  mutate(OBS_VALUE = OBS_VALUE |> as.numeric()) |>
  ggplot() + 
  geom_line(aes(x = date, y = OBS_VALUE, color = REF_AREA, linetype = REF_AREA)) + 
  theme_minimal() + xlab("") + ylab("REER based on ULC") +
  scale_x_date(breaks = seq(1960, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_y_log10(breaks = seq(0, 200, 10),
                     labels = dollar_format(accuracy = 1, prefix = "")) +
  
  theme(legend.position = c(0.8, 0.2),
        legend.title = element_blank())

EREER_IX - Exchange Rates, REER based on CPI

Code
"Q.GB+FR+DE+US.EREER_IX" %>%
  # EREER_IX: Exchange Rates, Real Effective Exchange Rate based on Consumer Price Index
  paste0("http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/", .) |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("CompactData", "DataSet", "Series") |>
  unnest(cols = "Obs") %>%
  setNames(gsub("@", "", names(.))) |>
  quarter_to_date2() |>
  mutate(OBS_VALUE = OBS_VALUE |> as.numeric()) |>
  ggplot() + 
  geom_line(aes(x = date, y = OBS_VALUE, color = REF_AREA, linetype = REF_AREA)) + 
  theme_minimal() + xlab("") + ylab("REER based on CPI") +
  scale_x_date(breaks = seq(1960, 2100, 5) |> paste0("-01-01") |> as.Date(),
               labels = date_format("%Y")) +
  scale_y_log10(breaks = seq(0, 200, 10),
                     labels = dollar_format(accuracy = 1, prefix = "")) +
  
  theme(legend.position = c(0.8, 0.80),
        legend.title = element_blank())

Unemployment

Code
tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  filter(id %in% c("LUR_PT")) %>%
  {if (is_html_output()) print_table(.) else .}

CPI, Inflation

Code
Sys.sleep(10)
tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  filter(id %in% c("PCPI_IX", "PCPIHA_IX", "PPPIFG_IX", "PCPI_PC_CP_A_PT",
                   "PCPI_PC_PP_PT")) %>%
  {if (is_html_output()) print_table(.) else .}

MFS

Components

Code
Sys.sleep(10)
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/MFS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Dimension") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/MFS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

PGCS

Components

Code
Sys.sleep(10)
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/PGCS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Dimension") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

Attribute

Code
"http://dataservices.imf.org/REST/SDMX_JSON.svc/DataStructure/PGCS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "KeyFamilies", "KeyFamily", "Components", "Attribute") %>%
  setNames(gsub("@", "", names(.))) %>%
  {if (is_html_output()) print_table(.) else .}

INDICATOR

Code
imf_codelist <- "http://dataservices.imf.org/REST/SDMX_JSON.svc/CodeList/CL_INDICATOR_PGCS" |>
  httr::GET() |>
  httr::content("text") |>
  jsonlite::fromJSON() |>
  pluck("Structure", "CodeLists", "CodeList", "Code")

INDICATOR <- tibble(id = imf_codelist |> pluck("@value"),
       description = imf_codelist |> pluck("Description", "#text")) |>
  setNames(c("INDICATOR", "Indicator"))

INDICATOR %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}