Python 3 API Client for Polish REGON database (Baza Internetowa Regon - BIR)
Project description
Installation
pip install RegonAPI
Example
All usage examples are available in examples directory
from pprint import pprint
from RegonAPI import RegonAPI
from RegonAPI.exceptions import ApiAuthenticationError
# Available reports
REPORTS = [
"BIR11OsFizycznaDaneOgolne",
"BIR11OsFizycznaDzialalnoscCeidg",
"BIR11OsFizycznaDzialalnoscRolnicza",
"BIR11OsFizycznaDzialalnoscPozostala",
"BIR11OsFizycznaDzialalnoscSkreslonaDo20141108",
"BIR11OsFizycznaPkd",
"BIR11OsFizycznaListaJednLokalnych",
"BIR11JednLokalnaOsFizycznej",
"BIR11JednLokalnaOsFizycznejPkd",
"BIR11OsPrawna",
"BIR11OsPrawnaPkd",
"BIR11OsPrawnaListaJednLokalnych",
"BIR11JednLokalnaOsPrawnej",
"BIR11JednLokalnaOsPrawnejPkd",
"BIR11OsPrawnaSpCywilnaWspolnicy",
"BIR11TypPodmiotu",
]
TEST_API_KEY = "abcde12345abcde12345"
CD_PROJEKT_NIP = "7342867148"
CD_PROJEKT_KRS = "0000006865"
CD_PROJEKT_REGON9 = "492707333"
# Authentication
api = RegonAPI(
bir_version="bir1.1", is_production=False, timeout=10, operation_timeout=10
)
try:
api.authenticate(key=TEST_API_KEY)
except ApiAuthenticationError as e:
print("[-]", e)
exit(0)
except Exception as e:
raise
# Search by NIP
result = api.searchData(nip=CD_PROJEKT_NIP)
pprint(result)
# Search by KRS
result = api.searchData(krs=CD_PROJEKT_KRS)
pprint(result)
# Search by REGON
result = api.searchData(regon=CD_PROJEKT_REGON9)
pprint(result)
# Get all reports by REGON
for report_name in REPORTS:
result = api.dataDownloadFullReport(CD_PROJEKT_REGON9, report_name)
print("\n[*] Report:\n", report_name)
pprint(result)
# Group reports
GROUP_REPORTS = [
"BIR11NowePodmiotyPrawneOrazDzialalnosciOsFizycznych",
"BIR11AktualizowanePodmiotyPrawneOrazDzialalnosciOsFizycznych",
"BIR11SkreslonePodmiotyPrawneOrazDzialalnosciOsFizycznych",
"BIR11NoweJednostkiLokalne",
"BIR11AktualizowaneJednostkiLokalne",
"BIR11SkresloneJednostkiLokalne",
]
# It's better to fetch group reports using your own API key
print("\n[!] It's better to fetch group reports using your own API key")
exit(0)
for group_report_name in GROUP_REPORTS:
result = api.dataDownloadFullGroupReport("2021-04-16", group_report_name)
print("\n[*] Group Report:\n", group_report_name)
pprint(result)
Result of the above code
... truncated ...
[{'praw_adSiedzGmina_Nazwa': 'Praga-Północ',
'praw_adSiedzGmina_Symbol': '088',
'praw_adSiedzKodPocztowy': '03301',
'praw_adSiedzKraj_Nazwa': 'POLSKA',
'praw_adSiedzKraj_Symbol': 'PL',
'praw_adSiedzMiejscowoscPoczty_Nazwa': 'Warszawa',
'praw_adSiedzMiejscowoscPoczty_Symbol': '0919298',
'praw_adSiedzMiejscowosc_Nazwa': 'Warszawa',
'praw_adSiedzMiejscowosc_Symbol': '0919298',
... truncated ...
'praw_formaFinansowania_Symbol': '1',
'praw_formaWlasnosci_Nazwa': 'WŁASNOŚĆ PRYWATNA KRAJOWA POZOSTAŁA',
'praw_formaWlasnosci_Symbol': '215',
'praw_jednostekLokalnych': '0',
'praw_nazwa': 'CD PROJEKT SPÓŁKA AKCYJNA',
'praw_nazwaSkrocona': 'CD PROJEKT S.A.',
'praw_nip': '7342867148',
... truncated ...
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
RegonAPI-1.3.1.tar.gz
(16.5 kB
view details)
Built Distribution
RegonAPI-1.3.1-py3-none-any.whl
(20.4 kB
view details)
File details
Details for the file RegonAPI-1.3.1.tar.gz
.
File metadata
- Download URL: RegonAPI-1.3.1.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57cdf93f9fe548685ca5958892316979b9c937b82f49eebb417372053a6520b8 |
|
MD5 | 60203fd7d48ab7659b719ba6fdb9f5bc |
|
BLAKE2b-256 | a4cc9321a1db7aa602252de8d81124f43ee98167936261287271351aa21864de |
File details
Details for the file RegonAPI-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: RegonAPI-1.3.1-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 429467829a63830426ed0bbee629e835c6f5b75e33544b8f6256e07b37374d8d |
|
MD5 | 8e698c7c8af6d6ff799efb8f198e31b3 |
|
BLAKE2b-256 | 45b722038438ddb3ff823c8e152908fae4a76a2e66aeb0a5e081299b3260a96c |