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
Metadata
Release files for PySyriatel 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pysyriatel-2.1.1.tar.gz | 8.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pysyriatel-2.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.0 kB
Release files / pysyriatel-2.1.1.tar.gz
| Download URL | pysyriatel-2.1.1.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3de4a8cadb0e1219a6d76c3bad9bdfeb05054ab2d920b3dc8143bdb24f21c2eb
|
|
BLAKE2b-256 checksum How to use checksums |
def01311d65667d5508c3b85b32e92c8db3db16f48fbc6d859ce89d100cbdd33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Release files / pysyriatel-2.1.1-py3-none-any.whl
| Download URL | pysyriatel-2.1.1-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d2a2f501631907b1d2b43780da9a58a2ff78e23e901624247f51780324188561
|
|
BLAKE2b-256 checksum How to use checksums |
5c1f4ac761d3c6f193e703343ca1653f8b1cb99d8a9b1ef5dec55a011809d9dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.8
|
Security for PySyriatel 2.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.