The derapi Python SDK provides access to the Derapi API for Python
applications -- fully typed with async support.
The SDK closely mirrors our API, so the API documentation is a helpful reference when using it in your project.
pip install derapiimportosimporthttpxfromderapiimportAuthenticatedClientdefinit_client() ->AuthenticatedClient:
token_resp=httpx.post(
"https://auth.derapi.com/oauth2/token",
auth=(os.environ["DERAPI_CLIENT_ID"], os.environ["DERAPI_CLIENT_SECRET"]),
data={"grant_type": "client_credentials"},
)
token_resp.raise_for_status()
token=token_resp.json()["access_token"]
returnAuthenticatedClient(
base_url="https://api.derapi.com",
raise_on_unexpected_status=True,
token=token,
)Example: Retrieve a list of Sites synchronously, iterating through all pages of results automatically
...
fromderapi.api.sitesimportlist_sitesclient=init_client()
forsiteinlist_sites.sync_depaginated(client=client):
print(site.id)derapi is distributed under the terms of the MIT license.