Code samples, one task at a time
Each recipe below does one job. They read your key from an environment variable named SMMVIA_KEY, so the key never sits in the code. Service 205, order numbers 80412 and 80413 and the post link are invented for this page; replace them with values from your own account. A real add call spends real balance.
POSThttps://smmvia.com/api/v2
Field meanings are in the reference; the rules behind them are on the developer overview.
Task 1: read your balance
Task 2: find a service number
Filter the list by category or name in your own code, then keep the service number. The rate shown is your personal price per 1,000.
<?php
function via(string $action, array $fields = []): array {
$ch = curl_init('https://smmvia.com/api/v2');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_POSTFIELDS => http_build_query(['key' => getenv('SMMVIA_KEY'), 'action' => $action] + $fields),
]);
$reply = json_decode(curl_exec($ch), true);
if (isset($reply['error'])) { throw new RuntimeException($reply['error']); }
return $reply;
}
foreach (via('services') as $row) {
echo $row['service'], ' ', $row['rate'], ' ', $row['min'], '-', $row['max'], ' ', $row['name'], PHP_EOL;
}
Task 3: place one order
Send add once and store the returned number before doing anything else. If the call times out, check your Orders page before trying again, because a second add is a second paid order.
const ENDPOINT = "https://smmvia.com/api/v2";
async function via(action, fields = {}) {
const body = new URLSearchParams({ key: process.env.SMMVIA_KEY, action, ...fields });
const reply = await (await fetch(ENDPOINT, { method: "POST", body })).json();
if (reply && reply.error) throw new Error(reply.error);
return reply;
}
const placed = await via("add", { service: "205", link: "https://t.me/your_channel/57", quantity: "100" });
console.log("new order", placed.order);
Task 4: poll until every order is final
One status call covers up to 100 IDs. Ask every few minutes, and remove an order from the list once it is final. A Canceled order still showing a charge above zero is not settled yet, so keep it in the loop.
import time
open_ids = {80412, 80413}
DONE = {"Completed", "Partial", "Refunded"}
while open_ids:
batch = ",".join(str(i) for i in sorted(open_ids)[:100])
reply = via("status", orders=batch) or {} # [] when no ID matched
for oid, info in reply.items():
settled = info["status"] in DONE or (info["status"] == "Canceled" and float(info["charge"]) == 0)
if settled:
print(oid, info["status"], "undelivered:", info["remains"])
open_ids.discard(int(oid))
time.sleep(180)
Task 5: cancel unfinished orders
Each row of the reply is either 1 (stopped, undelivered part back on your balance) or an error for that ID. Retry only the rows whose error asks you to retry.
curl -s https://smmvia.com/api/v2 \
--data "key=$SMMVIA_KEY" --data "action=cancel" --data "orders=80412,80413"
Before you go live
- Test with one small order per service you plan to resell.
- Log every reply body; errors arrive with HTTP 200.
- Stay under 300 calls per minute per key, and back off on HTTP 429.
- Read the refund policy so your own customers get the same arithmetic.
Last verified: