| icon | python | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| layout |
|
The Walver SDK provides a convenient way to interact with the Walver API from your Python applications. It offers both synchronous and asynchronous clients for creating and managing wallet verification links.
Install the SDK using pip:
pip install walver-sdkYou can provide your API key in two ways:
-
Pass it directly when initializing the client:
from walver_sdk import Walver walver = Walver(api_key="your-api-key")
-
Set it as an environment variable in your
.envfile:WALVER_API_KEY=your-api-key
from walver_sdk import Walver walver = Walver() # Will use the API key from .env
By default, the client uses https://walver.io/. You can change this by passing the base_url parameter:
walver = Walver(
api_key="your-api-key",
base_url="https://your-custom-url.com"
)The default timeout is 10 seconds. You can change this by passing the timeout parameter:
walver = Walver(
api_key="your-api-key",
timeout=30 # 30 seconds timeout
)The Walver class provides synchronous methods for interacting with the API.
verification = walver.create_verification(
id="verification_123",
service_name="My Service",
chain="solana",
webhook="https://your-webhook-url.com/webhook",
secret="your-webhook-secret",
redirect_url="https://your-redirect-url.com",
one_time=True,
force_email_verification=True,
custom_fields=[
{
"id": "email",
"type": "email",
"name": "Email Address",
"required": True
}
]
)
verification_url = verification["verification_url"]| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | A unique identifier for the verification |
| service_name | string | Yes | The name of your service (shown to users) |
| chain | string | Yes | The blockchain to use (e.g., "solana", "ethereum") |
| internal_id | string | No | An optional internal ID for your reference |
| webhook | string | No | URL to call when verification is complete |
| expiration | string/datetime | No | When the verification link expires |
| secret | string | No | A secret key for webhook security |
| redirect_url | string | No | URL to redirect after verification |
| one_time | boolean | No | If true, the link can only be used once |
| folder_id | string | No | ID of a folder to associate with |
| custom_fields | list | No | List of custom fields to collect |
| token_gate | boolean | No | Enable token gating |
| token_address | string | No | Token address for gating (required if token_gate=True) |
| token_amount | number | No | Minimum token amount (required if token_gate=True) |
| is_nft | boolean | No | Whether the token is an NFT |
| force_email_verification | boolean | No | Require email verification via OTP |
| force_telegram_verification | boolean | No | Require Telegram verification |
| force_twitter_verification | boolean | No | Require Twitter verification |
| force_discord_verification | boolean | No | Require Discord verification |
folder = walver.create_folder(
name="My Folder",
description="A folder for organizing verifications",
custom_fields=[
{
"id": "discord",
"type": "discord",
"name": "Discord Username",
"required": True
}
]
)folders = walver.get_folders()folder = walver.get_folder(folder_id="folder_123")verifications = walver.get_folder_verifications(folder_id="folder_123")api_key = walver.create_api_key(
name="My API Key",
description="API key for production use"
)api_keys = walver.get_api_keys()walver.delete_api_key(api_key="key_123")The AsyncWalver class provides asynchronous methods for interacting with the API.
import asyncio
from walver_sdk import AsyncWalver
async def main():
# Initialize the client
walver = AsyncWalver(api_key="your-api-key")
# Create a verification
verification = await walver.create_verification(
id="verification_123",
service_name="My Service",
chain="solana"
)
print(verification)
# Run the async code
asyncio.run(main())The async client provides the same methods as the synchronous client, but with async/await syntax.
The SDK raises exceptions for various error conditions:
try:
verification = walver.create_verification(
id="verification_123",
service_name="My Service",
chain="solana",
token_gate=True # Missing token_address and token_amount
)
except ValueError as e:
print(f"Validation error: {e}")
except requests.HTTPError as e:
print(f"HTTP error: {e}")Common exceptions:
ValueError: Raised for client-side validation errorsrequests.HTTPError: Raised for server-side errorsrequests.Timeout: Raised when the request times out
When creating verifications, you can specify various types of custom fields:
| Type | Description |
|---|---|
| text | Simple text input |
| Email address with validation | |
| url | URL with validation |
| Twitter handle | |
| telegram | Telegram username |
| discord | Discord username |
| number | Numeric input with validation |
| date | Date input with validation |
| wallet | Wallet address with validation |
Example:
custom_fields=[
{
"id": "email",
"type": "email",
"name": "Email Address",
"required": True
},
{
"id": "discord",
"type": "discord",
"name": "Discord Username",
"required": False
}
]You can create token-gated verifications by setting the token_gate parameter to True and providing the required token information:
verification = walver.create_verification(
id="verification_123",
service_name="My Service",
chain="solana",
token_gate=True,
token_address="So11111111111111111111111111111111111111112",
token_amount=1.0,
is_nft=False # Set to True for NFT verification
)from walver_sdk import Walver
# Initialize the client
walver = Walver(api_key="your-api-key")
# Create a basic verification
verification = walver.create_verification(
id="basic_verification",
service_name="My Service",
chain="solana",
webhook="https://example.com/webhook",
secret="your_webhook_secret"
)
print(f"Verification URL: {verification['verification_url']}")from walver_sdk import Walver
# Initialize the client
walver = Walver(api_key="your-api-key")
# Create a token-gated verification with email requirement
verification = walver.create_verification(
id="token_gated_verification",
service_name="Premium Service",
chain="ethereum",
webhook="https://example.com/webhook",
secret="your_webhook_secret",
token_gate=True,
token_address="0x1234567890abcdef1234567890abcdef12345678",
token_amount=10.0,
force_email_verification=True,
custom_fields=[
{
"id": "email",
"type": "email",
"name": "Email Address",
"required": True
},
{
"id": "name",
"type": "text",
"name": "Full Name",
"required": True
}
]
)
print(f"Verification URL: {verification['verification_url']}")from walver_sdk import Walver
# Initialize the client
walver = Walver(api_key="your-api-key")
# Create a folder
folder = walver.create_folder(
name="My Project",
description="Verifications for my project"
)
# Create a verification in the folder
verification = walver.create_verification(
id="folder_verification",
service_name="My Service",
chain="solana",
folder_id=folder["id"]
)
# Get all verifications in the folder
verifications = walver.get_folder_verifications(folder_id=folder["id"])