A package that facilitates connections to and data extractions from the ATOKA API service.
Project description
atokaconn
is a python package that allows connections to and data extractions from the
ATOKA API service.
ATOKA is a service provided by SpazioDati (Cerved), based on companies' data from the Camera di Commercio.
An extensive introduction to these data's structure is available here: https://atoka.io/pages/en/data-structure/.
The API reference is available here: https://developers.atoka.io/v2/.
Installation
Python versions from 3.6 are supported.
The package is hosted on pypi, and can be installed, for example using pip:
pip install atokaconn
Usage
Once a key has been obtained from ATOKA's service (you need to pay for this), then
from atokaconn import AtokaConn
atoka_conn = AtokaConn(key=MYKEY)
atoka_p = atoka_conn.get_person_from_tax_id(tax_id)
ATOKA has an incredibly rich set of endpoints and filters, allowing a wide variety of usages for their API. This package implements a very limited set of public methods that facilitate accessing only part of all available information.
See https://gitlab.com/spaziodati/atoka-cli for a go-based CLI implementation.
See the Contributing section to increase coverage.
get_person_from_tax_id
Gets a single person, as a dict, from its tax_id. Raises one of the Atoka exceptions if errors are present or no persons are found. see: https://developers.atoka.io/v2/people.html#people_taxIds
search_person
Retrieves a single person from ATOKA API, starting from its anagraphical data. Raises Atoka exceptions if errors or no objects are found.
person
is an object instance of Popolo Person type to look for into ATOKA
Can be an instance of an object with these attributes:
- family_name,
- given_name,
- birth_date (YYYY[-MM][-DD])
- birth_location_area (object of Popolo Area type, an instance with a name attribute will do)
TODO: this is not generic enough, as OPDM/Popolo concepts creeps in. Must be generalized.
get_people_from_atoka_ids
Returns a list of dictionaries, with persons corresponding to the passed atoka ids.
get_people_from_tax_ids
Returns a list of dictionaries, with persons corresponding to the passed tax ids
get_companies_from_atoka_ids
Returns a list of dictionaries, with companies corresponding to the passed atoka ids.
get_companies_from_tax_ids
Returns a list of dictionaries, with companies corresponding to the passed tax ids.
get_roles_from_atoka_ids
Returns all people in companies with given atoka ids, used to extract people with roles in these companies
Most of the above methods are based on the internal generic get_items_from_ids
, which uses
posts_requests
, in order to correctly build the multipart batch post request.
When extracting roles, we hit a 50 items limit, and the extend_response
method must be used, in order to fetch
items when the returned count is greater than 50.
Support
There is no guaranteed support available, but authors will try to keep up with issues and merge proposed solutions into the code base.
Project Status
This project is currently being developed by the Openpolis Foundation and does only cover those parts of the ATOKA API that are needed in the Foundation's projects. Should more be needed, you can either ask to increase the coverage, or try to contribute, following instructions below.
Contributing
In order to contribute to this project:
- verify that python 3.6+ is being used (or use pyenv)
- verify or install poetry, to handle packages and dependencies in a leaner way, with respect to pip and requirements
- clone the project
git clone git@github.com:openpolis/atokaconn.git
- install the dependencies in the virtualenv, with
poetry install
, this will also install the dev dependencies - develop and test
- create a pull request
- wait for the maintainers to review and eventually merge your pull request into the main repository
Testing
Tests are under the tests folder, and can be launched with
pytest
Requests and responses from ATOKA's API are mocked, in order to avoid having to connect to the remote service during tests (slow and needs an API key).
Coverage is installed as a dev dependency and can be used to see how much of the package's code is covered by tests:
coverage run -m pytest
# sends coverage report to terminal
coverage report -m
# generate and open a web page with interactive coverage report
coverage html
open htmlcov/index.html
Syntax can be checked with flake8
.
Coverage and flake8 configurations are in their sections within setup.cfg
.
Authors
Guglielmo Celata - guglielmo@openpolis.it
Licensing
This package is released under an MIT License, see details in the LICENSE.txt file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file atokaconn-0.1.8.tar.gz
.
File metadata
- Download URL: atokaconn-0.1.8.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.4 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e897f93e11d36618c0bc54d7ba3d143cd6fae355a75702c54431ed0a50adc6f |
|
MD5 | 2dd855057e608ec6e37f54af37a3ee8a |
|
BLAKE2b-256 | e219086499e045a481df2a536982fbecf5ad0b0ecddbf483765e3ae436631a93 |
File details
Details for the file atokaconn-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: atokaconn-0.1.8-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.9.4 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2007a2f5a2ddaeb82671bd3fd995e6225c1ba75caf5d714711aba2a89c81f78f |
|
MD5 | 957ccf3be9e77aea7b020cb8dcedcd8f |
|
BLAKE2b-256 | c23c9dc36012aac2a7d1ca8aaccaa34f83d30e7be5b33f43ea2d2efe76118898 |