Skip to main content

Python client for Syriatel API

Project description

PySyriatel

Python client for Syriatel API.

Installation

pip install PySyriatel

Usage

Async

from syriatel import SyriatelAPI

async with SyriatelAPI(api_token="your_token") as api:
    # Get registered numbers
    numbers = await api.get_numbers()
    codes = await api.get_codes()
    numbers_codes = await api.get_numbers_codes()
    
    # Syriatel Cash
    balance = await api.syrcash.balance("0991234567")  # By number
    balance = await api.syrcash.balance(code="65288500")  # By secret code
    
    incoming = await api.syrcash.get_incoming_history(
        number="0991234567",
        start_at="2024-01-01",
        end_at="2024-12-31"
    )
    
    outgoing = await api.syrcash.get_outgoing_history(number="0991234567")
    
    tx = await api.syrcash.find_incoming_transaction(
        "TXN123456",
        number="0991234567"
    )

Sync

from syriatel import SyriatelAPISync

with SyriatelAPISync(api_token="your_token") as api:
    numbers = api.get_numbers()
    balance = api.syrcash.balance("0991234567")
    incoming = api.syrcash.get_incoming_history(number="0991234567")

API

SyriatelAPI / SyriatelAPISync

Method Returns Description
get_numbers() List[str] Active phone numbers
get_codes() List[str] Secret codes
get_numbers_codes() List[Tuple[str, str]] Number and code pairs

api.syrcash

Method Returns Description
balance(number=None, code=None) int Balance in SYP. Accepts either number or code parameter
get_incoming_history(number, code, page, start_at, end_at) List[Transaction] Incoming transfers
get_outgoing_history(number, code, page, start_at, end_at) List[Transaction] Outgoing transfers
find_incoming_transaction(transaction_no, number, code) Transaction Find by transaction number

Transaction

@dataclass
class Transaction:
    transaction_no: str
    date: str
    from_gsm: str
    to_gsm: str
    amount: int
    fee: int
    net: int
    channel: str
    status: str

Error Handling

from syriatel import (
    SyriatelAPIError,
    InvalidTokenError,
    SubscriptionExpiredError,
    FetchFailedError,
    NetworkError,
)

try:
    balance = await api.syrcash.balance("0991234567")
except SubscriptionExpiredError:
    print("Subscription expired")
except InvalidTokenError:
    print("Invalid token")
except NetworkError as e:
    print(f"Network error: {e}")

License

MIT

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

pysyriatel-2.0.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

pysyriatel-2.0.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pysyriatel-2.0.3.tar.gz.

File metadata

  • Download URL: pysyriatel-2.0.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pysyriatel-2.0.3.tar.gz
Algorithm Hash digest
SHA256 9ca1eeae55cad6b9fc4e456ae677f85c9e1b23cbc5ab869439c16e89620b27fb
MD5 fe0a0911ee1d26d8a8418be52a69dfe3
BLAKE2b-256 8439205fe6f37d4b94d35207065f97c110efd511f6cd56c2467fbe8da4aed6bb

See more details on using hashes here.

File details

Details for the file pysyriatel-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: pysyriatel-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pysyriatel-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 07eac0dbfdbe94944ee2b2edc0afbed13efd8bc1a10e4e7bec19c104f0bf1c15
MD5 d7f5834f7055256152cc611c6282b406
BLAKE2b-256 1fa7f3bbabff20bcad046e2fa80b408c15a0cf88c6b28cc9da664871b616979c

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