Skip to main content

Unofficial AsiaCell Python SDK

Project description

AsiaCell SDK

A modern Python SDK for interacting with AsiaCell APIs.

Features

  • Token-based authentication
  • Profile parsing
  • Balance retrieval
  • Voucher top-up
  • Typed response models
  • Session management
  • Random User-Agent rotation
  • Custom exceptions
  • Lightweight and easy to use

Installation

pip install asiacell

Quick Start

from asiacell import AsiaCellClient

client = AsiaCellClient(
    token="YOUR_TOKEN"
)

profile = client.get_profile()

print(profile.name)
print(profile.phone)
print(profile.balance.amount)

Authentication

The SDK currently supports Bearer Token authentication.

from asiacell import AsiaCellClient

client = AsiaCellClient(
    token="YOUR_JWT_TOKEN"
)

You can also set or clear the token later:

client.set_token("TOKEN")

client.clear_token()

Profile

Retrieve account profile information.

profile = client.get_profile()

print(profile.name)
print(profile.phone)
print(profile.photo)

Profile Object

profile.name
profile.phone
profile.photo
profile.balance

Balance

balance = client.get_balance()

print(balance.amount)

Voucher Top-Up

result = client.topup(
    msisdn="077XXXXXXXX",
    voucher="1234567890"
)

print(result.success)
print(result.message)

TopUpResult Object

result.success
result.message
result.raw

Random User-Agent Rotation

client.rotate_user_agent()

Exceptions

The SDK provides custom exceptions:

from asiacell.exceptions import (
    AsiacellError,
    AuthenticationError,
    APIError,
    VoucherUsedError
)

Example:

try:
    client.get_profile()

except AuthenticationError:
    print("Invalid token")

except APIError as e:
    print(e)

Models

Profile

Profile(
    name: str,
    phone: str,
    photo: str,
    balance: Balance
)

Balance

Balance(
    amount: int
)

TopUpResult

TopUpResult(
    success: bool,
    message: str,
    raw: dict
)

Example

from asiacell import AsiaCellClient

client = AsiaCellClient(
    token="YOUR_TOKEN"
)

profile = client.get_profile()

print(profile.name)
print(profile.balance.amount)

result = client.topup(
    msisdn=profile.phone,
    voucher="1234567890"
)

print(result.message)

Requirements

  • Python 3.9+
  • requests
  • fake-useragent

Legal Disclaimer

This project is an unofficial SDK and is not affiliated with or endorsed by AsiaCell.

Use responsibly and in compliance with applicable terms of service.


License

MIT License

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

asiacellclient-1.0.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

asiacellclient-1.0.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file asiacellclient-1.0.0.tar.gz.

File metadata

  • Download URL: asiacellclient-1.0.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for asiacellclient-1.0.0.tar.gz
Algorithm Hash digest
SHA256 23de866a68bd973c3bdeace0c8872dd8cc4ada253b47c2025f84b76a6151ef42
MD5 0f1e6a243c9ade6b5054473d5b99fef6
BLAKE2b-256 e16af6541260446727cf38227b7a077c5b2c69de677e4ccbe7d3fe3d73c7e834

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asiacellclient-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for asiacellclient-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a7a36d862fbb725cae7188a3d704085c70e631d61bb35aa6307b7f8097d646b
MD5 e3efceb70a1cfbb837e5541b67aa6068
BLAKE2b-256 83f3eddd15f4efd0e905ea3ec244268f4ad1c3dd0b61bcea27fb52f23f8879e8

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