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 - accepts phone number or secret code (auto-detected)
balance = await api.syrcash.balance("0991234567") # Phone number
balance = await api.syrcash.balance("65656565") # Secret code as string
balance = await api.syrcash.balance(65656565) # Secret code as int
# Get transaction history (only successful transactions by default)
incoming = await api.syrcash.get_incoming_history("0991234567")
# Get all transactions including failed ones
all_tx = await api.syrcash.get_incoming_history("0991234567", status="all")
# Get only failed transactions
failed = await api.syrcash.get_incoming_history("0991234567", status="failed")
# Date filtering
incoming = await api.syrcash.get_incoming_history(
"0991234567",
start_at="2024-01-01",
end_at="2024-12-31"
)
outgoing = await api.syrcash.get_outgoing_history("0991234567")
tx = await api.syrcash.find_incoming_transaction(
"6036565056",
query="0991234567"
)
Sync
from syriatel import SyriatelAPISync
with SyriatelAPISync(api_token="your_token") as api:
numbers = api.get_numbers()
balance = api.syrcash.balance("0991234567")
balance = api.syrcash.balance(65656565) # Secret code as int works too
incoming = api.syrcash.get_incoming_history("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(query) |
float |
Balance in SYP. Accepts phone number or secret code (auto-detected) |
get_incoming_history(query, page, status, start_at, end_at) |
List[Transaction] |
Incoming transfers |
get_outgoing_history(query, page, status, start_at, end_at) |
List[Transaction] |
Outgoing transfers |
find_incoming_transaction(transaction_no, query) |
Transaction |
Find by transaction number |
Notes:
queryparameter auto-detects: if 10 digits starting with09, it's a phone number, otherwise it's a secret codestatusparameter:"success"(default),"failed", or"all"- Phone numbers and secret codes can be passed as strings or integers
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}")
Rate Limits
- Balance: 5 requests per minute per number
- History: 5 requests per minute per number
License
MIT
Project details
Release history Release notifications | RSS feed
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.1.1.tar.gz
(8.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysyriatel-2.1.1.tar.gz.
File metadata
- Download URL: pysyriatel-2.1.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3de4a8cadb0e1219a6d76c3bad9bdfeb05054ab2d920b3dc8143bdb24f21c2eb
|
|
| MD5 |
d1df6cbec956b5a3d328c831bd053de9
|
|
| BLAKE2b-256 |
def01311d65667d5508c3b85b32e92c8db3db16f48fbc6d859ce89d100cbdd33
|
File details
Details for the file pysyriatel-2.1.1-py3-none-any.whl.
File metadata
- Download URL: pysyriatel-2.1.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2a2f501631907b1d2b43780da9a58a2ff78e23e901624247f51780324188561
|
|
| MD5 |
02f0949f23a0cd5807d35facfa0a569a
|
|
| BLAKE2b-256 |
5c1f4ac761d3c6f193e703343ca1653f8b1cb99d8a9b1ef5dec55a011809d9dc
|