keyban_api_client
Keyban API Client
Python client for the Keyban DPP Passport API.
keyban_api_client.client
Keyban API Client
Python client for the Keyban DPP Passport API. Public surface is scoped to model-granularity passports for writes; reads (list/get) remain agnostic.
KeybanAPIError Objects
class KeybanAPIError(requests.HTTPError)
API error with structured details from the response body.
Attributes:
-
status_code- HTTP status code -
detail- Parsed JSON body. The backend emits RFC 7807 ProblemDetails ({status, title, detail, type, instance}); validation errors also include anerrorsarray.str(err) renders as
"HTTP \{code\} \{title\}: \{detail\}"so a simpleprint(err)gives the full diagnostic without digging into attributes.
PassportData Objects
class PassportData(BaseModel)
Dynamic passport data fields with optional field-level encryption.
Automatically converts Python date/datetime objects to ISO string format.
Example:
from datetime import date
data = PassportData( name="My product", manufacturing_date=date(2024, 6, 15), # auto -> "2024-06-15" )
create_encrypted
@classmethod
def create_encrypted(cls,
confidential_paths: Optional[List[str]] = None,
enc_algorithm: str = "sha256",
enc_key: Optional[str] = None,
**data) -> "PassportData"
Build PassportData with selected fields hashed or encrypted.
Arguments:
-
confidential_paths- Dot-notation paths to protect. -
enc_algorithm- "sha256" (one-way hash) or "aes-256-gcm" (reversible). -
enc_key- Base64-encoded 32-byte key; auto-generated if None for AES. -
**data- Passport data fields. -
WARNING- SHA256 is irreversible. Use "aes-256-gcm" if you need decryption.
encryption_key
@property
def encryption_key() -> Optional[str]
Return the encryption key used (if any).
Passport Objects
class Passport(BaseModel)
Keyban DPP Passport response (model / batch / item).
PassportListResponse Objects
class PassportListResponse(BaseModel)
Paginated list response.
FilterOperator Objects
class FilterOperator(BaseModel)
Filter operator for list_passports.
The value must already be a string in the format the backend expects for the target field (e.g. ISO 8601 for datetime fields, UUID string for application.id, "true"/"false" for booleans). See the backend field schema.
operator
'eq', 'contains', 'gt', 'lt', 'gte', 'lte', 'ne'
PassportClient Objects
class PassportClient()
Python client for the Keyban DPP Passport API (model granularity).
Read operations (list_passports, get_passport) are agnostic and return
passports of any granularity. Write operations are scoped to model level.
list_passports
def list_passports(filters: Optional[List[FilterOperator]] = None,
current_page: int = 1,
page_size: int = 10) -> PassportListResponse
List passports with optional filters and pagination.
get_passport
def get_passport(passport_id: UUID) -> Passport
Get a passport by ID.
create_passport_model
def create_passport_model(
*,
application: UUID,
network: str,
model_number: str,
data: Optional[Dict[str, Any]] = None,
certified_paths: Optional[List[str]] = None) -> Passport
Create a model-granularity passport.
Certification triggers automatically when data is provided.
update_passport_model
def update_passport_model(
passport_id: UUID,
*,
data: Optional[Dict[str, Any]] = None,
certified_paths: Optional[List[str]] = None) -> Passport
Update a model-granularity passport.
Re-certification triggers automatically when the certificate content changes.
close
def close()
Close the HTTP session.