Skip to main content

SDK Package for the eSignBase API

Project description

esignbase-python-sdk

API Client for the eSignBase API

The package provides a small, synchronous client for interacting with the eSignBase API.

Full REST API documentation is available at https://esignbase.com/en/api_documentation it also shows the format of the returned dictionary data.

Classes

GrantType (Enum)

Defines the available OAuth2 grant types:

  • CLIENT_CREDENTIALS: For server-to-server authentication
  • AUTHORIZATION_CODE: For user-specific authentication

Scope (Enum)

Defines the available API permission scopes:

  • ALL: Full access to all API endpoints
  • READ: Read-only access
  • CREATE_DOCUMENT: Permission to create documents
  • DELETE: Permission to delete documents
  • SANDBOX: Access to the sandbox environment, use this scope for testing

OAuth2Client

Main client class that stores authentication credentials and state.

Attributes:

id (str) # Client ID from ESignBase
secret (str) # Client secret from ESignBase
grant_type (GrantType) # OAuth2 grant type to use
user_name (Optional[str]) # Username (required AUTHORIZATION_CODE)
password (Optional[str]) # Password (required AUTHORIZATION_CODE)
scope (list[Scope]) # List of requested API scopes

Retrieve your Client ID and Client Secret at https://app.esignbase.com/oauth2/client by creating an OAuth2 Client Configuration.

Recipient

Represents a document recipient/signer. role_name value is defined during template creation in the template editor.

Attributes:

email (str) # Recipient's email address
first_name (str) # Recipient's first name
last_name (str) # Recipient's last name
role_name (str) # Role name (e.g., "Signer", "Viewer")
locale (str) # Locale code ("de", "en", "es")

ESignBaseSDKError (Exception)

Custom exception class for API-related errors.

Functions

def connect(client: OAuth2Client) -> None

Authenticates with the ESignBase API

Parameters:

client: Configured OAuth2Client instance

Raises:

ESignBaseSDKError: If authentication fails or validation fails

Example:

client = OAuth2Client(
    id="your_client_id",
    secret="your_client_secret",
    grant_type=GrantType.CLIENT_CREDENTIALS,
    scope=[Scope.ALL],
)
connect(client)

def get_templates(client: OAuth2Client) -> list[dict[str, Any]]

Retrieves a list of available document templates.

Parameters:

client: Authenticated OAuth2Client instance

Returns A list of dictionaries containing template data.

Raises:

ESignBaseSDKError: If the API request fails

def get_template(client: OAuth2Client, template_id: str) -> dict[str, Any]

Retrieves details of a specific template.

Parameters:

client: Authenticated OAuth2Client instance
template_id: Unique identifier of the template

Returns: Dictionary containing template details

Raises: ESignBaseSDKError: If the API request fails


def get_documents(client: OAuth2Client, limit: int, offset: int) -> dict[str, Any]

Retrieves a paginated list of documents.

Parameters:

client: Authenticated OAuth2Client instance
limit: Maximum number of documents to return
offset: Pagination offset

Returns:

Dictionary containing document list and pagination info `{documents: [...]}`

Raises:

ESignBaseSDKError: If the API request fails

def get_document(client: OAuth2Client, document_id: str) -> dict[str, Any]

Retrieves details of a specific document.

Parameters:

client: Authenticated OAuth2Client instance
document_id: Unique identifier of the document

Returns:

Dictionary containing document details

Raises:

ESignBaseSDKError: If the API request fails

def create_document(
    client: OAuth2Client,
    template_id: str,
    document_name: str,
    recipients: list[Recipient],
    user_defined_metadata: Optional[dict[str, str | int]] = None,
    expiration_date: Optional[datetime] = None
) -> dict[str, Any]

Creates a new document from a template.

Parameters:

client: Authenticated OAuth2Client instance
template_id: ID of the template to use
document_name: Name for the new document
recipients: List of Recipient objects
user_defined_metadata: Optional metadata to attach to the document
expiration_date: Optional expiration date for the document

Returns:

Dictionary containing the created document id and current document status

Raises:

ESignBaseSDKError: If the API request fails

Example:

recipients = [
    Recipient(
        email="signer@example.com",
        first_name="John",
        last_name="Doe",
        role_name="signer",
        locale="de"
    )
]

document = create_document(
    client=client,
    template_id="template_123",
    document_name="Contract Agreement",
    recipients=recipients,
    user_defined_metadata={"contract_id": "CTR-2024-001"},
    expiration_date=datetime(2024, 12, 31)
)

def delete_document(client: OAuth2Client, document_id: str) -> None

Deletes a specific document.

Parameters:

client: Authenticated OAuth2Client instance
document_id: Unique identifier of the document to delete

Raises:

ESignBaseSDKError: If the API request fails

def get_credits(client: OAuth2Client) -> dict[str, Any]

Retrieves credit balance information.

Parameters:

client: Authenticated OAuth2Client instance

Returns:

Dictionary containing credit balance data

Raises:

ESignBaseSDKError: If the API request fails

Error Handling

All functions raise ESignBaseSDKError exceptions for API errors, network issues, or validation failures. Always wrap API calls in try-except blocks:

try:
    templates = get_templates(client)
except ESignBaseSDKError as e:
    print(f"API Error: {e}")

Complete Example

from datetime import datetime

# Setup client
client = OAuth2Client(
    id="your_client_id",
    secret="your_client_secret",
    grant_type=GrantType.CLIENT_CREDENTIALS,
    scope=[Scope.CREATE_DOCUMENT, Scope.READ]
)

# Authenticate
connect(client)

# Get available templates
templates = get_templates(client)

# Create a document
recipients = [
    Recipient(
        email="alice@example.com",
        first_name="Alice",
        last_name="Smith",
        role_name="Signer",
        locale="en"
    )
]
template_id = templates[0]["id"]

document = create_document(
    client=client,
    template_id=template_id,
    document_name="NDA Agreement",
    recipients=recipients
)

# Check document status
document_details = get_document(client, document["id"])

# Delete the document (if needed)
delete_document(client, document["id"])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

esignbase_sdk-1.0.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file esignbase_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: esignbase_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for esignbase_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9049bc2eeb1e13cff0ff08ff2fbfa7f4adb21b804e7c3842846dbe68f7cd58b8
MD5 d42cb3fdad4a1ffd4f7d5867c4e8a794
BLAKE2b-256 bc2eaf379beda5fc11a5fb49bd8e49fc218eb7e99eb7c28467ea69e7addbc87c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page