Skip to main content
from typing import Annotated, Literal

from fastapi import Depends, FastAPI, HTTPException, Request, responses

from yemot_api.api_model import ApiModel
from yemot_api.api_response import id_list_message_text, join, routing_yemot
from yemot_api.input_types import FileAction
from yemot_api.yemot_api import Yemot


def verify_yemot(request: Request) -> Literal[True]:
    user_agent = request.headers.get("user-agent")
    if user_agent != "yemot-core-api/1.0":
        raise HTTPException(status_code=403, detail=f"Access denied: {user_agent}")
    return True


class ApiModelExample(ApiModel):
    path: str
    token: str


# app = FastAPI(dependencies=[Depends(verify_yemot)])
app = FastAPI()


@app.get("/foo")
def foo(q: Annotated[ApiModelExample, Depends()]) -> responses.PlainTextResponse:
    yemot_ins = Yemot(q.token)
    if not yemot_ins.check_if_file_exists(q.path):
        return responses.PlainTextResponse("ERROR", 404)
    content = yemot_ins.download_file(q.path)
    with open("testtt.wav", "wb") as f:
        f.write(content)
    yemot_ins.file_action(FileAction.MOVE, q.path, "1")
    res_1 = id_list_message_text("הנך מועבר למערכת אחרת")
    res_2 = routing_yemot("0773137770")
    res = join(res_1, res_2)
    return responses.PlainTextResponse(res, 200)

REST API (API key)

Uses the new API at https://rest.yemot.co.il/start with a permanent API key instead of a token. All the Yemot / AsyncYemot methods work the same, the switch is selected with switch_id (the uuid from search_switches).

from yemot_api.yemot_rest_api import YemotRest

with YemotRest("yk_live_...") as yemot:
    switches = yemot.search_switches()
    yemot.switch_id = switches.items[0].uuid
    print(yemot.get_ivr2_dir("ivr2:/"))
from yemot_api.async_yemot_rest_api import AsyncYemotRest

async with AsyncYemotRest("yk_live_...", switch_id="<SWITCH_UUID>") as yemot:
    print(await yemot.get_customer_data())

By the system phone number (searches the switches of the account, LookupError when not found):

with YemotRest.from_number("yk_live_...", "0791234567") as yemot:
    print(yemot.get_customer_data())

yemot = await AsyncYemotRest.from_number("yk_live_...", "+972791234567")

Errors of the REST API (bad key, permissions, missing switch_id, rate limit) raise YemotAPIError with the error code in message_code and status_code, details, request_id and retry_after (on HTTP 429, wait before retrying).

Account methods: get_profile, get_security, get_api_key, revoke_api_key, search_switches, get_switch, find_switch.

Not available with an API key: login, logout, render_ymgr_file and the session and security methods (set_password, set_customer_details, double_auth, mfa_session, get_all_sessions, kill_session, kill_all_sessions). upload_file sends the file in a single request, up to YemotRest.MAX_UPLOAD_SIZE (about 20MB, the gateway limit), the chunked upload for larger files does not work through the gateway. check_if_file_exists and check_if_folder_exists are checked with GetFile. get_session and get_customer_data do not return access_password and record_password.

Metadata

Release files for yemot-api 0.1.36

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yemot-api 0.1.36
File Size Uploaded Provenance Actions
yemot_api-0.1.36.tar.gz 72.0 kB Without provenance Details for yemot_api-0.1.36.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yemot-api 0.1.36
File Interpreter ABI Platform Actions
yemot_api-0.1.36-py3-none-any.whl Python 3 none any Details for yemot_api-0.1.36-py3-none-any.whl

Total release size: 129.5 kB

Release files / yemot_api-0.1.36.tar.gz

Download URL yemot_api-0.1.36.tar.gz
Size 72.0 kB
Tags Source
SHA-256 checksum
How to use checksums
00f751ddef6860a2ba9f427041a566993b6f368af6302e24833a6a2827fdb8cc
BLAKE2b-256 checksum
How to use checksums
90a440befaacfed38c17b7647fa86bc25adea214c55e1907f69a4368f92175e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / yemot_api-0.1.36-py3-none-any.whl

Download URL yemot_api-0.1.36-py3-none-any.whl
Size 57.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
582cbdc46eb1a4feeab276155026f1336e1438b49e4a6a16f3c8aa6e5938586b
BLAKE2b-256 checksum
How to use checksums
37e0c8e5cd08160cd60b647a4124a8e4d32513e6a1cdfee95267fe221586b379
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for yemot-api 0.1.36

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.

Release history Release notifications | RSS feed

This release

0.1.36 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page