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.37

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.37
File Size Uploaded Provenance Actions
yemot_api-0.1.37.tar.gz 72.2 kB Without provenance Details for yemot_api-0.1.37.tar.gz

Built distribution (wheel)

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

Total release size: 129.8 kB

Release files / yemot_api-0.1.37.tar.gz

Download URL yemot_api-0.1.37.tar.gz
Size 72.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f5af9c02d98d0bf35361109df80f83e11fe39e6a21a4516b70c9a5ea888b50d1
BLAKE2b-256 checksum
How to use checksums
04bbe0d2dbafc52a905a1d3ebaf8453866c1d0c66691d502366a70eb46d26e30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","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.37-py3-none-any.whl

Download URL yemot_api-0.1.37-py3-none-any.whl
Size 57.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
72c541c4e468c21af8daf8509937bf6a5859e4bff87a857e72ab726fbf9790bf
BLAKE2b-256 checksum
How to use checksums
50c7d74dc5253e07fa6f4f3b76ab61c2768e2101e22217f6c86ec3664c43a64d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","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.37

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.37 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