The single entry-point to all network operations that:
Manages an internal persistent HTTP client with automatic retry & back-off for 5xx / 429 responses
Can be instantiated directly or via the convenience constructor from environment variables
Automatically normalizes URLs (adds https://, removes trailing slashes). The default base URL is https://api.nekuda.ai
Copy
Ask AI
from nekuda import NekudaClient# Production clientclient = NekudaClient(api_key="sk_live_...")# Client pointing to a different API endpoint (e.g. staging)# client = NekudaClient(api_key="sk_test_...", base_url="https://staging-api.nekuda.ai")
Copy
Ask AI
from nekuda import NekudaClient# Production clientclient = NekudaClient(api_key="sk_live_...")# Client pointing to a different API endpoint (e.g. staging)# client = NekudaClient(api_key="sk_test_...", base_url="https://staging-api.nekuda.ai")
Copy
Ask AI
import { NekudaClient } fromt '@nekuda/nekuda-js';// All of these work the same way:const client = new NekudaClient('sk_...', { baseUrl: 'api.nekuda.ai' });const client = new NekudaClient('sk_...', { baseUrl: 'https://api.nekuda.ai/' });
A lightweight wrapper returned by client.user(user_id) that automatically injects the user_id header on every call.
A user_id is mandatory for all user-specific operations like creating mandates or revealing cards.
Copy
Ask AI
from nekuda import NekudaClient, MandateDataclient = NekudaClient.from_env()# You must provide a unique user_id for each of your users.user_id = "user_unique_identifier_123"user = client.user(user_id)# Example MandateData (details below)mandate_details = MandateData( product="Example Product", price=10.99, currency="USD", merchant="YourStore")# The user_id is now automatically included in the following calls:# 1. Create a mandate (intent to purchase)mandate_response = user.create_mandate(mandate_details)# 2. A mandate must be created first to obtain a mandate_id.# This mandate_id is then used to request a card reveal token.reveal_response = user.request_card_reveal_token(mandate_response.mandate_id)# 3. Exchange the token for card detailscard_details_response = user.reveal_card_details(reveal_response.reveal_token)
Copy
Ask AI
from nekuda import NekudaClient, MandateDataclient = NekudaClient.from_env()# You must provide a unique user_id for each of your users.user_id = "user_unique_identifier_123"user = client.user(user_id)# Example MandateData (details below)mandate_details = MandateData( product="Example Product", price=10.99, currency="USD", merchant="YourStore")# The user_id is now automatically included in the following calls:# 1. Create a mandate (intent to purchase)mandate_response = user.create_mandate(mandate_details)# 2. A mandate must be created first to obtain a mandate_id.# This mandate_id is then used to request a card reveal token.reveal_response = user.request_card_reveal_token(mandate_response.mandate_id)# 3. Exchange the token for card detailscard_details_response = user.reveal_card_details(reveal_response.reveal_token)
Copy
Ask AI
import { NekudaClient, MandateData } fromt '@nekuda/nekuda-js';const client = NekudaClient.fromEnv();const user = client.user('user_unique_identifier_123');// Example MandateData (details below)const mandate = new MandateData({ product: 'Example Product', price: 10.99, currency: 'USD', merchant: 'YourStore'});// All methods return typed response interfaces!// 1. Create a mandate (intent to purchase)const mandateResponse = await user.createMandate(mandate);// 2. Request reveal token using mandate_idconst revealResponse = await user.requestCardRevealToken(mandateResponse.mandateId);// 3. Exchange the token for card detailsconst cardDetails = await user.revealCardDetails(revealResponse.revealToken);
Behind the scenes no extra network round-trip happens for
client.user(user_id) – UserContext is just a convenience object that
stores the user_id.
A data class that represents the user’s intent to purchase.
It must be successfully submitted via user.create_mandate(mandate_data) to obtain a mandate_id before you can request a card reveal token.
Copy
Ask AI
from nekuda import MandateDatamandate = MandateData( product="Premium Subscription", price=49.99, currency="USD", merchant="nekuda Corp", # Optional fields: merchant_link="https://app.nekuda.ai/premium", product_description="Access to all premium features", confidence_score=0.95)
Client-side validation runs in __post_init__. Invalid payloads raise NekudaValidationErrorbefore any HTTP request is made.
Copy
Ask AI
from nekuda import MandateDatamandate = MandateData( product="Premium Subscription", price=49.99, currency="USD", merchant="nekuda Corp", # Optional fields: merchant_link="https://app.nekuda.ai/premium", product_description="Access to all premium features", confidence_score=0.95)
Client-side validation runs in __post_init__. Invalid payloads raise NekudaValidationErrorbefore any HTTP request is made.
class CardRevealTokenResponse: reveal_token: str # The one-time token reveal_path: str # API endpoint for reveal expires_at: datetime? # Optional expiration
CardDetailsResponse
Copy
Ask AI
class CardDetailsResponse: card_number: str # Validated 13-19 digits card_expiry_date: str # Validated MM/YY format cardholder_name: str # Name on card # ... plus optional fields
MandateCreateResponse
Copy
Ask AI
class MandateCreateResponse: mandate_id: int request_id: str customer_id: str # This is the user_id you provided created_at: datetime
CardRevealTokenResponse
Copy
Ask AI
class CardRevealTokenResponse: reveal_token: str # The one-time token reveal_path: str # API endpoint for reveal expires_at: datetime? # Optional expiration
CardDetailsResponse
Copy
Ask AI
class CardDetailsResponse: card_number: str # Validated 13-19 digits card_expiry_date: str # Validated MM/YY format cardholder_name: str # Name on card # ... plus optional fields
MandateCreateResponse
Copy
Ask AI
class MandateCreateResponse: mandate_id: int request_id: str customer_id: str # This is the user_id you provided created_at: datetime
# user_id had to be passed in each calltoken_dict = client.request_card_reveal_token(user_id="some_user", mandate_id="m_123")token = token_dict["reveal_token"] # 😟 Hope the key exists!
Copy
Ask AI
# user_id had to be passed in each calltoken_dict = client.request_card_reveal_token(user_id="some_user", mandate_id="m_123")token = token_dict["reveal_token"] # 😟 Hope the key exists!
The SDK client is designed to be cheap to instantiate but you can (and should) reuse a single instance across the lifetime of your process for maximum performance. Internally it lazily creates the underlying HTTP session the first time you make a request.