darkspiritali-ai / onaynet-sdk
OnayNet REST API v1 documentation and OpenAPI spec. This package contains no PHP client code; use the REST API directly.
Package info
github.com/darkspiritali-ai/onaynet-sdk
Language:JavaScript
pkg:composer/darkspiritali-ai/onaynet-sdk
v1.1.0
2026-11-25 14:12 UTC
Requires
- php: >=8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Small zero-dependency clients for the OnayNet REST API v1: allocate a phone number for SMS verification, read the received code, cancel for a refund.
- API documentation: https://onaynet.co/en/api-docs (Turkish: https://onaynet.co/tr/api-docs)
- OpenAPI 3.0 spec:
openapi.json(also served at https://onaynet.co/openapi.json)
What to know first
- Server-side only. The API does not allow cross-origin browser calls. Keep your API key (
onay_live_...) on your server. - Stock is indicative.
listServicesreturns indicative stock and prices; a number can still be unavailable when you buy. - Safe retries. Pass
idempotencyKeytobuyNumber(Python:idempotency_key). After a timeout, call again with the same key and parameters and the successful purchase is returned instead of being charged twice (keys last 24 hours). Without a key, checklistOrdersbefore retrying. - Refunds follow the refund policy on the website.
cancelOrderworks only while no SMS has arrived. - Rate limits: 120 read and 30 write requests per minute per API key (HTTP 429 with
Retry-After). - Country and service values are slugs (
"usa","england","turkey","whatsapp"), not numeric IDs. Get them fromlistCountries()andlistServices(). - The PHP/Composer and Ruby packages do not contain a maintained client; use the REST API or the Node.js / Python clients.
Node.js / TypeScript (Node 18+)
npm install onaynet-sdk
import { OnayNetClient } from 'onaynet-sdk'; const client = new OnayNetClient({ apiKey: process.env.ONAYNET_API_KEY }); const order = await client.buyNumber({ service: 'openai', country: 'usa' }); console.log(order.phone, order.order_id); try { const done = await client.waitForOtp(order.order_id, { timeoutMs: 120000 }); // cancels (refund) on timeout console.log(done.latest_code); await client.finishOrder(order.order_id); } catch (err) { console.error(err.code, err.message); } const page = await client.listOrders({ limit: 20 }); // { data, has_more, next_cursor }
Python (3.8+)
Copy python/onaynet.py into your project (standard library only).
from onaynet import OnayNetClient client = OnayNetClient(api_key="onay_live_...") order = client.buy_number("openai", country="usa") done = client.wait_for_otp(order["order_id"], timeout_sec=120) # cancels (refund) on timeout print(done["latest_code"]) client.finish_order(order["order_id"])
Methods
| Method | Endpoint |
|---|---|
getBalance() |
GET /balance |
listCountries() |
GET /countries |
listServices(country) |
GET /services?country= |
buyNumber({ service, country, operator, maxPrice, voice, idempotencyKey }) |
POST /orders/buy |
listOrders({ limit, status, cursor }) |
GET /orders |
getOrder(id) |
GET /orders/:id (code in latest_code) |
cancelOrder(id) |
POST /orders/:id/cancel |
banOrder(id) |
POST /orders/:id/ban (number unusable; refunds if no SMS arrived) |
finishOrder(id) |
POST /orders/:id/finish (only after an SMS arrived) |
waitForOtp(id, options) |
polls GET /orders/:id until latest_code |
Errors throw OnayNetError with status, code (for example NO_STOCK, INSUFFICIENT_BALANCE, NO_SMS_RECEIVED) and details.
Changelog
- 1.0.1 – Also adds
idempotencyKeyforbuyNumberandbanOrder. Fixed defaults and field names to match the real API: country and service are slugs (defaultusa, not187); the code is read fromlatest_code(previouslywaitForOtpnever saw it and always timed out); statusCANCELED; addedlistOrders,maxPrice,voice; corrected TypeScript types and the OpenAPI file; removed marketing claims that could not be verified. - 1.0.0 – Initial release.
License: MIT