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) float 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: float
    fee: float
    net: float
    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.4.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.4-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysyriatel-2.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 d37db210832decac38c4f126f9a64cbb2f693d4d54532582f1106d787fe5f04a
MD5 ced7ac54e7ed4a25b465a4b882b9c208
BLAKE2b-256 764681bdff5d5ae955c9eaef6824aaac7ff4fcaf6e5ec4217d230a21af992ca6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysyriatel-2.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 34b9c6b69acdeefc8a9d76e71d86156e87b008c09bacf943b9f7b52c87ecb0aa
MD5 1903019d0bf44e05a66bb3ddd1eb0b57
BLAKE2b-256 3a79ae7b87308ac59a6942bfad352ded16b76e0b29317b73127ac22d9ce41e45

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