# datagouv-python
[![PyPI version](https://badge.fury.io/py/datagouv-python.svg)](https://badge.fury.io/py/datagouv-python)
[![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/MaximePawlakFr/datagouv-python)
Unofficial python client for `data.gouv.fr`.
Official documentation is here:
https://guides.data.gouv.fr/guide-data.gouv.fr/api/reference.
Current API version supported = "1".
# Getting Started
```python
from datagouv import DatagouvClient
client = DatagouvClient(MY_API_KEY)
# Get a dataset
dataset = client.datasets.get(my_dataset_id)
dataset_resources = dataset.get('resources')
# Upload a new resource from a file
client.datasets.post_resource_file(my_dataset_id, filename)
# Update a resource file
client.datasets.put_resource_file(my_dataset_id, filename, resource_id)
# Update a resource
client.datasets.put_resource(my_dataset_id, resource)
```
## Download all resources to current directory
```python
from datagouv import ResourcesDownloader
# Get a dataset: https://meteo.data.gouv.fr/datasets/656dab84db1bdf627a40eaae
dataset_id = "656dab84db1bdf627a40eaae"
# Instanciate ResourcesDownloader
downloader = ResourcesDownloader(dataset_id)
# Download to current directory
downloader.download()
```
## Download only 'main' resources with "2024" in title
```python
from datagouv import ResourcesDownloader
# Get a dataset: https://meteo.data.gouv.fr/datasets/656dab84db1bdf627a40eaae
dataset_id = "656dab84db1bdf627a40eaae"
# Instanciate ResourcesDownloader
downloader = ResourcesDownloader(dataset_id, resource_types=["main"] ,title_regex="2024")
# Download to 'output_dir' directory
downloader.download("./output_dir")
```
---
# Development
```
poetry run start
poetry run black datagouv/
poetry run flake8
```
## Build and Publish
### Steps
```bash
poetry version # [patch, minor, major]
poetry install
# TODO: Update CHANGELOG
git commit -m "vX.X.X"
git tag vX.X.X
poetry build
poetry publish
git push --tags
git push
```
### Test
```bash
poetry run pytest
```
### Commands
```bash
poetry add pytest --group dev
poetry version
poetry version -s
poetry version [patch, minor, major]
```
```bash
poetry build
```
<!--
```
python -m build
python -m twine upload --config-file .pypirc -r testpypi dist/*
python -m twine upload --config-file .pypirc -r pypi dist/*
``` -->
#### Config
```bash
# test-pypi
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi MY_TOKEN
poetry publish -r test-pypi
# pypi
poetry config pypi-token.pypi MY_TOKEN
poetry publish
```
# Resources
- https://pypi.org/project/datagouv-python/
# Roadmap
- [ ] Handle /datasets routes
- [ ] Handle other routes
- /site
- /reuses
- /discussions
- /organizations
- /spatial
- /users
- /me
- /workers
- /tags
- /topics
- /posts
- /transfer
- /notifications
- /avatars
- /harvest
Raw data
{
"_id": null,
"home_page": "https://github.com/MaximePawlakFr/datagouv-python",
"name": "datagouv-python",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "open-data, opendata, government",
"author": "Maxime Pawlak",
"author_email": "maxime.pawlak@amatek.fr",
"download_url": "https://files.pythonhosted.org/packages/e5/73/b243a78c206fbf1c1c01b1f0997b5de1e4d7a297f7ecd5ea253a0de7bbeb/datagouv_python-0.1.5.tar.gz",
"platform": null,
"description": "# datagouv-python\n\n[![PyPI version](https://badge.fury.io/py/datagouv-python.svg)](https://badge.fury.io/py/datagouv-python)\n[![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/MaximePawlakFr/datagouv-python)\n\nUnofficial python client for `data.gouv.fr`.\n\nOfficial documentation is here:\nhttps://guides.data.gouv.fr/guide-data.gouv.fr/api/reference.\n\nCurrent API version supported = \"1\".\n\n# Getting Started\n\n```python\nfrom datagouv import DatagouvClient\n\nclient = DatagouvClient(MY_API_KEY)\n\n# Get a dataset\ndataset = client.datasets.get(my_dataset_id)\ndataset_resources = dataset.get('resources')\n\n# Upload a new resource from a file\nclient.datasets.post_resource_file(my_dataset_id, filename)\n\n# Update a resource file \nclient.datasets.put_resource_file(my_dataset_id, filename, resource_id)\n\n# Update a resource\nclient.datasets.put_resource(my_dataset_id, resource)\n```\n\n## Download all resources to current directory\n\n```python\nfrom datagouv import ResourcesDownloader\n\n# Get a dataset: https://meteo.data.gouv.fr/datasets/656dab84db1bdf627a40eaae\ndataset_id = \"656dab84db1bdf627a40eaae\"\n\n# Instanciate ResourcesDownloader\ndownloader = ResourcesDownloader(dataset_id)\n\n# Download to current directory\ndownloader.download()\n```\n\n## Download only 'main' resources with \"2024\" in title\n\n```python\nfrom datagouv import ResourcesDownloader\n\n# Get a dataset: https://meteo.data.gouv.fr/datasets/656dab84db1bdf627a40eaae\ndataset_id = \"656dab84db1bdf627a40eaae\"\n\n# Instanciate ResourcesDownloader\ndownloader = ResourcesDownloader(dataset_id, resource_types=[\"main\"] ,title_regex=\"2024\")\n\n# Download to 'output_dir' directory\ndownloader.download(\"./output_dir\")\n```\n\n---\n\n# Development\n\n```\npoetry run start\npoetry run black datagouv/\npoetry run flake8\n```\n\n## Build and Publish\n\n### Steps\n\n```bash\npoetry version # [patch, minor, major]\npoetry install\n# TODO: Update CHANGELOG\ngit commit -m \"vX.X.X\"\ngit tag vX.X.X\npoetry build\npoetry publish\ngit push --tags\ngit push\n```\n\n### Test\n```bash\npoetry run pytest\n```\n\n### Commands\n\n```bash\npoetry add pytest --group dev\n\npoetry version\npoetry version -s\n\npoetry version [patch, minor, major]\n```\n\n```bash\npoetry build\n```\n\n<!--\n```\npython -m build\n\npython -m twine upload --config-file .pypirc -r testpypi dist/*\npython -m twine upload --config-file .pypirc -r pypi dist/*\n``` -->\n\n#### Config\n\n```bash\n# test-pypi\npoetry config repositories.test-pypi https://test.pypi.org/legacy/\npoetry config pypi-token.test-pypi MY_TOKEN\n\npoetry publish -r test-pypi \n\n# pypi\npoetry config pypi-token.pypi MY_TOKEN\npoetry publish\n```\n\n# Resources\n\n- https://pypi.org/project/datagouv-python/\n\n# Roadmap\n\n- [ ] Handle /datasets routes\n- [ ] Handle other routes\n - /site\n - /reuses\n - /discussions\n - /organizations\n - /spatial\n - /users\n - /me\n - /workers\n - /tags\n - /topics\n - /posts\n - /transfer\n - /notifications\n - /avatars\n - /harvest\n",
"bugtrack_url": null,
"license": "GPL-3.0-or-later",
"summary": "Unofficial python client for `data.gouv.fr`",
"version": "0.1.5",
"project_urls": {
"Homepage": "https://github.com/MaximePawlakFr/datagouv-python",
"Repository": "https://github.com/MaximePawlakFr/datagouv-python"
},
"split_keywords": [
"open-data",
" opendata",
" government"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6aa238c1b2a3dea3244905cb3609516649096dc329b3ef5efd07aa28dee6ca43",
"md5": "0fed41a45e2dbe1eef324dcbce1470d5",
"sha256": "8db078aad1de13897eec503eeaad9d16f61e2ab12c1c01898c1330cd29f38a50"
},
"downloads": -1,
"filename": "datagouv_python-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0fed41a45e2dbe1eef324dcbce1470d5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 19602,
"upload_time": "2024-08-07T13:13:48",
"upload_time_iso_8601": "2024-08-07T13:13:48.769380Z",
"url": "https://files.pythonhosted.org/packages/6a/a2/38c1b2a3dea3244905cb3609516649096dc329b3ef5efd07aa28dee6ca43/datagouv_python-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e573b243a78c206fbf1c1c01b1f0997b5de1e4d7a297f7ecd5ea253a0de7bbeb",
"md5": "f7a05fa11282a594e61639875d4b0176",
"sha256": "d446412e409d42f555402d27201f18215ab055a41f5e885e22587ad29db1b4e3"
},
"downloads": -1,
"filename": "datagouv_python-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "f7a05fa11282a594e61639875d4b0176",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 18017,
"upload_time": "2024-08-07T13:13:50",
"upload_time_iso_8601": "2024-08-07T13:13:50.328764Z",
"url": "https://files.pythonhosted.org/packages/e5/73/b243a78c206fbf1c1c01b1f0997b5de1e4d7a297f7ecd5ea253a0de7bbeb/datagouv_python-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-07 13:13:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MaximePawlakFr",
"github_project": "datagouv-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "datagouv-python"
}