Skip to content

Numbers

Pavel Kuzmin edited this page Sep 6, 2026 · 6 revisions

Home › Numbers

Numbers

Temporary SMS numbers — order, poll state, wait for codes, close or ban.

Prefer state() over state_one when you have several active operations: one request for all numbers is cheaper and safer for rate limits. Concurrent wait_code calls already share a batch poller.

On this page: Quick start · get · get_with_number · price · state · state_one · next · close · ban · wait_code · tariffs

let numbers = Client::new("APIKEY")?.numbers();

Workflow


Quick start

use onlinesim_rs_api::{Client, WaitCodeOptions};

#[tokio::main]
async fn main() -> onlinesim_rs_api::Result<()> {
    let numbers = Client::new("APIKEY")?.numbers();

    let tzid = numbers.get("telegram").await?;
    let code = numbers
        .wait_code(
            tzid,
            WaitCodeOptions {
                interval_secs: 5,
                max_attempts: 24,
                ..WaitCodeOptions::default()
            },
        )
        .await?;
    println!("code={code}");
    Ok(())
}

get

docs ru · docs en

Order a number. Returns tzid.

Param Default Description
service required Service slug
country 1 Dial code (get_with)
reject [] Exclusion list (get_with)
extension false Extension flag (get_with)
numbers.get("telegram").await?;
numbers
    .get_with(GetNumberParams::new("telegram").country(1))
    .await?;

get_with_number

Same as get, but also returns the phone number and metadata.

let ordered = numbers.get_with_number("telegram").await?;
// ordered.tzid, ordered.number, ordered.country, …

price

docs ru · docs en

Param Default Description
service required Service slug
country 1 Via price_in

state

docs ru · docs en

List all active operations (batch). Prefer this over state_one.

Param Default Description
message_to_code 1 1 — code, 0 — full message
orderby ASC ASC or DESC
msg_list true Show all messages
clean true Clean flag
repeat false Repeat mode

state_one

docs ru · docs en

State for a single tzid (defaults: message_to_code=1, msg_list=true, clean=true). Use state_one_with for explicit flags.

Warning: Prefer state() and filter by tzid locally instead of polling each number separately.


next

docs ru · docs en

Request the next SMS for an operation.

Param Default Description
tzid required Operation id

close

docs ru · docs en

Close the operation.

Param Default Description
tzid required Operation id

ban

Close and ban the number (ban=1).


wait_code

Wait until an SMS code arrives for tzid.

Concurrent calls on the same client share one background poller that calls state() (all numbers) once per tick and fans results out by tzid. The poller starts with the first waiter and stops when none remain.

Field Default Description
interval_secs 3 Poll interval in seconds (shared poller uses the minimum)
max_attempts 10 Attempt limit per waiter
not_end false Call next instead of close
full_message false Full message text; if any waiter sets this, the batch poll uses it

tariffs

docs ru · docs en

Method Scope
tariffs() All countries
tariffs_one() Default country (1)
tariffs_one_in(country) Explicit country

← Home Rent →

Clone this wiki locally