Search by

s00d / onlinesim-api

s00d

PHP client for the OnlineSim API: SMS numbers, rent, account and free numbers.

2.1.1 2026-11-20 08:41 UTC

README

Packagist CI

PHP client for the OnlineSim API: SMS numbers, rent, account and free numbers. PHP 8.1+, ext-curl, no runtime dependencies.

composer require s00d/onlinesim-api
use s00d\OnlineSimApi\OnlineSim;

$client = new OnlineSim(apiKey: getenv('ONLINESIM_KEY') ?: null);

$balance = $client->user->balance();
echo 'available: ', $balance['balance'] - max($balance['zbalance'], 0), " USD\n";

$order = $client->numbers->getWithNumber('google', 44);
echo "enter {$order['number']} in the app\n";
echo 'code: ', $client->numbers->waitCode($order['tzid']), "\n";

Testing

MockOnlineSim is a built-in offline fake of the API: test your integration without network, key or money. More in the testing guide.

use s00d\OnlineSimApi\Mock\MockOnlineSim;

$mock = new MockOnlineSim(balance: 10);
$client = $mock->client();

$tzid = $client->numbers->get('google', 44);
$mock->addSmsAfter($tzid, 'Your code: 123-456', 2); // arrives on the third poll
$code = $client->numbers->waitCode($tzid, interval: 0);

assert($code === '123456');
assert($mock->balance() === 9.8);

Documentation: https://s00d.github.io/onlinesim-php-api/ · Changes: CHANGELOG.md · License: Apache-2.0