This API is used to retrieve series data in desired format (csv or json). Default is json.
HTTP Request (GET): https://easydata.sbp.org.pk/api/v1/series/[series_key]/data?[parameter-list]
where [series_key] is fully qualified series key of desire indicator/variable, and [parameter-list] is a list of standard HTTP GET request parameter. Below is the list of parameters applicable for this API:
Query Parameters
Parameter |
Mandatory |
Type (format) |
Default |
Description |
api_key |
yes |
string |
none |
API key can be generated from My Data Basket under My Account after login. |
start_date |
no |
ISO Date (YYYY-MM-DD) |
none |
The start of a date range when requesting data for a range of dates. If both start_date and end_date are not specified, the API will return only the most recent observation. |
end_date |
no |
ISO Date (YYYY-MM-DD) |
Today |
The end of the date range, when requesting data for a range of dates. If both start_date and end_date are not specified, the API will return only the most recent observation. |
format |
no |
string |
json |
'json' is the default format; 'csv' is also supported. |
Python Example
import requests
res = requests.get("https://easydata.sbp.org.pk/api/v1/series/TS_GP_BOP_WR_M.WR0010/data?api_key="+
                           "FE72FE1E90D209A8AAB3E8DC83B9B8D49511BCE8" ,verify = False)
print(res.text)
Output : '{"columns": ["Dataset Name", "Series Key", "Series Name", "Observation Date", "Observation Value", "Unit", "Observation Status", "Status Comments"], "rows": [["Country-wise Workers\' Remittances", "TS_GP_BOP_WR_M.WR0010", "Total Cash inflow of Workers\' remittances in Pakistan in a month", "2022-07-31", "2523.753816", "Million USD", "Normal", ""]]}'
R Example
api_key <- "FE72FE1E90D209A8AAB3E8DC83B9B8D49511BCE8"
download.file(
    url = paste0(
    "https://easydata.sbp.org.pk/api/v1/series/TS_GP_BOP_WR_M.WR0010/data?api_key=",
    api_key
    ),
  destfile = "output.json",
  mode = "wb",
  method = "curl"
)
|