API
Posted: Mon May 02, 2016 1:37 am
Hi
Statistics Norway has now made available all its data through API. They have made examples of how to download data directly into programs such as
SAS:
proc http in=in out=out url="http://data.ssb.no/api/v0/no/table/07459"
method="post";
run;
and pyjstat
from pyjstat import pyjstat
import requests
from collections import OrderedDict
EXAMPLE_URL = 'http://data.ssb.no/api/v0/no/table/03024'
payload = {"query": [{"code": "VareGrupper2", "selection": {"filter": "item", "values": ["01", "02"] } }, {"code": "ContentsCode", "selection": {"filter": "item", "values": ["Vekt", "Kilopris"] } }, {"code": "Tid", "selection": {"filter": "top", "values": ["53"] } } ], "response": {"format": "json-stat"} }
data = requests.post(EXAMPLE_URL, json = payload)
results = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
# results[0].to_csv("03024.csv", sep=';', encoding='utf-8') # lagre .csv
print(results)
How can I import data directly into Eviews in a similar manner?
Thomas
Statistics Norway has now made available all its data through API. They have made examples of how to download data directly into programs such as
SAS:
proc http in=in out=out url="http://data.ssb.no/api/v0/no/table/07459"
method="post";
run;
and pyjstat
from pyjstat import pyjstat
import requests
from collections import OrderedDict
EXAMPLE_URL = 'http://data.ssb.no/api/v0/no/table/03024'
payload = {"query": [{"code": "VareGrupper2", "selection": {"filter": "item", "values": ["01", "02"] } }, {"code": "ContentsCode", "selection": {"filter": "item", "values": ["Vekt", "Kilopris"] } }, {"code": "Tid", "selection": {"filter": "top", "values": ["53"] } } ], "response": {"format": "json-stat"} }
data = requests.post(EXAMPLE_URL, json = payload)
results = pyjstat.from_json_stat(data.json(object_pairs_hook=OrderedDict))
# results[0].to_csv("03024.csv", sep=';', encoding='utf-8') # lagre .csv
print(results)
How can I import data directly into Eviews in a similar manner?
Thomas