.NET
Official C# client for the Zernio API. Install the Zernio NuGet package and publish to 14+ social platforms.
The official C# client for the Zernio API.
- Package:
Zernioon NuGet - Source: github.com/zernio-dev/zernio-dotnet
Install
dotnet add package ZernioQuick start
using System;
using System.Collections.Generic;
using System.Net.Http;
using Zernio.Api;
using Zernio.Client;
using Zernio.Model;
Configuration config = new Configuration();
config.BasePath = "https://zernio.com/api";
config.AccessToken = Environment.GetEnvironmentVariable("ZERNIO_API_KEY");
// Reuse HttpClient and HttpClientHandler across API classes
HttpClient httpClient = new HttpClient();
HttpClientHandler httpClientHandler = new HttpClientHandler();
var postsApi = new PostsApi(httpClient, config, httpClientHandler);
var request = new CreatePostRequest(
content: "Hello world from Zernio!",
platforms: new List<CreatePostRequestPlatformsInner>
{
new CreatePostRequestPlatformsInner(platform: "twitter", accountId: "acc_xxx"),
new CreatePostRequestPlatformsInner(platform: "linkedin", accountId: "acc_yyy"),
},
publishNow: true
);
try
{
var result = postsApi.CreatePost(request);
Console.WriteLine(result);
}
catch (ApiException e)
{
Console.WriteLine("Status code: " + e.ErrorCode);
Console.WriteLine("Message: " + e.Message);
}Get your API key from the dashboard, or see Getting started for the full setup walkthrough.
For safe retries, CreatePost accepts an idempotency key: postsApi.CreatePost(request, xRequestId: Guid.NewGuid()). Requests that reuse the same ID within ~5 minutes return the original post instead of double-posting.
List connected accounts
var accountsApi = new AccountsApi(httpClient, config, httpClientHandler);
var accounts = accountsApi.ListAccounts();
Console.WriteLine(accounts);Dependency injection
In ASP.NET Core, register API classes with IHttpClientFactory so connections are managed for you:
services.AddHttpClient<PostsApi>(httpClient => new PostsApi(httpClient));Error handling
API failures throw Zernio.Client.ApiException, which carries the HTTP status and error content:
try
{
postsApi.CreatePost(request);
}
catch (ApiException e)
{
Console.WriteLine("Status code: " + e.ErrorCode);
Console.WriteLine("Message: " + e.Message);
Console.WriteLine(e.ErrorContent);
}See the error handling guide for the API's error codes and retry semantics.
Full reference
The SDK exposes every API namespace as a class in Zernio.Api: PostsApi, AccountsApi, ProfilesApi, AnalyticsApi, QueueApi, MediaApi, WebhooksApi, AdsApi, PhoneNumbersApi, WhatsAppApi, WorkflowsApi, and more. Each method maps 1:1 to an API Reference operation.