Official Humanos API SDK for Python with automatic request signing and webhook verification
Project description
Humanos SDK for Python
Official Python SDK for the Humanos API. Provides automatic request signing, webhook verification and decryption, and full API access for credential management.
Features
- Automatic Request Signing - All API requests are signed with HMAC-SHA256
- Webhook Verification - Verify signatures and decrypt encrypted payloads
- Type Hints - Full type annotations with Pydantic models
- Simple API - Clean interface for all Humanos endpoints
Getting Started
1. Install the SDK
pip install humanos
2. Create an Account
Sign up at humanos.id and create your organization.
3. Get Your API Keys
In the Humanos Dashboard, go to Settings > API Keys and copy:
- API Key - Used to authenticate requests
- Signature Secret - Used to sign requests with HMAC-SHA256
4. Get Your Webhook Keys
In the Humanos Dashboard, go to Settings > Webhooks and copy:
- Webhook Signature Secret - Used to verify incoming webhook signatures
- Webhook Encryption Secret - Used to decrypt webhook payloads
- Webhook Encryption Salt - Used alongside the encryption secret
5. Initialize the Client
from humanos_sdk import HumanosClient, HumanosClientConfig
client = HumanosClient(HumanosClientConfig(
base_path="https://api.humanos.id",
api_key=os.environ["HUMANOS_API_KEY"],
signature_secret=os.environ["HUMANOS_SIGNATURE_SECRET"],
))
6. Make Your First API Call
Fetch all your credential requests:
response = client.requests.get_requests()
print(response.data)
Usage Examples
Create a Credential Request
Send a credential request to one or more contacts using pre-configured resources:
from humanos_sdk import GenerateRequestDto
request = client.requests.generate(GenerateRequestDto(
contacts=["user@example.com"],
security_level="CONTACT",
resources_ids=["your-resource-id"],
))
print("Request ID:", request.id)
print("Credentials:", request.credentials)
You can also use group IDs to include all resources in a group:
request = client.requests.generate(GenerateRequestDto(
contacts=["user@example.com"],
security_level="CONTACT",
group_ids=["your-group-id"],
))
Or provide inline credential data directly:
from humanos_sdk import CredentialDto, MandateDataDto, MandateDataDtoValue
request = client.requests.generate(GenerateRequestDto(
contacts=["user@example.com"],
security_level="CONTACT",
credentials=[
CredentialDto(
scope="onboarding",
type="JSON",
name="Service Agreement",
data=[
MandateDataDto(label="Company", type="string", value=MandateDataDtoValue("Acme Corp")),
MandateDataDto(label="Plan", type="string", value=MandateDataDtoValue("Enterprise")),
],
),
],
))
Receive Webhooks
Humanos sends webhook events when credentials are signed, identity checks complete, or OTPs fail. Payloads are encrypted and signed.
The SDK provides create_flask_webhook_handler which handles signature verification and payload decryption automatically:
from flask import Flask
from humanos_sdk import create_flask_webhook_handler, WebhookConfig
app = Flask(__name__)
webhook_config = WebhookConfig(
signature_secret=os.environ["HUMANOS_WEBHOOK_SIGNATURE_SECRET"],
encryption_secret=os.environ["HUMANOS_WEBHOOK_ENCRYPTION_SECRET"],
encryption_salt=os.environ["HUMANOS_WEBHOOK_ENCRYPTION_SALT"],
)
def on_webhook(payload):
print("Event type:", payload.get("eventType"))
event_type = payload.get("eventType")
if event_type == "credential":
print("Credential signed:", payload.get("requestId"))
elif event_type == "identity":
print("Identity verified:", payload.get("requestId"))
elif event_type == "otp.failed":
print("OTP failed:", payload.get("requestId"))
elif event_type == "test":
print("Test event received")
app.add_url_rule(
"/webhook",
"webhook",
create_flask_webhook_handler(webhook_config, on_webhook),
methods=["POST"],
)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=3000)
For local development, use ngrok to expose your server:
ngrok http 3000
Then set the ngrok URL (e.g. https://xxxx.ngrok-free.app/webhook) as your webhook URL in the Humanos Dashboard under Settings > Webhooks.
API Reference
Resources
# List resources
resources = client.resources.get_resources()
# List resource groups
groups = client.resources.get_groups()
Requests
# List requests
requests = client.requests.get_requests()
# Get request details
detail = client.requests.get_request_detail(request_id)
# Create a credential request
request = client.requests.generate(GenerateRequestDto(...))
# Cancel a request
client.requests.cancel_request(request_id)
# Resend OTP
client.requests.resend_otp(request_id, contact="user@example.com")
Users
from humanos_sdk import CreateSubjectDto, IdentityDto
# Create or update users
users = client.users.create([
CreateSubjectDto(
contact="user@example.com",
internal_id="your-internal-id",
identity=IdentityDto(
full_name="John Doe",
birth="1990-01-01",
doc_id="123456789",
country_alpha3="USA",
),
)
])
Credentials
# Get credential by ID
credential = client.credentials.get_credential(credential_id)
# Get credential with PDF
credential = client.credentials.get_credential(credential_id, include_pdf=True)
Error Handling
The SDK raises ApiException for failed requests. The exception includes the HTTP status and response body:
from humanos_sdk import ApiException
try:
request = client.requests.generate(GenerateRequestDto(...))
except ApiException as e:
print(f"Status: {e.status}")
print(f"Body: {e.body}")
except Exception as e:
print(f"Error: {e}")
Documentation
Support
- Email: tech@humanos.tech
License
MIT License - see LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file humanos-1.0.1.tar.gz.
File metadata
- Download URL: humanos-1.0.1.tar.gz
- Upload date:
- Size: 58.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71d92c978579ec8fcbbfc169f1cb7c6b35789195153d86740e9b3a8c77e981b4
|
|
| MD5 |
1c79407743273e954de5b5e71d9e7db2
|
|
| BLAKE2b-256 |
b02ca846bd43449a094ff10f8225ce8e4f6fac3790c85bc5bd89b064036eb547
|
Provenance
The following attestation bundles were made for humanos-1.0.1.tar.gz:
Publisher:
publish-python.yml on Humanos-App/humanos-sdks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
humanos-1.0.1.tar.gz -
Subject digest:
71d92c978579ec8fcbbfc169f1cb7c6b35789195153d86740e9b3a8c77e981b4 - Sigstore transparency entry: 1205471848
- Sigstore integration time:
-
Permalink:
Humanos-App/humanos-sdks@e3cae140ae42cc7389b76fb05c9449dc590bfe4e -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Humanos-App
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@e3cae140ae42cc7389b76fb05c9449dc590bfe4e -
Trigger Event:
release
-
Statement type:
File details
Details for the file humanos-1.0.1-py3-none-any.whl.
File metadata
- Download URL: humanos-1.0.1-py3-none-any.whl
- Upload date:
- Size: 136.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6bc5a8d5e229c917675212c5a3353e0ef7523c002ce0c7ff6fb1cda3a86ad97
|
|
| MD5 |
2dcfa7b0678f2fcf1b71556da4010568
|
|
| BLAKE2b-256 |
a6ce3bf01a414544b21a396dd7a9a08a47be7681d7b8592ec04a32c5d91f9716
|
Provenance
The following attestation bundles were made for humanos-1.0.1-py3-none-any.whl:
Publisher:
publish-python.yml on Humanos-App/humanos-sdks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
humanos-1.0.1-py3-none-any.whl -
Subject digest:
a6bc5a8d5e229c917675212c5a3353e0ef7523c002ce0c7ff6fb1cda3a86ad97 - Sigstore transparency entry: 1205471857
- Sigstore integration time:
-
Permalink:
Humanos-App/humanos-sdks@e3cae140ae42cc7389b76fb05c9449dc590bfe4e -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Humanos-App
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@e3cae140ae42cc7389b76fb05c9449dc590bfe4e -
Trigger Event:
release
-
Statement type: