Why Integrate an SMS API
If you need to automate receiving SMS codes — for testing, monitoring, or business workflows — buying numbers manually doesn't scale. SMSCodex REST API lets you programmatically get numbers, check SMS, and manage your balance.
Quick Start
All you need: an API key (generated in your dashboard) and an HTTP client. Base URL: https://smscodex.com/api/v1/.
Python Example
import requests
API_KEY = "your_api_key"
BASE = "https://smscodex.com/api/v1"
# 1. Get available services
services = requests.get(f"{BASE}/services", headers={"Authorization": f"Bearer {API_KEY}"}).json()
# 2. Buy a number for Telegram (service_id=1, country_id=1)
order = requests.post(f"{BASE}/orders", json={"service_id": 1, "country_id": 1}, headers={"Authorization": f"Bearer {API_KEY}"}).json()
phone = order["phone"]
order_id = order["id"]
print(f"Number: {phone}")
# 3. Get the SMS code (polling)
import time
for _ in range(60):
status = requests.get(f"{BASE}/orders/{order_id}", headers={"Authorization": f"Bearer {API_KEY}"}).json()
if status.get("sms_code"):
print(f"Code: {status['sms_code']}")
break
time.sleep(2)
Node.js Example
const API_KEY = "your_api_key";
const BASE = "https://smscodex.com/api/v1";
async function getCode() {
const order = await fetch(`${BASE}/orders`, {
method: "POST",
headers: { "Authorization": `Bearer ${API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ service_id: 1, country_id: 1 })
}).then(r => r.json());
console.log(`Number: ${order.phone}`);
for (let i = 0; i < 60; i++) {
const status = await fetch(`${BASE}/orders/${order.id}`, {
headers: { "Authorization": `Bearer ${API_KEY}` }
}).then(r => r.json());
if (status.sms_code) { console.log(`Code: ${status.sms_code}`); return; }
await new Promise(r => setTimeout(r, 2000));
}
}
getCode();
PHP Example
$apiKey = "your_api_key";
$base = "https://smscodex.com/api/v1";
$ch = curl_init("$base/orders");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer $apiKey", "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(["service_id" => 1, "country_id" => 1]),
CURLOPT_RETURNTRANSFER => true,
]);
$order = json_decode(curl_exec($ch), true);
curl_close($ch);
echo "Phone: " . $order["phone"] . "\n";
for ($i = 0; $i < 60; $i++) {
$ch = curl_init("$base/orders/{$order['id']}");
curl_setopt_array($ch, [CURLOPT_HTTPHEADER => ["Authorization: Bearer $apiKey"], CURLOPT_RETURNTRANSFER => true]);
$status = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!empty($status["sms_code"])) { echo "Code: " . $status["sms_code"] . "\n"; break; }
sleep(2);
}
Key Endpoints
GET /api/v1/services— list of services and pricesGET /api/v1/countries— available countriesPOST /api/v1/orders— buy a numberGET /api/v1/orders/:id— order status and SMS codeDELETE /api/v1/orders/:id— cancel (auto-refund)GET /api/v1/balance— account balance
What's Next
Full documentation with Swagger UI is available in the API Docs section. You'll also find ready-made SDKs for Python, Node.js, and PHP.