How-to · 3 min read

Receive an OTP in Python

A minimal, production-shaped Python example for buying a number and reading the verification code — with retries and clean teardown.

Here's the smallest useful Python flow for receiving a one-time code.

import os, time
from eveses import Eveses

client = Eveses(key=os.environ["EVESES_KEY"])

# 1. provision a number
order = client.orders.create(country="ua", mode="activation", service="telegram")
print("number:", order.phone)

# 2. poll for the code (use a webhook in production)
def wait_for_otp(order_id, timeout=120, every=1.5):
    deadline = time.time() + timeout
    while time.time() < deadline:
        o = client.orders.sms(order_id)
        if o.sms:
            return o.sms[0].otp
        time.sleep(every)
    raise TimeoutError("no OTP received")

code = wait_for_otp(order.order_id)
print("code:", code)

# 3. release the number
client.orders.finish(order.order_id)

Install with pip install eveses. For high volume, register a webhook instead of polling and let the server push the code to you.


Ready to build? Create a free Eveses account, top up a wallet, and grab your API key — no KYC. See the API docs or live pricing.

FAQ

▸How do I receive an SMS code in Python?
pip install eveses, create an order, then poll client.orders.sms(order_id) or register a webhook to receive the code.
▸Should I poll or use webhooks?
Polling is fine for scripts; for production volume, webhooks remove the latency and the request overhead.
Related guides