{"id":21426721,"url":"https://github.com/j535d165/cbsodata","last_synced_at":"2025-04-05T08:03:51.164Z","repository":{"id":54521315,"uuid":"76260632","full_name":"J535D165/cbsodata","owner":"J535D165","description":"Unofficial Statistics Netherlands (CBS) open data API client for Python","archived":false,"fork":false,"pushed_at":"2025-03-03T20:22:25.000Z","size":112,"stargazers_count":43,"open_issues_count":4,"forks_count":19,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-29T07:02:44.084Z","etag":null,"topics":["census-api","census-data","data","national-statistics","netherlands","open-data","python-library"],"latest_commit_sha":null,"homepage":"http://cbsodata.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/J535D165.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-12T13:53:18.000Z","updated_at":"2025-03-04T12:41:55.000Z","dependencies_parsed_at":"2022-08-13T18:31:05.434Z","dependency_job_id":"eb4ad86d-de98-4ed9-b72c-3b6baee7d267","html_url":"https://github.com/J535D165/cbsodata","commit_stats":{"total_commits":67,"total_committers":5,"mean_commits":13.4,"dds":0.5074626865671642,"last_synced_commit":"8ce73ed0cc386ca838d3e363c4d0959d7057344f"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J535D165%2Fcbsodata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J535D165%2Fcbsodata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J535D165%2Fcbsodata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J535D165%2Fcbsodata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/J535D165","download_url":"https://codeload.github.com/J535D165/cbsodata/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305932,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["census-api","census-data","data","national-statistics","netherlands","open-data","python-library"],"created_at":"2024-11-22T21:43:25.342Z","updated_at":"2025-04-05T08:03:51.140Z","avatar_url":"https://github.com/J535D165.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Statistics Netherlands opendata API client for Python\n\n[![pypi](https://badge.fury.io/py/cbsodata.svg)](https://badge.fury.io/py/cbsodata)\n[![tests](https://github.com/J535D165/cbsodata/workflows/tests/badge.svg)](https://github.com/J535D165/cbsodata/actions)\n\nRetrieve data from the [open data interface of Statistics\nNetherlands](http://www.cbs.nl/nl-NL/menu/cijfers/statline/open-data/default.htm)\n(Centraal Bureau voor de Statistiek) with *Python*. The data is\nidentical in content to the tables which can be retrieved and downloaded\nfrom [StatLine](http://statline.cbs.nl/). CBS datasets are accessed via\nthe [CBS open data\nportal](https://opendata.cbs.nl/statline/portal.html).\n\nThe documentation of this package is found at this page and on\n[readthedocs.io](http://cbsodata.readthedocs.io/).\n\nR user? Use\n[cbsodataR](https://cran.r-project.org/web/packages/cbsodataR/index.html).\n\n## Installation\n\nFrom PyPi\n\n``` sh\npip install cbsodata\n```\n\n## Usage\n\nLoad the package with\n\n``` python\n\u003e\u003e\u003e import cbsodata\n```\n\n### Tables\n\nStatistics Netherlands (CBS) has a large amount of public available data\ntables (more than 4000 at the moment of writing). Each table is\nidentified by a unique identifier (`Identifier`).\n\n``` python\n\u003e\u003e\u003e tables = cbsodata.get_table_list()\n\u003e\u003e\u003e print(tables[0])\n{'Catalog': 'CBS',\n 'ColumnCount': 18,\n 'DefaultPresentation': '_la=nl\u0026_si=\u0026_gu=\u0026_ed=LandVanUiteindelijkeZeggenschapUCI\u0026_td=Perioden\u0026graphType=line',\n 'DefaultSelection': \"$filter=((LandVanUiteindelijkeZeggenschapUCI eq '11111') or (LandVanUiteindelijkeZeggenschapUCI eq '22222')) and (Bedrijfsgrootte eq '10000') and (substringof('JJ',Perioden))\u0026$select=LandVanUiteindelijkeZeggenschapUCI, Bedrijfsgrootte, Perioden, FiscaalJaarloonPerBaan_15\",\n 'ExplanatoryText': '',\n 'Frequency': 'Perjaar',\n 'GraphTypes': 'Table,Bar,Line',\n 'ID': 0,\n 'Identifier': '82010NED',\n 'Language': 'nl',\n 'MetaDataModified': '2014-02-04T02:00:00',\n 'Modified': '2014-02-04T02:00:00',\n 'OutputStatus': 'Regulier',\n 'Period': '2008 t/m 2011',\n 'ReasonDelivery': 'Actualisering',\n 'RecordCount': 32,\n 'SearchPriority': '2',\n 'ShortDescription': '\\nDeze tabel bevat informatie over banen en lonen bij bedrijven in Nederland, uitgesplitst naar het land van uiteindelijke zeggenschap van die bedrijven. Hierbij wordt onderscheid gemaakt tussen bedrijven onder Nederlandse zeggenschap en bedrijven onder buitenlandse zeggenschap. In de tabel zijn alleen de bedrijven met werknemers in loondienst meegenomen. De cijfers hebben betrekking op het totale aantal banen bij deze bedrijven en de samenstelling van die banen naar kenmerken van de werknemers (baanstatus, geslacht, leeftijd, herkomst en hoogte van het loon). Ook het gemiddelde fiscale jaarloon per baan is in de tabel te vinden. \\n\\nGegevens beschikbaar vanaf: 2008 \\n\\nStatus van de cijfers: \\nDe cijfers in deze tabel zijn definitief.\\n\\nWijzigingen per 4 februari 2014\\nDe cijfers van 2011 zijn toegevoegd.\\n\\nWanneer komen er nieuwe cijfers?\\nDe cijfers over 2012 verschijnen in de eerste helft van 2015.\\n',\n 'ShortTitle': 'Zeggenschap bedrijven; banen, grootte',\n 'Source': 'CBS.',\n 'Summary': 'Banen en lonen van werknemers bij bedrijven in Nederland\\nnaar land van uiteindelijke zeggenschap en bedrijfsgrootte',\n 'SummaryAndLinks': 'Banen en lonen van werknemers bij bedrijven in Nederland\u003cbr /\u003enaar land van uiteindelijke zeggenschap en bedrijfsgrootte\u003cbr /\u003e\u003ca href=\"http://opendata.cbs.nl/ODataApi/OData/82010NED\"\u003ehttp://opendata.cbs.nl/ODataApi/OData/82010NED\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"http://opendata.cbs.nl/ODataFeed/OData/82010NED\"\u003ehttp://opendata.cbs.nl/ODataFeed/OData/82010NED\u003c/a\u003e',\n 'Title': 'Zeggenschap bedrijven in Nederland; banen en lonen, bedrijfsgrootte',\n 'Updated': '2014-02-04T02:00:00'}\n```\n\n### Info\n\nGet information about a table with the `get_info` function.\n\n``` python\n\u003e\u003e\u003e info = cbsodata.get_info('82070ENG') # Returns a dict with info\n\u003e\u003e\u003e info['Title']\n'Caribbean Netherlands; employed labour force characteristics 2012'\n\u003e\u003e\u003e info['Modified']\n'2013-11-28T15:00:00'\n```\n\n### Data\n\nThe function you are looking for!! The function `get_data` returns a\nlist of dicts with the table data.\n\n``` python\n\u003e\u003e\u003e data = cbsodata.get_data('82070ENG')\n[{'CaribbeanNetherlands': 'Bonaire',\n  'EmployedLabourForceInternatDef_1': 8837,\n  'EmployedLabourForceNationalDef_2': 8559,\n  'Gender': 'Total male and female',\n  'ID': 0,\n  'Periods': '2012',\n  'PersonalCharacteristics': 'Total personal characteristics'},\n {'CaribbeanNetherlands': 'St. Eustatius',\n  'EmployedLabourForceInternatDef_1': 2099,\n  'EmployedLabourForceNationalDef_2': 1940,\n  'Gender': 'Total male and female',\n  'ID': 1,\n  'Periods': '2012',\n  'PersonalCharacteristics': 'Total personal characteristics'},\n {'CaribbeanNetherlands': 'Saba',\n  'EmployedLabourForceInternatDef_1': 1045,\n  'EmployedLabourForceNationalDef_2': 971,\n  'Gender': 'Total male and female',\n  'ID': 2,\n  'Periods': '2012',\n  'PersonalCharacteristics': 'Total personal characteristics'},\n # ...\n]\n```\n\nThe keyword argument `dir` can be used to download the data directly to\nyour file system.\n\n``` python\n\u003e\u003e\u003e data = cbsodata.get_data('82070ENG', dir=\"dir_to_save_data\")\n```\n\n### Catalogs (dataderden)\n\nThere are multiple ways to retrieve data from catalogs other than\n'opendata.cbs.nl'. The code below shows 3 different ways to retrieve\ndata from the catalog 'dataderden.cbs.nl' (known from Iv3).\n\nOn module level.\n\n``` python\ncbsodata.options.catalog_url = 'dataderden.cbs.nl'\n# list tables\ncbsodata.get_table_list()\n# get dataset 47003NED\ncbsodata.get_data('47003NED')\n```\n\nWith context managers.\n\n``` python\nwith cbsodata.catalog('dataderden.cbs.nl'):\n    # list tables\n    cbsodata.get_table_list()\n    # get dataset 47003NED\n    cbsodata.get_data('47003NED')\n```\n\nAs a function argument.\n\n``` python\n# list tables\ncbsodata.get_table_list(catalog_url='dataderden.cbs.nl')\n# get dataset 47003NED\ncbsodata.get_data('47003NED', catalog_url='dataderden.cbs.nl')\n```\n\n### Pandas users\n\nThe package works well with Pandas. Convert the result easily into a\npandas DataFrame with the code below.\n\n``` python\n\u003e\u003e\u003e data = pandas.DataFrame(cbsodata.get_data('82070ENG'))\n\u003e\u003e\u003e data.head()\n```\n\nThe list of tables can be turned into a pandas DataFrame as well.\n\n``` python\n\u003e\u003e\u003e tables = pandas.DataFrame(cbsodata.get_table_list())\n\u003e\u003e\u003e tables.head()\n```\n\n## Command Line Interface\n\nThis library ships with a Command Line Interface (CLI).\n\n``` bash\n\u003e cbsodata -h\nusage: cbsodata [-h] [--version] [subcommand]\n\nCBS Open Data: Command Line Interface\n\npositional arguments:\n  subcommand  the subcommand (one of 'data', 'info', 'list')\n\noptional arguments:\n  -h, --help  show this help message and exit\n  --version   show the package version\n```\n\nDownload data:\n\n``` bash\n\u003e cbsodata data 82010NED\n```\n\nRetrieve table information:\n\n``` bash\n\u003e cbsodata info 82010NED\n```\n\nRetrieve a list with all tables:\n\n``` bash\n\u003e cbsodata list\n```\n\n### Export data\n\nUse the flag `-o` to load data to a file (JSON lines).\n\n``` bash\n\u003e cbsodata data 82010NED -o table_82010NED.jl\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj535d165%2Fcbsodata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj535d165%2Fcbsodata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj535d165%2Fcbsodata/lists"}