Search by

darkspiritali-ai / onaynet-sdk

darkspiritali-ai

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

Homepage

Documentation

Language:JavaScript

pkg:composer/darkspiritali-ai/onaynet-sdk

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2026-11-25 14:12 UTC

This package is auto-updated.

Last update: 2026-12-02 18:56:14 UTC


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.

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. listServices returns indicative stock and prices; a number can still be unavailable when you buy.
  • Safe retries. Pass idempotencyKey to buyNumber (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, check listOrders before retrying.
  • Refunds follow the refund policy on the website. cancelOrder works 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 from listCountries() and listServices().
  • 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 idempotencyKey for buyNumber and banOrder. Fixed defaults and field names to match the real API: country and service are slugs (default usa, not 187); the code is read from latest_code (previously waitForOtp never saw it and always timed out); status CANCELED; added listOrders, maxPrice, voice; corrected TypeScript types and the OpenAPI file; removed marketing claims that could not be verified.
  • 1.0.0 – Initial release.

License: MIT