Package: atokaconn
atokaconnis a python package that allows connections to and data extractions from theATOKAAPI 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/.InstallationPython versions from 3.6 are supported.The package is hosted on pypi, and can be installed, for example using pip:pip install atokaconnUsageOnce a key has been obtained from ATOKA's service (you need to pay for this), thenfrom 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 avery limited set of public methodsthat facilitate
accessing only part of all available information.Seehttps://gitlab.com/spaziodati/atoka-clifor a go-based CLI implementation.See the Contributing section to increase coverage.get_person_from_tax_idGets 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_taxIdssearch_personRetrieves a single person from ATOKA API, starting from its anagraphical data.
Raises Atoka exceptions if errors or no objects are found.personis 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_idsReturns a list of dictionaries, with persons corresponding to the passed atoka ids.get_people_from_tax_idsReturns a list of dictionaries, with persons corresponding to the passed tax idsget_companies_from_atoka_idsReturns a list of dictionaries, with companies corresponding to the passed atoka ids.get_companies_from_tax_idsReturns a list of dictionaries, with companies corresponding to the passed tax ids.get_roles_from_atoka_idsReturns all people in companies with given atoka ids, used to extract people with roles in these companiesMost of the above methods are based on the internal genericget_items_from_ids, which usesposts_requests, in order to correctly build the multipartbatchpost request.When extracting roles, we hit a 50 items limit, and theextend_responsemethod must be used, in order to fetch
items when the returned count is greater than 50.SupportThere is no guaranteed support available, but authors will try to keep up with issues
and merge proposed solutions into the code base.Project StatusThis project is currently being developed by theOpenpolis Foundationand 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.ContributingIn order to contribute to this project:verify that python 3.6+ is being used (or usepyenv)verify or installpoetry, to handle packages and dependencies in a leaner way,
with respect to pip and requirementsclone the projectgit clone git@github.com:openpolis/atokaconn.gitinstall the dependencies in the virtualenv, withpoetry install,
this will also install the dev dependenciesdevelop and testcreate apull requestwait for the maintainers to review and eventually merge your pull request into the main repositoryTestingTests are under the tests folder, and can be launched withpytestRequests 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.htmlSyntax can be checked withflake8.Coverage and flake8 configurations are in their sections withinsetup.cfg.AuthorsGuglielmo Celata -guglielmo@openpolis.itLicensingThis package is released under an MIT License, see details in the LICENSE.txt file.