OnlineSim.Api
1.0.1
dotnet add package OnlineSim.Api --version 1.0.1
NuGet\Install-Package OnlineSim.Api -Version 1.0.1
<PackageReference Include="OnlineSim.Api" Version="1.0.1" />
<PackageVersion Include="OnlineSim.Api" Version="1.0.1" />
<PackageReference Include="OnlineSim.Api" />
paket add OnlineSim.Api --version 1.0.1
#r "nuget: OnlineSim.Api, 1.0.1"
#:package OnlineSim.Api@1.0.1
#addin nuget:?package=OnlineSim.Api&version=1.0.1
#tool nuget:?package=OnlineSim.Api&version=1.0.1
OnlineSim.Api
Typed async C# / .NET client for the OnlineSim API: SMS numbers, rent, account and free numbers.
netstandard2.0 and net8.0: .NET Framework 4.6.2+, .NET 6/8/9+, Unity/Mono.
dotnet add package OnlineSim.Api
using OnlineSim.Api;
var client = new OnlineSimClient(Environment.GetEnvironmentVariable("ONLINESIM_KEY"));
var balance = await client.User.BalanceAsync();
Console.WriteLine($"available: {balance.Balance - Math.Max(balance.Zbalance, 0)} USD");
var order = await client.Numbers.GetWithNumberAsync("google", 44);
Console.WriteLine($"enter {order.Number} in the app");
Console.WriteLine($"code: {await client.Numbers.WaitCodeAsync(order.Tzid)}");
Testing
MockOnlineSim is a built-in offline fake of the API: test your integration without network, key or money.
More in the testing guide.
using OnlineSim.Api;
var mock = new MockOnlineSim(new MockOptions { Balance = 10 });
var client = mock.Client();
var tzid = await client.Numbers.GetAsync("google", 44);
mock.AddSmsAfter(tzid, "Your code: 123-456", 2); // arrives on the third poll
var code = await client.Numbers.WaitCodeAsync(tzid, new WaitCodeOptions { Interval = TimeSpan.Zero });
if (code != "123456" || mock.Balance() != 9.8m) throw new Exception($"unexpected: {code}, {mock.Balance()}");
Console.WriteLine($"code {code}, balance {mock.Balance()}");
Documentation: https://s00d.github.io/onlinesim-dotnet-api/ · Changes: CHANGELOG.md · License: Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 8.0.5)
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Aligned with the regenerated backend API spec.
### Fixed
- Decoding no longer fails on real answers: `RentSms.Code` accepts the integer `0` the server sends for a `notify` SMS (normalised to the string `"0"`); `Profile.Number` is `long?` and `Profile.Country` is `string?` (they were swapped; both decoded leniently).
- `Operation.Response` is `string?` (absent when no number could be issued); `FreeCountry.CountryText`/`CountryOriginal`, `FreeNumber.CountryOriginal`, `PaymentOrder.Currency` are nullable (`PaymentOrder.FormText` already was).
- `User.PaymentHistoryAsync()` no longer drops `Paylist` when the server sends it as a JSON array (ids 0, 1, 2…): a PHP list is read as an index-keyed map (`"0"`, `"1"`, …), for every map.
- Rent `Sum` is read from a number (getRentNum, extendRentState) or a decimal string (getRentState).
- `Numbers.WaitCodeAsync` retries `ApiException` `TRY_AGAIN_LATER` (HTTP 429 rate limit), `ERROR_UNDEFINED` and `INTERVAL_CONCURRENT_REQUESTS_ERROR` until its timeout instead of throwing at once.
- Error messages: `"0"` (ban not applied, the operation already has an SMS), `ACCOUNT_CLEANED`, `USER_NOT_ACTIVATED`, `ERROR_UNDEFINED`, `FORWARD_NOT_SUPPORTED` added; `ERROR_NO_KEY`, `NO_NUMBER_FOR_FORWARD`, `ACCOUNT_IDENTIFICATION_REQUIRED`, `API_DISABLED` (no longer sent) removed; `ERROR_WRONG_KEY` is "Wrong or missing API key". `NoNumberException` is thrown only for `NO_NUMBER`.
- `MockOnlineSim` follows the backend: `setOperationRevise` answers `{"tzid":"N","response":"1"}` and `ERROR_WRONG_TZID` / `ERROR_NO_TZID`; `setOperationOk` tzid `0` → `ERROR_NO_TZID`; a missing key is HTTP 200 `ERROR_WRONG_KEY` (456 only for a wrong key, also on public endpoints); `getNum` with `number` adds `title`, `response_text`, `guard_interval_remaining_seconds`. Rent: `getRentNum` reserves the price (`status` 0) and the first non-`notify` SMS confirms and charges it, unknown country → `UNDEFINED_COUNTRY`, `sum` a number in getRentNum/extendRentState and a string in getRentState, `guard_interval_remaining_seconds` with `number`; `extendRentState` refusals are all `TRY_AGAIN_LATER`; `closeRentNum` unknown tzid → `ERROR_NO_OPERATIONS`, releases the reservation of an unconfirmed rent. Webhook-log params: `code` `""` without a code, rent `number` in full digits, rent `time_left` in minutes, `time_start` per type. `profile.php` accepts any `scheme://…` URL. `getPaymentHistory` adds `forms`/`buttons`/`domains`; `getFreeList` lists 44 first, clamps `count` to 10..500, sends ISO-8601 `created_at` and `ignore`/`content`. `MockRent` exposes `Status` and `InitialDays`.
- Docs: rent reservation and `Sum`, available = Balance − max(Zbalance, 0), `BanAsync` answer `"0"`, webhook `Number`/`TimeLeft`/`TimeStart`, the `WaitCodeAsync` retry policy, the mock's behaviour.