s00d / onlinesim-api
PHP client for the OnlineSim API: SMS numbers, rent, account and free numbers.
2.1.1
2026-11-20 08:41 UTC
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
- ergebnis/composer-normalize: ^2.58
- friendsofphp/php-cs-fixer: ^3.64
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.5 || ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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