SMSAPI.pl
3.0.0
dotnet add package SMSAPI.pl --version 3.0.0
NuGet\Install-Package SMSAPI.pl -Version 3.0.0
<PackageReference Include="SMSAPI.pl" Version="3.0.0" />
<PackageVersion Include="SMSAPI.pl" Version="3.0.0" />
<PackageReference Include="SMSAPI.pl" />
paket add SMSAPI.pl --version 3.0.0
#r "nuget: SMSAPI.pl, 3.0.0"
#:package SMSAPI.pl@3.0.0
#addin nuget:?package=SMSAPI.pl&version=3.0.0
#tool nuget:?package=SMSAPI.pl&version=3.0.0
SMSAPI C# client
Client library for the SMSAPI messaging platform. Works with smsapi.io, smsapi.pl and smsapi.com accounts.
Requirements
- .NET 6.0 or newer (
net6.0,net7.0,net8.0,net9.0,net10.0)
Dependencies
Installed automatically by NuGet:
- Newtonsoft.Json >= 13.0.3
No other third-party packages are required. HTTP communication uses the built-in System.Net.Http.HttpClient.
Installation
dotnet add package SMSAPI.pl
or in Package Manager Console:
Install-Package SMSAPI.pl
Quick start
using SMSApi.Api;
var client = new ClientOAuth("token");
var features = new Features(client);
var result = features.SMS()
.ActionSend("4850010010", "Hello world")
.SetSender("Test")
.Execute();
Console.WriteLine($"Sent: {result.Count}");
More examples for every feature are in the examples/ directory.
Authentication
Only OAuth bearer tokens are supported. Generate a token in the SMSAPI panel
(smsapi.pl / smsapi.com)
and pass it to ClientOAuth:
var client = new ClientOAuth("token");
Basic (username/password) authentication was removed in 3.0.
How to pick a service?
Features (and every *Factory) accepts a ProxyAddress. Default is smsapi.io.
var features = new Features(client); // smsapi.io (default)
var features = new Features(client, ProxyAddress.SmsApiPl); // api.smsapi.pl
var features = new Features(client, ProxyAddress.SmsApiCom); // api.smsapi.com
Backup endpoints ProxyAddress.BackupSmsApiPl and ProxyAddress.BackupSmsApiCom are available as well.
Features
Every feature is reached through an extension method on Features:
| Feature | Accessor | Examples |
|---|---|---|
| SMS (send, get status, delete scheduled, fallback, templates) | features.SMS() |
examples/sms |
| MMS | features.MMS() |
examples/mms |
| VMS (text-to-speech, audio file) | features.VMS() |
examples/vms |
| HLR lookups | features.HLR() |
examples/hlr |
| MFA codes | features.MFA() |
examples/mfa |
| Sender names | features.Sendernames() |
examples/sendernames |
| Short URLs | features.ShortUrl() |
examples/shortUrl |
| Contacts, groups, fields | features.Contacts() |
examples/contacts |
| Subusers | features.Subusers() |
examples/subusers |
| Blacklist | features.Blacklist() |
examples/blacklist |
| Opt-out | features.OptOut() |
examples/optOut |
| Profile, points | features.Profile() |
examples/profile |
| Prices | features.Prices() |
examples/profile/prices |
| Ping | features.Ping() |
examples/ping |
Listings support pagination through Limit / Offset — see examples/Pagination.cs.
Async
Every action can be executed asynchronously:
var result = await features.SMS()
.ActionSend("4850010010", "Hello world")
.ExecuteAsync(cancellationToken);
Custom HttpClient and proxy
By default the library creates its own HttpClient. To reuse your own instance (e.g. configured with a web proxy,
timeouts or IHttpClientFactory), pass it to Features:
var httpClient = new HttpClient(new HttpClientHandler
{
Proxy = new WebProxy("http://proxy.example.com:8080"),
});
var features = new Features(client, httpClient, ProxyAddress.SmsApiPl);
To point the client at a different base URL (e.g. a test environment), build the transport yourself:
var proxy = new ProxyHTTP("https://api.example.com", httpClient);
var features = new Features(client, proxy);
Error handling
All API errors derive from SmsapiException, which exposes the error Code and, where available, the raw API
Response.
try
{
var result = features.SMS()
.ActionSend("4850010010", "Hello world")
.Execute();
}
catch (ActionException e)
{
// Action error, e.g. invalid sender name, empty message
Console.WriteLine($"{e.Code}: {e.Message}");
}
catch (ClientException e)
{
// Client error, e.g. 101 invalid token, 103 insufficient credits
// (full list of codes in the SMSAPI docs: https://www.smsapi.pl/docs)
Console.WriteLine($"{e.Code}: {e.Message}");
}
catch (HostException e)
{
// Server error or malformed API response (code -1, raw body in e.Response)
Console.WriteLine($"{e.Code}: {e.Message}");
}
catch (ProxyException e)
{
// Communication problem between the client and the server
Console.WriteLine(e.Message);
}
REST endpoints (contacts, sender names, short URLs, subusers, opt-out, blacklist, MFA, HLR) additionally throw typed
exceptions from smsapi.Api.Response.REST.Exception — ValidationException (with ValidationErrors),
NotFoundException (base for feature-specific ones like OptOutNotFoundException), UnauthorizedException, AccessForbiddenException, TooManyRequestsException,
ServiceUnavailableException — and feature-specific ones such as ContactAlreadyExistsException or
ShortUrlWithNameAlreadyExistsException.
Upgrading from 2.x
See CHANGELOG.md for the full list of breaking changes in 3.0.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 is compatible. 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 is compatible. 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 is compatible. 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. |
-
net10.0
- Newtonsoft.Json (>= 13.0.3)
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
-
net7.0
- Newtonsoft.Json (>= 13.0.3)
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
-
net9.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 3.0.0 | 74 | 10/21/2026 | |
| 2.2.1 | 11,206 | 5/19/2026 | |
| 2.2.0 | 193,538 | 5/16/2023 | |
| 2.1.0 | 18,057 | 4/12/2023 | |
| 2.0.1 | 16,308 | 1/20/2023 | |
| 1.0.9 | 145,901 | 5/13/2020 | |
| 1.0.8 | 4,234 | 3/31/2020 | |
| 1.0.7 | 20,095 | 2/10/2020 | |
| 1.0.6 | 3,494 | 2/3/2020 | |
| 1.0.5 | 3,544 | 2/3/2020 | |
| 1.0.4 | 4,301 | 1/17/2020 | |
| 1.0.3 | 32,260 | 1/5/2016 | |
| 1.0.2 | 4,594 | 11/27/2015 | |
| 1.0.1 | 6,502 | 11/24/2015 | |
| 1.0.0 | 4,660 | 10/6/2015 |
3.0.0: OAuth-only authentication, RestSharp replaced with HttpClient, async support, new features (MFA, HLR, Blacklist, Opt-out, Short URLs, Subusers, Sender names, Profile, Prices, Ping), .NET 6-10. See CHANGELOG.md for breaking changes.