Skip to content

Some support functions for calling SSB StatBank API

License

Notifications You must be signed in to change notification settings

sehyoun/SSB_API_helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSB_API_helper

Writing the "query" statement to make an API call to StatBank of Statistics Norway (SSB) can be quite annoying. The functions here help forming the query string by pre-populating the query with available variables.

Usage

To get table 09189, one need to call

df_gdp = ssb_get_table('09189')

This acquires the entire table and returns it as a pandas dataframe. One can alternately call

available_vars = ssb_get_var_info('09189')

to get a dict of available variables, and then feed in updated available_var to ssb_get_table to get a subset of the available variables.

available_vars = ssb_get_var_info('09189')
# After editing available_vars
dg_gdp = ssb_get_table('09189', vars_cell = available_vars)

One can also download the table in separate chunks and put a wait time between API call by setting n_step and wait_time.

Lastly, though this is a thin wrapper around pandas.pivot function, I frequently rotate the result dataframe with

df_gdp = ssb_rotate_table(df_gdp)

to get wide table with years (ind) as indices.

Todo:

  • Separate example files

About

Some support functions for calling SSB StatBank API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages