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)