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")
    
    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) int Balance in SYP
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.1.tar.gz (8.3 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.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysyriatel-2.0.1.tar.gz
  • Upload date:
  • Size: 8.3 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.1.tar.gz
Algorithm Hash digest
SHA256 24b0dd4201b557c8b35906bc49338bf6beb2cb9a159082dc167160add3c662ba
MD5 98e0e0fb44ef934d83b58f8a1212979e
BLAKE2b-256 a1c86d6a1819d0d0cf772ea139c8ed5c2b59bea08d009c6378b469fd98836478

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysyriatel-2.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba6df7da4b61b0091decc8a18f9325544f60c6b4f2151c4337048efab0d11b92
MD5 ec6a3891f24976da64e7c6cd06337baf
BLAKE2b-256 9e6f4b4456709e8ebda5e932abf1919ec828bc82dd8bbd98302a9d374e8c0a90

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