apitalker package

Submodules

apitalker.api module

class apitalker.api.API(api_key: str)[source]

Bases: requests.sessions.Session

API class for connection and getting data from Apitalks API resources.

__init__(api_key: str) → None[source]

Initializes the class.

Parameters:api_key (str) – api key. You need to register to Apitalks (free) to get it
base_url = 'https://api.apitalks.store'
default_skip = 0
get_data(resource: str, order=None, where=None, **kwargs) → Tuple[apitalker.data.Data, Union[None, apitalker.api.ApiError]][source]

Get all available data from given API <resource>. Utilizes api.API.query() method. Sends API calls with incremented <skip> parameter, until ApiResponse.data array is returned as []. Returns tuple. All fetched data are returned as instance of apitalker.data.Data class. Error is either None or apitalker.api.ApiError.

In case API request fail and all data were not retrieved, method returns tuple with unsorted list of retrieved data so far, and apitalker.api.ApiError class instance of the request error.

Parameters:

resource (str) – API resource path

Keyword Arguments:
 
  • order (Union[None, str], optional) – order the returned data of !individual! API call. Defaults to None.
  • where (Union[None, str], optional) – filter the returned data. Defaults to None.
  • sleep (Union[None, int], optional) – set in seconds, how long should method wait between each api call. Defaults to None.
  • limit (int) – add limit to set limit for one page of returned data via api call. Defaults to max_limit.
  • skip (int) – add skip to set number of skipped data entries via api call. Defaults to default_skip.

Method can use same keyword arguments as api.API.query(). For details refer to that method.

Returns:Tuple[apitalker.data.Data, Union[None, apitalker.api.ApiError]]
max_limit = 30
query(resource: str, order=None, where=None, **kwargs) → Union[apitalker.api.ApiResponse, apitalker.api.ApiError, int][source]

Queries API for data from <resource>. See https://www.api.store/czso.cz/dokumentace#section/Query-parametry

Parameters:

resource (str) – API resource path as specified in Apitalks documentation

Keyword Arguments:
 
  • order (str) – order output of returned data of api call. e.g order=‘“id ASC, nazev DESC”’.
  • where (str) – specify filtering of the returned data of api call. e.g. where=‘“rok”:{“gt”:2000}’ or where=‘“rok=2000,”barva”:”red”’
  • limit (int) – add limit to set limit for one page of returned data via api call. Defaults to max_limit.
  • skip (int) – add skip to set number of skipped data entries via api call. Defaults to default_skip.
Returns:

(Union[ApiResponse, ApiError, int])
  • ApiResponse: class instance with attributes of successfull API call
  • ApiError: class instance with attributes of unsuccessfull API call
  • int: 1, if some other bad stuff happened

class apitalker.api.ApiError(resource=None, response=None, error=None, status_code=None, name=None, message=None)[source]

Bases: object

Class for data response error return of API resource call.

__init__(resource=None, response=None, error=None, status_code=None, name=None, message=None) → None[source]

Initializes instance of the class.

Keyword Arguments:
 
  • resource (Union[None, str], optional) – full resource url.
  • response (Union[None, Dict[str, Dict[str, Any]]], optional) – complete response message as dict. Defaults to None.
  • error (Union[None, Dict[str, Any]], optional) – error part of the respone message as dict. Defaults to None.
  • status_code (Union[None, int], optional) – status code part of the response message. Defaults to None.
  • name (Union[None, str], optional) – name of the error message. Defaults to None.
  • message (Union[None, str], optional) – body of the error message. Defaults to None.
class apitalker.api.ApiResponse(resource=None, response=None, data=None, skip=None, count=None, limit=None, info=None, provider=None)[source]

Bases: object

Class for data response of API resource call.

__init__(resource=None, response=None, data=None, skip=None, count=None, limit=None, info=None, provider=None) → None[source]

Initializes instance of the class.

Keyword Arguments:
 
  • resource (Union[None, str], optional) – full resource url.
  • response (Union[None, Dict[str, List[Any]]], optional) – complete response from api call as dict. Defaults to None.
  • data (Union[None, Iterable[Any]], optional) – only data from response from api call as list. Defaults to None.
  • skip (Union[None, int], optional) – value of skipped pages. Defaults to None.
  • count (Union[None, int], optional) – value of count. Defaults to None.
  • limit (Union[None, int], optional) – value of limit. Defaults to None.
  • info (Union[None, Dict[str, str]], optional) – value of info. Defaults to None.
  • provider (Union[None, str], optional) – value of data provider. Defaults to None.

apitalker.data module

class apitalker.data.Data(data: List[Any])[source]

Bases: object

Class for handling data returned by using apitalker.api.API.get_data() method.

__init__(data: List[Any]) → None[source]

Initializes instance of the class.

Parameters:data (List[Any]) – data retrieved from Apitalks API data resource.
as_list

original data retrieved from Api resource

Type:List[Any]
as_dataframe

data as pandas DataFrame object, converted using pandas._json_normalize(). You can then use various methods, which pandas.DataFrame class provides, e.g. for saving data in various file types.

Type:pandas.Dataframe

Examples

>>> from apitalker.api import API
>>>
>>> api = API("yourapikey")
>>>
>>> data, error = api.get_data("/path/to/resource/", **kwargs)
>>>
>>> if error is None:
>>>     data.as_dataframe.to_json()
>>>     data.as_dataframe.to_csv()
to_dataframe(data=None, **kwargs) → Union[pandas.core.frame.DataFrame, bool][source]

Converts data to DataFrame.

Keyword Arguments:
 
  • data (Union[None, Any]) – data to normalize and convert into pandas.core.frame.DataFrame
  • kwargs – keyword args to pass to pandas _json.normalize() function, which does the normalization and conversion to DataFrame. See References for link.
Returns:

Union[pandas.core.frame.DataFrame, bool]
  • pandas.core.frame.DataFrame: converted API data to pandas DataFrame, if normalization of data was successful. If data cannot be normalized, returns empty DataFrame.
  • False: if normalization raises an Exception. Can happen, if data have deeply nested and irregular structure.

References

json_normalize: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html#pandas-json-normalize

apitalker.resources module

This module provides convenient mappings of currently existing API resources provided by Apitalks.

Resources are mapped using classes, to be able to use . [dot] notation (and IntelliSense of IDE of your choice.)

All resources were NOT tested to be functional. They were just taken from the documentation.

Example:

from apitalker.api import API
from apitalker.resources import Czso

api = API("yourapikey")

data, error = api.get_data(Czso.ciselniky_kraj)

if error is None:
    print(data.as_dataframe.head)
class apitalker.resources.AdminOfLandSurveyingAndCadastre[source]

Bases: object

Class for mapping API resources of State Administration of Land Surveying and Cadastre (CUZSK) provided by Apitalks.

References

https://www.api.store/cuzk.cz/ (in czech language)

adresni_mista = '/cuzk.cz/adresni-mista-cr'
adresni_mista_vazby_na_skladebnost = '/cuzk.cz/adresni-mista-vazby-cr'
vazby_katastru_na_obce = '/cuzk.cz/vazby-katastr-uzemi-cr'
vazby_na_puvodni_cleneni_okresu = '/cuzk.cz/vazby-okresy-cr'
vazby_praha = '/cuzk.cz/vazby-hlm-praha'
vazby_ulice_obce = '/cuzk.cz/vazby-ulice-obce-s-ulicni-siti'
vazby_uzemnich_prvku_na_statut_mesta = '/cuzk.cz/vazby-momc-statutarni-mesta'
vazby_v_cr = '/cuzk.cz/vazby-cr'
class apitalker.resources.AuthoritiesJurisdiction[source]

Bases: object

Class for mapping API resources of authorities territory jurisdiction provided by Apitalks.

References

https://www.api.store/spadovost/ (in czech language)

spadovost = '/spadovost'
class apitalker.resources.CzechBusinessInspection[source]

Bases: object

Class for mapping API resources of Czech Business Inspection (Ceska obchodni inspekce), provided by Apitalks.

References

https://www.api.store/coi/ (in czech language)

rizikove_weby = '/coi/rizikove-weby'
sankce = '/coi/sankce'
zajisteni = '/coi/zajisteni'
zakazy = '/coi/zakazy'
zamereni = '/coi/zamereni'
class apitalker.resources.CzechNationalBank[source]

Bases: object

Class for mapping API resources of Czech National Bank provided by Apitalks.

References

https://www.api.store/cnb.cz/ (in czech language)

banky_a_zahranicni_pobocky = '/cnb.cz/banky'
nebankovni_poskytovatele_spotr_uveru = '/cnb.cz/npsu'
samostatni_poskytovatele_spotr_uveru = '/cnb.cz/szsu'
smenarny = '/cnb.cz/smenarny'
vazani_zastupci = '/cnb.cz/vzsu'
zahr_zprostredkovatele_spotr_uveru = '/cnb.cz/zzsu'
zprostredkovatele_vazaneho_spotr_uveru = '/cnb.cz/zvsu'
class apitalker.resources.CzechPost[source]

Bases: object

Class for mapping API resources of Czech Post Office, provided by Apitalks.

References

https://www.api.store/ceskaposta.cz/dokumentace (in czech language)

adresovani_balik_expres = '/cpost.cz/adresovani-baliku-expres'
balikovny = '/cpost.cz/balikovny'
mista_bez_dorucovani = '/cpost.cz/bez-dorucovani'
mista_prevzeti_u_odesilatele = '/cpost.cz/mista-prevezeti-u-odesilatele'
mista_zkracene_dodani = '/cpost.cz/mista-zkracene-dodani'
mista_zkracene_dodani_svatky = '/cpost.cz/mista-zkracene-dodani-svatky'
obce_s_adresni_psc = '/cpost.cz/obce-adresni-psc'
podani_balik_expres = '/cpost.cz/podani-baliku-expres'
podani_balik_nadrozmer = '/cpost.cz/podani-baliku-nadrozmer'
postovni_schranky = '/cpost.cz/postovni-schranky'
posty_info = '/cpost.cz/posty'
provozovny = '/cpost.cz/provozovny'
provozovny_podat_balik_na_postu = '/cpost.cz/podani-baliku-na-postu'
provozovny_s_baliky = '/cpost.cz/provozovny-balik'
provozovny_s_baliky_nad_30kg = '/cpost.cz/provozovny-balik-30kg'
provozovny_ulozit_balik_na_postu = '/cpost.cz/adresovani-baliku-na-postu'
psc = '/cpost.cz/psc'
psc_adresni = '/cpost.cz/adresni-psc'
psc_s_dorucovacim_pasmem = '/cpost.cz/psc-s-dorucovacim-pasmem'
roznasky_propagacnich_materialu_pocty = '/cpost.cz/pocty-RIPM'
roznasky_propagacnich_materialu_posty = '/cpost.cz/objednavka-RIPM'
ulozit_balik_nadrozmer = '/cpost.cz/ulozeni-baliku-nadrozmer'
class apitalker.resources.Czso[source]

Bases: object

Class for mapping API resources of Czech Statistical Office, provided by Apitalks.

References

https://www.api.store/czso.cz/dokumentace (in czech language)

ciselniky_kraj = '/czso.cz/kraj'
ciselniky_mestske_obvody_a_casti = '/czso.cz/mestsky-obvod-mestska-cast'
ciselniky_obce_a_ujezdy = '/czso.cz/obec-a-vojensky-ujezd'
ciselniky_okres = '/czso.cz/okres'
ciselniky_region_soudrznosti = '/czso.cz/region-soudrznosti'
ciselniky_spr_obv_praha = '/czso.cz/spravni-obvod-v-hlavnim-meste-praze'
ciselniky_spr_obv_s_rozsirenou_pusobnosti = '/czso.cz/spravni-obvody-obci-s-rozsirenou-pusobnosti'
ciselniky_stat = '/czso.cz/stat'
cizinci_dle_obcanstvi_veku_pohlavi = '/czso.cz/cizinci-podle-statniho-obcanstvi-veku-a-pohlavi'
hoste_a_prenocovani = '/czso.cz/hoste-a-prenocovani-v-hromadnych-ubytovacich-zarizenich-podle-zemi'
lide_domy_byty = '/czso.cz/lide-domy-byty'
nadeje_doziti = '/czso.cz/nadeje-doziti-v-okresech-a-spravnich-obvodech-orp'
obyvatele_sidelni_jednotky = '/czso.cz/obyvatele-sidelni-jednotky'
obyvatelstvo_domy = '/czso.cz/obyvatelstvo-domy'
pohyb_obyvatel = '/czso.cz/pohyb-obyvatel-za-cr-kraje-okresy-so-orp-a-obce'
prumerne_mzdy_odvetvi = '/czso.cz/prumerne-mzdy-odvetvi'
prumerne_spotrebitelske_ceny = '/czso.cz/prumerne-spotrebitelske-ceny-vybranych-vyrobku-potravinarske-vyrobky'
vyjizdky_zamestnani = '/czso.cz/vyjizdky-zamestnani'
class apitalker.resources.DataBoxes[source]

Bases: object

Class for mapping API resources of Data Boxes (Datove schranky), provided by Apitalks.

References

https://www.api.store/datove-schranky/ (in czech language)

datove_schranky = '/datove-schranky'
class apitalker.resources.EET[source]

Bases: object

Class for mapping API resources of Electronic Evidence of Revenue (EET) provided by Apitalks.

References

https://www.api.store/fs.mfcr.cz/ (in czech language)

ciselnik_cinnosti_provozoven = '/fs.mfcr.cz/ciselnik'
eet = '/fs.mfcr.cz/eet'
class apitalker.resources.EmployersInInsolvency[source]

Bases: object

Class for mapping API resources of Employers in Service sector of the economy provided by Apitalks.

References

https://www.api.store/sif/ (in czech language)

zamestnavatele_v_insolvenci = '/sif'
class apitalker.resources.EuropeanParliament[source]

Bases: object

Class for mapping API resources of European Parliament provided by Apitalks.

References

https://www.api.store/evropsky-parlament/ (in czech language)

clenove = '/meps'
class apitalker.resources.HealthServices[source]

Bases: object

Class for mapping API resources of Health Service (Zdravotni sluzby), provided by Apitalks.

References

https://www.api.store/zdravotni-sluzby/ (in czech language)

zdravotni_sluzby = '/zdravotni-sluzby'
class apitalker.resources.Jobs[source]

Bases: object

Class for mapping API resources of available jobs provided by Apitalks.

References

https://www.api.store/volna-pracovni-mista/ (in czech language)

volna_pracovni_mista = '/volna-pracovni-mista'
class apitalker.resources.Prague6[source]

Bases: object

Class for mapping API resources of Prague 6 provided by Apitalks.

References

https://www.api.store/praha6.cz/ (in czech language)

doprava_lokace = '/praha6.cz/traffic/locations'
kvalita_ovzdusi_data = '/praha6.cz/airtracker/data'
kvalita_ovzdusi_jednotky_mereni = '/praha6.cz/airtracker/measurement-units'
kvalita_ovzdusi_lokace = '/praha6.cz/airtracker/locations'
kvalita_ovzdusi_typ_senzoru = '/praha6.cz/airtracker/sensor-types'
kvalita_ovzdusi_typy_mereni = '/praha6.cz/airtracker/measurement-types'
typ_vozidla_detailni = '/praha6.cz/traffic/car-types-detail'
typ_vozidla_zjednoduseny = '/praha6.cz/traffic/car-types'
class apitalker.resources.PraguePublicTransportation[source]

Bases: object

Class for mapping API resources of Prague public transportation provided by Apitalks.

References

https://www.api.store/prazska-integrovana-doprava/ (in czech language)

zastavky = '/pid/zastavky'
class apitalker.resources.PublicAuthorities[source]

Bases: object

Class for mapping API resources of public authorities provided by Apitalks.

References

https://www.api.store/organy-verejne-moci/ (in czech language)

organy_verejne_moci = '/ovm'
class apitalker.resources.SUKL[source]

Bases: object

Class for mapping API resources of State Institue for Drug Control (SUKL) provided by Apitalks.

References

https://www.api.store/sukl.cz/ (in czech language)

atc_skupina_lp = '/sukl.cz/dlp-atc'
cesta_podani_lp = '/sukl.cz/dlp-cesty'
dodavky_atc_2011_2015 = '/sukl.cz/dodavky-lp-2011-2015'
dodavky_atc_2016 = '/sukl.cz/dodavky-atc-2016'
dodavky_atc_2017 = '/sukl.cz/dodavky-atc-2017'
dodavky_lp_1991_2000 = '/sukl.cz/dodavky-lp-1991-2000'
dodavky_lp_2001_2010 = '/sukl.cz/dodavky-lp-2001-2010'
dodavky_lp_2018 = '/sukl.cz/dodavky-lp-2018'
dokumenty_navazane_k_lp = '/sukl.cz/dlp-nazvydokumentu'
doping = '/sukl.cz/dlp-doping'
indikacni_skupina_lp = '/sukl.cz/dlp-indikacniskupiny'
informace_o_drziteli_prav_lp = '/sukl.cz/dlp-vpois'
jednotka_mnozstvi_latky = '/sukl.cz/dlp-jednotky'
kategorie_zavislosti_ll = '/sukl.cz/dlp-zavislost'
kod_soli_v_latce = '/sukl.cz/dlp-soli'
lecebny_program_mzcr = '/sukl.cz/dlp-splp'
lecive_pripravky_lp = '/sukl.cz/dlp-lecivepripravky'
lekarny_pracovni_doba = '/sukl.cz/lekarny-prac-doba'
lekarny_seznam = '/sukl.cz/lekarny-seznam'
lekarny_typ = '/sukl.cz/lekarny-typ'
lekova_forma_lp = '/sukl.cz/dlp-formy'
leky_s_anabolickym_ci_jinym_hormonalnim_ucinkem = '/sukl.cz/dlp-narvla'
nazev_latky = '/sukl.cz/dlp-latky'
nazev_lecive_latky = '/sukl.cz/dlp-lecivelatky'
nazev_obalu_lp = '/sukl.cz/dlp-obaly'
nazev_vyrobce_lp = '/sukl.cz/dlp-vyrobci'
nazev_zdroje_lp = '/sukl.cz/dlp-zdroje'
ochranne_prvky_ano = '/sukl.cz/ochranne-prvky-ano'
ochranne_prvky_ne = '/sukl.cz/ochranne-prvky-ne'
priznak_slozeni_lp = '/sukl.cz/dlp-slozenipriznak'
registracni_procedura_lp = '/sukl.cz/dlp-regproc'
slozeni_lp = '/sukl.cz/dlp-slozeni'
stav_registrace_lp = '/sukl.cz/dlp-stavyreg'
synonyma_latky_lp = '/sukl.cz/dlp-synonyma'
typ_vydeje_lp = '/sukl.cz/dlp-vydej'
zeme_vyroby_lp = '/sukl.cz/dlp-zeme'
zkratka_drzitel_registrace_vyrobce = '/sukl.cz/dlp-organizace'
class apitalker.resources.Schools[source]

Bases: object

Class for mapping API resources of schools provided by Apitalks.

References

https://www.api.store/skoly/ (in czech language)

skoly = '/skoly'

Module contents