Skip to main content

onlinesim 1.0.1 copy "onlinesim: ^1.0.1" to clipboard
onlinesim: ^1.0.1 copied to clipboard

Typed Dart client for the OnlineSim SMS API: numbers, rent, account, free numbers and webhooks, with a built-in offline mock for tests. Flutter and web.

onlinesim #

pub package CI

Typed Dart client for the OnlineSim API: SMS numbers, rent, account and free numbers. Pure Dart on package:http: Flutter, CLI, server and web.

dart pub add onlinesim
import 'package:onlinesim/onlinesim.dart';

Future<void> main() async {
  final client = OnlineSim(apiKey: 'your-api-key');

  final balance = await client.user.balance();
  print('available: ${balance.available} USD');

  final order = await client.numbers.getWithNumber('google', country: 44);
  print('enter ${order.number} in the app');
  print('code: ${await client.numbers.waitCode(order.tzid)}');
  client.close();
}

Testing #

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

import 'package:onlinesim/onlinesim.dart';

Future<void> main() async {
  final mock = MockOnlineSim(balance: 10);
  final client = mock.client();

  final tzid = await client.numbers.get('google', country: 44);
  mock.addSmsAfter(tzid, 'Your code: 123-456', 2); // arrives on the third poll
  final code = await client.numbers.waitCode(tzid, interval: Duration.zero);

  if (code != '123456' || mock.balance() != 9.8) throw StateError('unexpected');
  print('ok: $code');
}

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

0
likes
160
points
29
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Typed Dart client for the OnlineSim SMS API: numbers, rent, account, free numbers and webhooks, with a built-in offline mock for tests. Flutter and web.

Homepage
Repository (GitHub)
View/report issues

Topics

#sms #api #onlinesim #otp

License

Apache-2.0 (license)

Dependencies

http

More

Packages that depend on onlinesim