Thanks to visit codestin.com
Credit goes to lib.rs

#sms #api #tokyo

textbelt

The library for Textbelt API, use to send SMS!

1 stable release

1.0.0 Sep 4, 2025

#1400 in Web programming

MIT license

25KB
69 lines

textbelt-rs logo


textbelt-rs is a Rust library for textbelt. 🦀

Textbelt is an SMS API that is built for developers who just want to send and receive SMS. Sending an SMS is a simple thing. The goal is to provide an API that is correspondingly simple, without requiring account configuration, logins, or extra recurring billing. You shouldn’t send more than 1–2 SMS per second; this is the rate limit imposed by the official service. Please read the official documentation for more information.

  • CHANGELOG.md - A record of all significant version changes
  • examples/ - Library usage example in real Rust project

Implemented Features

Method Resource Description
POST /text Can be use to send message to a phone number (a normal 10-digit phone number with area code).
GET /status/:textId If you are given a textId and want to check its delivery status.
GET /quota/:key You may want to know how much quota or credit you have left on a key.

Example

Cargo.toml:

...
[dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
textbelt = { version = "1.0.0" }

main.rs:

How to send an text SMS?

use textbelt::TextbeltClient;

#[tokio::main]
async fn main() {
    let tc = TextbeltClient::new("Your textbelt API Key");
    let phone = "+33601020304";
    let message = "Hello from textbelt-rs!";
    match tc.text(&phone, &message).await {
        Ok(res) => {
            println!("{:?}", &res);
         },
        Err(err) => { println!("[Error] {err}") }
    }   
}

How to check the delivery status?

use textbelt::TextbeltClient;

#[tokio::main]
async fn main() {
    let tc = TextbeltClient::new("Your textbelt API Key");
    let text_id = "text_id";
    match tc.status(&text_id).await {
        Ok(res) => {
            println!("{:?}", &res);
         },
        Err(err) => { println!("[Error] {err}") }
    }   
}

How to check the api key quota?

use textbelt::TextbeltClient;

#[tokio::main]
async fn main() {
    let tc = TextbeltClient::new("Your textbelt API Key");
    match tc.quota().await {
        Ok(res) => {
            println!("{:?}", &res);
         },
        Err(err) => { println!("[Error] {err}") }
    }
}

More examples in doc.rs/textbelt

Special thanks to

Dependencies

~5–21MB
~238K SLoC