API - MMA Statistics Database
Back

MMA Statistics API Documentation

General Information
  • All responses are in JSON format
  • An API token is required to access the data
  • Authorization type is Bearer Token
  • SERIES_ID_ARRAY must be passed in the URL
  • API URL is https://database.mma.gov.mv/api/series?ids={SERIES_ID_ARRAY}
  • Date format is yyyy-mm-dd

JSON RESPONSE FORMAT
{ "data": [ { "id": 1122, "name": "Total excluding fish", "sector": "Real Sector", "path": [ "Real Sector", "Prices", "Male'", "CPI" ], "unit": "Index", "frequency": "Monthly", "description": "", "is_flow": false, "is_stock": false, "is_latest_missing": false, "freq_convertible": true, "conversion_method": "avg", "is_int": false, "source": [ "Maldives Bureau of Statistics" ], "composition": [], "data": [ { "date": "1985-01-31", "amount": 23.4506707944345 }, // more data points ] } // more series ], "meta": { "total": 1, "current_page": 1, "last_page": 1, "per_page": 10 }, "links": { "first": "https://database.mma.gov.mv/api/series?ids=1122", "prev": null, "next": null, "last": "https://database.mma.gov.mv/api/series?ids=1122" } }
Field Type Description
id Integer Series id
name String The name of the data series
sector String The sector that the data series belongs to
path Array The hierarchy of the data series
unit String The unit of data series (Rufiyaa / US dollar, etc.. )
last_updated_at String Returns the last update date and time for the specific series
frequency String The frequency in which the data is reported (Monthly, Quarterly, Annual)
base_weight float The weight allocated to the series, if applicable
definition String Brief description of the data series
is_flow Boolean Represents changes in economic values within a period
is_stock Boolean Represents economic value at a given point in time
freq_convertible Boolean Whether the data can be converted to different frequencies
is_latest_missing Boolean Returns false if data is up to date or latest. Returns true if a series is discontinued.
conversion_method String If freq_convertible is true, this field will give the method of conversion (sum, avg, ep)
is_int Boolean This represents whether the value of the amount column in the data array should be shown as an integer or not.
source Array Where the data originates
composition Array Composition of child series
data Array Series data array
Last updated on March 28, 2023
SAMPLE CODE
  • Python
  • R

import requests
import json
import pandas as pd

series_id = SERIES_ID_ARRAY
token = BEARER_TOKEN

def bearer_oauth(r):
    """
    Method required by bearer token authentication.
    """
    r.headers["Authorization"] = f"Bearer {token}"
    return r

url = f"https://database.mma.gov.mv/api/series?ids={series_id}"
response = requests.request("GET",url,auth=bearer_oauth,verify=False)
json_data = json.loads(response.content.decode("ascii"))


                        

require(httr)
library(jsonlite)

bearer_token <- BEARER_TOKEN
series_id <- SERIES_ID_ARRAY
headers <- c(`Authorization` = sprintf('Bearer %s', bearer_token))
url <- sprintf('https://database.mma.gov.mv/api/series?ids=%s',series_id)
response <- httr::GET(url = url, httr::add_headers(.headers = headers))
obj <- httr::content(response, as = "text")
document <- fromJSON(txt=obj)
print(document)