https://github.com/jvaleroliet/datosgobes
Manage data from Spain's open data portal (https://datos.gob.es/es/) easily. The library simplifies API access and streamlines workflows for Python users.
https://github.com/jvaleroliet/datosgobes
data datosgobes opendata python spain
Last synced: 5 months ago
JSON representation
Manage data from Spain's open data portal (https://datos.gob.es/es/) easily. The library simplifies API access and streamlines workflows for Python users.
- Host: GitHub
- URL: https://github.com/jvaleroliet/datosgobes
- Owner: jvaleroliet
- License: mit
- Created: 2024-07-04T15:13:14.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-16T16:01:09.000Z (about 1 year ago)
- Last Synced: 2025-08-27T22:27:07.082Z (10 months ago)
- Topics: data, datosgobes, opendata, python, spain
- Language: Python
- Homepage: https://pypi.org/project/datosgobes/
- Size: 38.1 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-spain - datosgobes - square&label=%E2%AD%90)](https://github.com/jvaleroliet/datosgobes/stargazers) [](https://github.com/jvaleroliet/datosgobes/commits/main) [](https://github.com/jvaleroliet/datosgobes) [](https://github.com/jvaleroliet/datosgobes/blob/main/LICENSE) [](https://datos.gob.es/) - Librería Python para gestionar datos del portal datos.gob.es. (Datos Abiertos y Estadísticas / Región de Murcia)
README
# datosgobes
## Introduction
datosgobes is a python library that provides a simple interface to access the open data API of [https://datos.gob.es/es/](https://datos.gob.es/es/). The package is designed to make it easy for users to retrieve and analyze data from the API.
It is inspired in the R library [rOpenSpain/opendataes](https://github.com/rOpenSpain/opendataes).
## Installation
You can install datosgobes using pip:
```python
pip install datosgobes
```
## Usage
Once installed, you can start using datosgobes by importing it in your python script:
```python
import datosgobes
```
First, you need to initialize the manager:
```python
manager = datosgobes.Manager()
```
Then, you can use the manager to search for datasets:
```python
datasets = manager.search_datasets('sanidad')
```
You can also retrieve a dataset by its identifier:
```python
dataset = manager.get_dataset('l01080193-resultados-absolutos-de-las-elecciones-al-parlamento-europeo-de-la-ciudad-de-barcelona')
```
Once you have a dataset, you can retrieve its metadata, title, description...:
```python
print(dataset.title)
print(dataset.description)
```
Each dataset can contain multiple distributions. They are stored in a list called `distributions`:
```python
print(dataset.distributions)
```
You can retrieve the data from a distribution by its list index:
```python
distribution = dataset.distribution[0]
```
The distribution is a class that contains information about the data, such as its title, description, format...:
```python
print(distribution.title)
print(distribution.description)
print(distribution.format)
```
Finally, you can retrieve the data from the distribution:
```python
data = distribution.data
```
The data is returned as a pandas DataFrame, if the format is recognized, or as a raw string otherwise.
You can use it as you wish.
## Collaboration
If you want to contribute to the project, you can fork the repository and submit a pull request. Please make sure to follow the coding standards and documentation guidelines.
## License
datosgobes is released under the MIT license.