pyucallerapi - Python service for convenient work with uCaller API
Documentation uCaller api: DOC
Установка
Пользуем pip:
pip install pyucallerapi
Зависимости
python>=3.10
requests
pydantic>=2.9.2
Как использовать
Все названия методов соответствуют action в ссылке (смотрите документацию). Пример названия метода:
- /v1.0/initCall/ -
init_сall
Варианты импорта Вы можете импортировать
UCallerAPI - с всеми доступными методами
SettingAPI - только методы для работы с аккаунтом
CallAPI - только запросы кода авторизации
Так же прошу вас обратить внимание на аннотацию типов аргументов
Если вам нужно чтобы ответ был в dict - то при инициализации укажите аргумент return_dict = True
api = UCallerAPI(service_id=service_id,key=key, return_dict=True)
# Либо
api = UCallerAPI(service_id=service_id,key=key,)
api.return_dict = True
Example
Использование сервиса
import logging
from pyucallerapi import APIUCaller, CallAPI, SettingAPI
logger = logging.getLogger(__name__)
logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG)
service_id = <int>
key = ""
# запрашиваем звонок
api = APIUCaller(
service_id=service_id,
key=key,
logger=logger
)
# Проверка работоспособности сервиса -> HealthModel | ErrorResponseModel
api.health()
# Запрос на авторизацию -> InitCallModel | ErrorResponseModel
out = api.init_call("+79000000001", "6123",)
# получить информацию о запросе авторизации
api.get_info(out.ucaller_id)
Получение данных webhook (например, из FastAPI)
from fastapi import APIRouter, Request
from pyucallerapi import UcallerWebhookModel
router = APIRouter()
@router.post("/ucaller-webhook")
async def handle_webhook(request: Request):
data = await request.json()
webhook = UcallerWebhookRequest(**data) # Валидация
if webhook.isMnp:
print(f"Номер портирован от {webhook.operatorName} к {webhook.operatorNameMnp}")
return {"status": "ok"}
Metadata
Release files for pyucallerapi 0.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 | Actions |
|---|---|---|---|---|
| pyucallerapi-0.1.1.tar.gz | 13.8 kB | Without provenance | Details for pyucallerapi-0.1.1.tar.gz |
Release files / pyucallerapi-0.1.1.tar.gz
| Download URL | pyucallerapi-0.1.1.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
005253aa447c54391e0a7be86f5ffacc84c15bf0f35f642e1e2d98321d77d807
|
|
BLAKE2b-256 checksum How to use checksums |
d004b52558d60c1373514958ac5eee224aecc385fab111a9cf5d54834cecc561
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.7
|
Security for pyucallerapi 0.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.