dados-gov-sdk


Namedados-gov-sdk JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/adrianolaselva/dados-gov-python-sdk.git
SummaryREST API of the Brazilian Federal Government Open Data Portal
upload_time2024-03-11 11:11:51
maintainer
docs_urlNone
authorAdriano M. La Selva
requires_python
licenseMIT
keywords python dados data api apis recursos resources swagger client sdk pygov swagger portal gov governo government federal brasil brazil api swagger abertos open open-data transparencia transparency utilitario utility colaborativo collaborative modulo module pacote package
VCS
bugtrack_url
requirements certifi six python_dateutil setuptools urllib3 requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # REST API of the Brazilian Federal Government Open Data Portal

[![Python package](https://github.com/adrianolaselva/dados-gov-python-sdk/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/adrianolaselva/dados-gov-python-sdk/actions/workflows/python-package.yml)
[![codecov](https://codecov.io/github/adrianolaselva/dados-gov-python-sdk/graph/badge.svg?token=1JFRLT3ZLM)](https://codecov.io/github/adrianolaselva/dados-gov-python-sdk)
[![PyPI Latest Release](https://img.shields.io/pypi/v/dados-gov-sdk.svg)](https://pypi.org/project/dados-gov-sdk/) 
![PyPI - Downloads](https://img.shields.io/pypi/dm/dados-gov-sdk)


dados.gov.br now manages the technological solution to improve the governance of federal investments in infrastructure, 
through monitoring and monitoring the execution of investments in Federal Government infrastructure projects. 
Optionally, other powers of the Union, States, Federal District and Municipalities may register investments in 
infrastructure with their own resources through a formal manifestation of their adhesion.

dados.gov.br, in addition to complying with various rulings from the Federal Court of Auditors, aims to meet society's 
demand for clear, updated and centralized information. Thus, it positively impacts the effectiveness of the execution 
of public policies and decision-making by managers, in addition to enabling social control through transparency.

The platform gathers information about the geolocation of investments and allows it to be integrated with other 
monitoring, control and inspection systems, thus optimizing citizens' access to information and strengthening 
transparency regarding the rational use of public resources.

For more information, visit: [https://www.gov.br/transferegov/pt-br/obrasgov/sobre](https://www.gov.br/transferegov/pt-br/obrasgov/sobre)

## Additional information

Python library created with the aim of contributing to the community, providing an alternative to facilitate the use of 
the Federal Government's APIs, thus making the column available for contributions aimed at maintaining and evolving this 
simple code base.

And last but not least, **please** use the information wisely and without political bias.

## How to install

To install the library use Python's `pip` package manager.

Below are some examples of how to install.

```shell
pip install dados-gov-sdk
```
> Example of installation from the latest available version

```shell
pip install dados-gov-sdk@1.1.0
```
> Installation example stating a specific version

## How to Get Token

Access the Brazilian Federal Government Portal with your access credentials using your CPF (Individual Person Registry). 
Access through the link [https://dados.gov.br/](https://dados.gov.br/).

Once logged in, generate an access token and that's it, you will already have the information at hand to access the 
APIs, have fun 🥳

## How To Use

To use, first have the access key on hand, once that is done, there are some ways to configure it for use, either 
directly through the `ApiClient(...)` instance or through environment variables.

Configuring through environment variables, simply set them according to the names of the [environment variable](#environment-variables) session, 
once this is done, simply instance the resources and use them.

Below are some examples.

```python
from dados_gov import Settings, ApiClient

settings = Settings(api_key='<YOUR_API_KEY>')
api_client = ApiClient(settings)
```
> This example shows a way to initialize an instance of ApiClient, note that in the Settings entity it is possible to 
  pass personalized settings, if this is not passed the default information will be accepted, and if they have been 
  defined through environment variables, they will replace the default settings

```python
import datetime

from dados_gov import Settings, ApiClient
from dados_gov.models import DatasetModel
from dados_gov.models.dataset_model import TagModel, ResourceModel, ThemeModel
from dados_gov.resources.dataset_api import DatasetApi

dataset = DatasetModel(id="e668f214-e24a-4eda-b0b6-3c73765615f6",
                       tittle="Dateset Tittle One",
                       description="Dateset Description One",
                       organization="Dateset Organization One",
                       licence="Dateset Licence One",
                       responsible="Dateset Responsible One",
                       email_responsible="Dateset Email Responsible One",
                       frequency="INVALIDO",
                       date_start_temporal_coverage=datetime.datetime.now(),
                       date_end_temporal_coverage=datetime.datetime.now(),
                       space_coverage="INVALIDO",
                       version="1.0.0",
                       space_coverage_value="10",
                       spatial_granularity="INVALIDO",
                       version_update=True,
                       visibility="INVALIDO",
                       approval_status="INVALIDO",
                       discontinued=True,
                       date_discontinuation=datetime.date.today(),
                       reuse=True,
                       themes=[
                           ThemeModel(name="Theme One", tittle="Description Theme One"),
                           ThemeModel(name="Theme Two", tittle="Description Theme Two"),
                       ],
                       tags=[
                           TagModel(id="teste_tag", name="tag_1"),
                           TagModel(id="teste_tag", name="tag_2"),
                           TagModel(id="teste_tag", name="tag_3"),
                       ],
                       resources=[
                           ResourceModel(id="e668f214-e24a-4eda-b0b6-3c73765615d3",
                                         tittle="Resource One",
                                         description="Description resource One",
                                         link="https://...",
                                         type="INVALIDO"),
                           ResourceModel(id="1b9ed187-70d0-4f92-be56-48be6b3d781c",
                                         tittle="Resource Two",
                                         description="Description resource Two",
                                         link="https://...",
                                         type="INVALIDO")
                       ])

api_client = ApiClient(Settings(api_key='<YOUR_API_KEY>'))
dataset_api = DatasetApi(api_client)

response = dataset_api.create(dataset)
```
> In this example we initialize an object of type Dataset and insert a new record

```python
from dados_gov import Settings, ApiClient
from dados_gov.resources.dataset_api import DatasetApi

api_client = ApiClient(Settings(api_key='<YOUR_API_KEY>'))
dataset_api = DatasetApi(api_client)

response = dataset_api.list(page=1)
```
> In this example we list all the datasets for page number one

**Obs: In this first version, the data returned is generic, in the future it will be deserialized into domain objects**

## Environment variables.

Environment variables are one of the ways to configure the library for use, so none of the parameters are mandatory, 
assuming that if not informed, it is expected that the `ApiClient(...)` class.

Below is a table containing the accepted environment variables.

| Name                 | Description  | Default              | Optional |
|----------------------|--------------|----------------------|----------|
| DATA_GOV_HOST        | API base URL | https://dados.gov.br | true     |
| DATA_GOV_API_KEY     | Access key   | null                 | true     |
| DATA_GOV_TIMEOUT     | Timeout      | 5000                 | true     |
| DATA_GOV_PROXY_HTTP  | Proxy HTTP   | null                 | true     |
| DATA_GOV_PROXY_HTTPS | Proxy HTTPS  | null                 | true     |

## References

- [https://dados.gov.br/](https://dados.gov.br/)
- [https://www.gov.br/transferegov/pt-br/obrasgov/sobre](https://www.gov.br/transferegov/pt-br/obrasgov/sobre)
- [Swagger](https://dados.gov.br/swagger-ui/index.html).




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/adrianolaselva/dados-gov-python-sdk.git",
    "name": "dados-gov-sdk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,dados,data,api,apis,recursos,resources,swagger,client,sdk,pygov,swagger,portal,gov,governo,government,federal,brasil,brazil,api,swagger,abertos,open,open-data,transparencia,transparency,utilitario,utility,colaborativo,collaborative,modulo,module,pacote,package",
    "author": "Adriano M. La Selva",
    "author_email": "adrianolaselva@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/96/cf/9cb412c8233f1d07e94f9d987b0199478db9ae527db6e5ad9a9a7806d159/dados-gov-sdk-1.1.0.tar.gz",
    "platform": null,
    "description": "# REST API of the Brazilian Federal Government Open Data Portal\n\n[![Python package](https://github.com/adrianolaselva/dados-gov-python-sdk/actions/workflows/python-package.yml/badge.svg?branch=master)](https://github.com/adrianolaselva/dados-gov-python-sdk/actions/workflows/python-package.yml)\n[![codecov](https://codecov.io/github/adrianolaselva/dados-gov-python-sdk/graph/badge.svg?token=1JFRLT3ZLM)](https://codecov.io/github/adrianolaselva/dados-gov-python-sdk)\n[![PyPI Latest Release](https://img.shields.io/pypi/v/dados-gov-sdk.svg)](https://pypi.org/project/dados-gov-sdk/) \n![PyPI - Downloads](https://img.shields.io/pypi/dm/dados-gov-sdk)\n\n\ndados.gov.br now manages the technological solution to improve the governance of federal investments in infrastructure, \nthrough monitoring and monitoring the execution of investments in Federal Government infrastructure projects. \nOptionally, other powers of the Union, States, Federal District and Municipalities may register investments in \ninfrastructure with their own resources through a formal manifestation of their adhesion.\n\ndados.gov.br, in addition to complying with various rulings from the Federal Court of Auditors, aims to meet society's \ndemand for clear, updated and centralized information. Thus, it positively impacts the effectiveness of the execution \nof public policies and decision-making by managers, in addition to enabling social control through transparency.\n\nThe platform gathers information about the geolocation of investments and allows it to be integrated with other \nmonitoring, control and inspection systems, thus optimizing citizens' access to information and strengthening \ntransparency regarding the rational use of public resources.\n\nFor more information, visit: [https://www.gov.br/transferegov/pt-br/obrasgov/sobre](https://www.gov.br/transferegov/pt-br/obrasgov/sobre)\n\n## Additional information\n\nPython library created with the aim of contributing to the community, providing an alternative to facilitate the use of \nthe Federal Government's APIs, thus making the column available for contributions aimed at maintaining and evolving this \nsimple code base.\n\nAnd last but not least, **please** use the information wisely and without political bias.\n\n## How to install\n\nTo install the library use Python's `pip` package manager.\n\nBelow are some examples of how to install.\n\n```shell\npip install dados-gov-sdk\n```\n> Example of installation from the latest available version\n\n```shell\npip install dados-gov-sdk@1.1.0\n```\n> Installation example stating a specific version\n\n## How to Get Token\n\nAccess the Brazilian Federal Government Portal with your access credentials using your CPF (Individual Person Registry). \nAccess through the link [https://dados.gov.br/](https://dados.gov.br/).\n\nOnce logged in, generate an access token and that's it, you will already have the information at hand to access the \nAPIs, have fun \ud83e\udd73\n\n## How To Use\n\nTo use, first have the access key on hand, once that is done, there are some ways to configure it for use, either \ndirectly through the `ApiClient(...)` instance or through environment variables.\n\nConfiguring through environment variables, simply set them according to the names of the [environment variable](#environment-variables) session, \nonce this is done, simply instance the resources and use them.\n\nBelow are some examples.\n\n```python\nfrom dados_gov import Settings, ApiClient\n\nsettings = Settings(api_key='<YOUR_API_KEY>')\napi_client = ApiClient(settings)\n```\n> This example shows a way to initialize an instance of ApiClient, note that in the Settings entity it is possible to \n  pass personalized settings, if this is not passed the default information will be accepted, and if they have been \n  defined through environment variables, they will replace the default settings\n\n```python\nimport datetime\n\nfrom dados_gov import Settings, ApiClient\nfrom dados_gov.models import DatasetModel\nfrom dados_gov.models.dataset_model import TagModel, ResourceModel, ThemeModel\nfrom dados_gov.resources.dataset_api import DatasetApi\n\ndataset = DatasetModel(id=\"e668f214-e24a-4eda-b0b6-3c73765615f6\",\n                       tittle=\"Dateset Tittle One\",\n                       description=\"Dateset Description One\",\n                       organization=\"Dateset Organization One\",\n                       licence=\"Dateset Licence One\",\n                       responsible=\"Dateset Responsible One\",\n                       email_responsible=\"Dateset Email Responsible One\",\n                       frequency=\"INVALIDO\",\n                       date_start_temporal_coverage=datetime.datetime.now(),\n                       date_end_temporal_coverage=datetime.datetime.now(),\n                       space_coverage=\"INVALIDO\",\n                       version=\"1.0.0\",\n                       space_coverage_value=\"10\",\n                       spatial_granularity=\"INVALIDO\",\n                       version_update=True,\n                       visibility=\"INVALIDO\",\n                       approval_status=\"INVALIDO\",\n                       discontinued=True,\n                       date_discontinuation=datetime.date.today(),\n                       reuse=True,\n                       themes=[\n                           ThemeModel(name=\"Theme One\", tittle=\"Description Theme One\"),\n                           ThemeModel(name=\"Theme Two\", tittle=\"Description Theme Two\"),\n                       ],\n                       tags=[\n                           TagModel(id=\"teste_tag\", name=\"tag_1\"),\n                           TagModel(id=\"teste_tag\", name=\"tag_2\"),\n                           TagModel(id=\"teste_tag\", name=\"tag_3\"),\n                       ],\n                       resources=[\n                           ResourceModel(id=\"e668f214-e24a-4eda-b0b6-3c73765615d3\",\n                                         tittle=\"Resource One\",\n                                         description=\"Description resource One\",\n                                         link=\"https://...\",\n                                         type=\"INVALIDO\"),\n                           ResourceModel(id=\"1b9ed187-70d0-4f92-be56-48be6b3d781c\",\n                                         tittle=\"Resource Two\",\n                                         description=\"Description resource Two\",\n                                         link=\"https://...\",\n                                         type=\"INVALIDO\")\n                       ])\n\napi_client = ApiClient(Settings(api_key='<YOUR_API_KEY>'))\ndataset_api = DatasetApi(api_client)\n\nresponse = dataset_api.create(dataset)\n```\n> In this example we initialize an object of type Dataset and insert a new record\n\n```python\nfrom dados_gov import Settings, ApiClient\nfrom dados_gov.resources.dataset_api import DatasetApi\n\napi_client = ApiClient(Settings(api_key='<YOUR_API_KEY>'))\ndataset_api = DatasetApi(api_client)\n\nresponse = dataset_api.list(page=1)\n```\n> In this example we list all the datasets for page number one\n\n**Obs: In this first version, the data returned is generic, in the future it will be deserialized into domain objects**\n\n## Environment variables.\n\nEnvironment variables are one of the ways to configure the library for use, so none of the parameters are mandatory, \nassuming that if not informed, it is expected that the `ApiClient(...)` class.\n\nBelow is a table containing the accepted environment variables.\n\n| Name                 | Description  | Default              | Optional |\n|----------------------|--------------|----------------------|----------|\n| DATA_GOV_HOST        | API base URL | https://dados.gov.br | true     |\n| DATA_GOV_API_KEY     | Access key   | null                 | true     |\n| DATA_GOV_TIMEOUT     | Timeout      | 5000                 | true     |\n| DATA_GOV_PROXY_HTTP  | Proxy HTTP   | null                 | true     |\n| DATA_GOV_PROXY_HTTPS | Proxy HTTPS  | null                 | true     |\n\n## References\n\n- [https://dados.gov.br/](https://dados.gov.br/)\n- [https://www.gov.br/transferegov/pt-br/obrasgov/sobre](https://www.gov.br/transferegov/pt-br/obrasgov/sobre)\n- [Swagger](https://dados.gov.br/swagger-ui/index.html).\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "REST API of the Brazilian Federal Government Open Data Portal",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/adrianolaselva/dados-gov-python-sdk.git"
    },
    "split_keywords": [
        "python",
        "dados",
        "data",
        "api",
        "apis",
        "recursos",
        "resources",
        "swagger",
        "client",
        "sdk",
        "pygov",
        "swagger",
        "portal",
        "gov",
        "governo",
        "government",
        "federal",
        "brasil",
        "brazil",
        "api",
        "swagger",
        "abertos",
        "open",
        "open-data",
        "transparencia",
        "transparency",
        "utilitario",
        "utility",
        "colaborativo",
        "collaborative",
        "modulo",
        "module",
        "pacote",
        "package"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b6dbd99fd6468d556a88a967c8c970c0decd36c1d3ab8291de586e84ba5f6d46",
                "md5": "be7fe2c775c854cffd3c57199debe447",
                "sha256": "0d2149aa0a8a8044d0699dc3447f6741ff5ad7977f645ef5799ee3d3da8e5675"
            },
            "downloads": -1,
            "filename": "dados_gov_sdk-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "be7fe2c775c854cffd3c57199debe447",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 21216,
            "upload_time": "2024-03-11T11:11:49",
            "upload_time_iso_8601": "2024-03-11T11:11:49.783269Z",
            "url": "https://files.pythonhosted.org/packages/b6/db/d99fd6468d556a88a967c8c970c0decd36c1d3ab8291de586e84ba5f6d46/dados_gov_sdk-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "96cf9cb412c8233f1d07e94f9d987b0199478db9ae527db6e5ad9a9a7806d159",
                "md5": "eb2e6c5a5d0ac5df6f398e127ae08915",
                "sha256": "19dd1e57f737f6344001046d968f5ec3888727de040268f67a71840341f8b029"
            },
            "downloads": -1,
            "filename": "dados-gov-sdk-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "eb2e6c5a5d0ac5df6f398e127ae08915",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15467,
            "upload_time": "2024-03-11T11:11:51",
            "upload_time_iso_8601": "2024-03-11T11:11:51.447761Z",
            "url": "https://files.pythonhosted.org/packages/96/cf/9cb412c8233f1d07e94f9d987b0199478db9ae527db6e5ad9a9a7806d159/dados-gov-sdk-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-11 11:11:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "adrianolaselva",
    "github_project": "dados-gov-python-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "certifi",
            "specs": [
                [
                    ">=",
                    "14.05.14"
                ]
            ]
        },
        {
            "name": "six",
            "specs": [
                [
                    ">=",
                    "1.10"
                ]
            ]
        },
        {
            "name": "python_dateutil",
            "specs": [
                [
                    ">=",
                    "2.5.3"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    ">=",
                    "21.0.0"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    ">=",
                    "1.15.1"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.31.0"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "dados-gov-sdk"
}
        
Elapsed time: 0.20593s