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
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. |
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", None);
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", None);
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", None);
match tc.quota().await {
Ok(res) => {
println!("{:?}", &res);
},
Err(err) => { println!("[Error] {err}") }
}
}
More examples in doc.rs/textbelt