Skip to content

derapi/derapi-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

derapi

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.

PyPI - Version PyPI - Python Version


Table of Contents

Installation

pip install derapi

Usage

Client initialization

import os

import httpx
from derapi import AuthenticatedClient

def init_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"]
    return AuthenticatedClient(
        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

...

from derapi.api.sites import list_sites

client = init_client()

for site in list_sites.sync_depaginated(client=client):
    print(site.id)

License

derapi is distributed under the terms of the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages