PostnomicClientOptions
Both the ASP.NET Core and Blazor Client SDKs use the PostnomicClientOptions class for configuration. This class is defined in the Postnomic.Client.Abstractions package and controls how your application connects to the Postnomic API.
Available Properties
| Property | Type | Required | Description |
|---|---|---|---|
| BaseUrl | string |
Yes | The base URL of the Postnomic API (e.g., https://api.postnomic.com) |
| ApiKey | string |
Yes | Your blog's API key, prefixed with pk_ |
| BlogSlug | string |
Yes | The slug identifying which blog to display |
| ShowBranding | bool |
No | Fallback value for the "Powered by Postnomic" banner before blog info loads from the API. The server determines the actual value based on subscription tier. Defaults to false. |
Configuration Methods
Inline Configuration
The most straightforward approach — configure options directly in Program.cs:
builder.Services.AddPostnomicBlog(options =>
{
options.BaseUrl = "https://api.postnomic.com";
options.ApiKey = "pk_your_blog_key_here";
options.BlogSlug = "my-dev-blog";
});
Configuration from appsettings.json
For environment-specific settings, bind options from your configuration:
{
"PostnomicClient": {
"BaseUrl": "https://api.postnomic.com",
"ApiKey": "pk_your_blog_key_here",
"BlogSlug": "my-dev-blog"
}
}
builder.Services.AddPostnomicBlog(
builder.Configuration.GetSection("PostnomicClient")
);
Environment-Specific Configuration
Use appsettings.Development.json and appsettings.Production.json to configure different API endpoints per environment:
// appsettings.Development.json
{
"PostnomicClient": {
"BaseUrl": "https://localhost:7100"
}
}
// appsettings.Production.json
{
"PostnomicClient": {
"BaseUrl": "https://api.postnomic.com"
}
}
Branding and Free-Tier Advertising
The "Powered by Postnomic" banner is controlled server-side. The GET /public/blogs/{blogSlug} response includes a showBranding field, and the Client SDK uses that value to decide whether to render the banner. The server applies the following rules:
- No owner (legacy blog): branding is never shown
- Owner on a paid plan (Plus, Pro, or Enterprise — Active or Trialing): branding is never shown
- Owner on the Free plan or with no active subscription: branding is shown
You do not need to configure ShowBranding in your client options. The server handles it automatically based on the blog owner's subscription tier. Upgrading to any paid plan removes the banner immediately, with no client-side configuration change required.
PostnomicClientOptions.ShowBranding is a fallback value only. It is used before the blog info response has loaded (for example, during the initial render) or if the API is temporarily unreachable. Once the blog info loads, the server's value takes precedence regardless of what you set locally.
If you want to acknowledge the expected branding state explicitly in your configuration, the option is still available:
builder.Services.AddPostnomicBlog(options =>
{
options.BaseUrl = "https://api.postnomic.com";
options.ApiKey = "pk_your_blog_key_here";
options.BlogSlug = "my-dev-blog";
options.ShowBranding = true; // Optional fallback — server value takes precedence
});
Getting Your API Key
API keys are managed per blog through the Postnomic dashboard:
- Log in to the dashboard and select your blog
- Navigate to Settings → API Keys
- Click Create API Key and provide a descriptive name
- Copy the generated key — it starts with the
pk_prefix
Each blog can have multiple API keys. Use separate keys for different environments or applications so you can revoke individual keys without affecting other deployments.
The IPostnomicBlogService Interface
The Client SDK registers an IPostnomicBlogService implementation that you can inject into your own components or services if you need programmatic access beyond the built-in pages:
public class MyService
{
private readonly IPostnomicBlogService _blogService;
public MyService(IPostnomicBlogService blogService)
{
_blogService = blogService;
}
public async Task<PostnomicBlogInfo?> GetBlogAsync()
{
return await _blogService.GetBlogInfoAsync();
}
}
The service provides methods for retrieving blog info, post listings, post details, author profiles, and more — all authenticated automatically via the configured API key.
Security Best Practices
- Never commit API keys to source control. Use environment variables, user secrets, or Azure Key Vault.
- Use separate keys for development, staging, and production.
- Rotate keys periodically and revoke keys that are no longer in use.
- API keys are read-only — they grant access to public blog content only, not to management operations.