Skip to main content

Official Python SDK for Tourist eSIM Partner API

Project description

Tourist eSIM Python SDK

Official Python SDK for Tourist eSIM Partner API. Enable easy integration for resellers and partners to manage eSIM plans, orders, and customer data.

Features

  • 🔐 OAuth 2.0 Authentication - Secure Client Credentials flow with automatic token refresh
  • 🚀 Auto-Retry Logic - Exponential backoff with 3 retry attempts on connection failures
  • 📦 Type-Supported - Full type hints throughout the SDK
  • 💾 Token Caching - In-memory token cache to reduce OAuth requests
  • Pythonic API - Clean, intuitive API design following Python conventions
  • 🔄 Pagination Support - Built-in pagination for catalog queries
  • 🎯 Exception Hierarchy - Specific exceptions for different error scenarios

Requirements

  • Python 3.8+
  • requests >= 2.28.0

Testing

Run the included test script to verify SDK functionality:

python3 test_sdk.py

This runs basic tests for SDK import, instantiation, structure, and resource modules without making actual API calls.

Installation

pip install touristesim-python-sdk

Quick Start

from touristesim import TouristEsim

sdk = TouristEsim('your-client-id', 'your-client-secret')

# Fetch all plans
plans = sdk.plans().get()
for plan in plans:
    print(f"{plan.get('name')} - {plan.get('price')} {plan.get('currency')}")

API Usage

Plans

# Get all plans with filters
plans = sdk.plans().get({
    'country': 'US',
    'type': 'global',
    'per_page': 50,
    'sort_by': 'price'
})

# Get single plan by slug
plan = sdk.plans().find('vietnam_100mb_7days_7e87c5')

# Get plans by country
us_plans = sdk.plans().by_country('US')

# Get global plans
global_plans = sdk.plans().global_plans()

# Validate plan
validation = sdk.plans().validate('vietnam_100mb_7days_7e87c5', 5)

Countries

# Get all countries
countries = sdk.countries().all()

# Find by code
usa = sdk.countries().find('US')

# Search countries
asian = sdk.countries().search('china')

# Featured countries
featured = sdk.countries().featured()

Orders

# Create order
order = sdk.orders().create({
    'plans': [{'plan_slug': 'vietnam_100mb_7days_7e87c5', 'quantity': 1}],
    'customer': {'email': 'customer@example.com', 'name': 'Jane Doe'},
})

# Get orders
orders = sdk.orders().all()

# Get single order by order number
order = sdk.orders().find('PO-260519MKAUVE')

# To request a cancellation or refund, contact Tourist eSIM support

eSIMs

# Get eSIMs
esims = sdk.esims().all()

# Find eSIM
esim = sdk.esims().find('8955001000000000000')

# Check usage
usage = sdk.esims().usage('8955001000000000000')

# Get topup packages
packages = sdk.esims().topup_packages('8955001000000000000')

# Purchase topup
sdk.esims().topup('8955001000000000000', 789)

# Send setup email
sdk.esims().send_email('8955001000000000000', 'user@example.com')

Error Handling

from touristesim.exceptions import (
    AuthenticationException,
    ValidationException,
    RateLimitException,
    ResourceNotFoundException
)

try:
    plan = sdk.plans().find('nonexistent_plan_slug')
except AuthenticationException as e:
    print('Auth failed:', e)
except ValidationException as e:
    print('Validation errors:', e.get_errors())
except RateLimitException as e:
    print('Rate limited. Retry after:', e.get_retry_after(), 'seconds')
except ResourceNotFoundException as e:
    print('Not found:', e)

API Documentation

For complete API documentation, visit:

Support

For issues or questions:

License

MIT - see LICENSE file

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

touristesim_python_sdk-1.2.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

touristesim_python_sdk-1.2.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file touristesim_python_sdk-1.2.0.tar.gz.

File metadata

  • Download URL: touristesim_python_sdk-1.2.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for touristesim_python_sdk-1.2.0.tar.gz
Algorithm Hash digest
SHA256 eaa9f58b9f75dff37d72e36ee9c234f4e81cc34b92265e2d53f52b5434997585
MD5 02db06a06ca46000ca467ba98bbdb782
BLAKE2b-256 e8de16c1de90cf571e83b51f50e2afc04247d63c3cb811cafe9fb3e57fe195e0

See more details on using hashes here.

File details

Details for the file touristesim_python_sdk-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for touristesim_python_sdk-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2255f3f052df7ee86cb419ff4be66f343ed6e99cdac4d87e37da4d6e547b1ba
MD5 c86fe5c6c9874b5d5035efce2b4a26d3
BLAKE2b-256 ec350fd7a0d758b65190cb0cb9fef9c65bf348b627f87088f24d2da628aa93b3

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