How to load API keys?

stamina

retry

<aside> 💡

Calmcode Diskcache is a joyful little library that uses Sqlite under the hood to act as a cache that is stored on disk. It comes with no dependencies and and its a very likeable tool to use to increase speed in API requests.

How to increase speed of requests?

</aside>

Aufruf einer Schnittstelle:

# api login test - check credentials first
checkUrl = "<https://www-genesis.destatis.de/genesisWS/rest/2020/helloworld/logincheck?username=>" \\
            +KENNUNG+ "&password=" +PASSWORT

response = requests.get(checkUrl, timeout=120)
response.json()

Aufrufen einer TB-API:

data = {
"variable 1": True,
"variable 2": 25000,
"variable 3": 15000,
"variable 4": 84,
....
"variable 5": True,
"variable 6": True,
"variable 7": 8000,
}

import requests
from requests.auth import HTTPBasicAuth
import base64

user = "test"
password = "test"

credentials = base64.b64encode(f"{user}:{password}".encode()).decode('utf-8')
headers = {'Authorization': 'Basic ' + credentials}
url = "https://name_of_service.ewu.oscp.easycredit.intern/api/v1/"

res = requests.post(url, headers=headers, json=data, verify=False)
print(res)