Posty5.HtmlHosting
2.0.0
dotnet add package Posty5.HtmlHosting --version 2.0.0
NuGet\Install-Package Posty5.HtmlHosting -Version 2.0.0
<PackageReference Include="Posty5.HtmlHosting" Version="2.0.0" />
<PackageVersion Include="Posty5.HtmlHosting" Version="2.0.0" />
<PackageReference Include="Posty5.HtmlHosting" />
paket add Posty5.HtmlHosting --version 2.0.0
#r "nuget: Posty5.HtmlHosting, 2.0.0"
#:package Posty5.HtmlHosting@2.0.0
#addin nuget:?package=Posty5.HtmlHosting&version=2.0.0
#tool nuget:?package=Posty5.HtmlHosting&version=2.0.0
Posty5.HtmlHosting
Deploy and manage static HTML pages with the Posty5 .NET SDK. This package provides a complete C# client for creating, updating, and managing hosted HTML pages with features like GitHub integration, form submission tracking, monetization, and analytics.
π What is Posty5?
Posty5 is a comprehensive suite of free online tools designed to enhance your digital marketing and social media presence. With over 4+ powerful tools and counting, Posty5 provides everything you need to:
- π Shorten URLs - Create memorable, trackable short links
- π± Generate QR Codes - Transform URLs, WiFi credentials, contact cards, and more into scannable codes
- π Host HTML Pages - Deploy static HTML pages with dynamic variables and form submission handling
- π’ Automate Social Media - Schedule and manage social media posts across multiple platforms
- π Track Performance - Monitor and analyze your digital marketing efforts
Posty5 empowers businesses, marketers, and developers to streamline their online workflowsβall from a unified control panel.
Learn more: https://posty5.com
π¦ About This Package
Posty5.HtmlHosting is a specialized tool package for deploying and managing static HTML pages through the Posty5 platform. It enables developers to quickly host landing pages, product pages, portfolios, and any static HTML content with professional features.
Key Capabilities
- π File Upload Hosting - Upload HTML files directly to high-performance cloud storage
- π GitHub Integration - Deploy HTML files directly from GitHub repositories
- π Analytics & Tracking - Monitor page views, visitor locations, devices, and more
- π° Monetization - Generate revenue through embedded advertisements
- π Form Submission Tracking - Capture and track form submissions automatically
- π Dynamic Variables - Inject real-time data into your static pages
- π± Google Sheets Integration - Auto-save form data to Google Sheets
- π API Key Filtering - Scope resources by API key for multi-tenant applications
- β‘ High Performance - Fast global CDN delivery with caching
- π Secure Hosting - HTTPS enabled with 24/7 security monitoring
Role in the Posty5 Ecosystem
This package works seamlessly with other Posty5 SDK packages:
- Use
Posty5.HtmlHostingVariablesto manage dynamic variables - Use
Posty5.HtmlHostingFormSubmissionto handle form submissions - Use
Posty5.ShortLinkto create shortened URLs for your pages - Use
Posty5.QRCodeto generate QR codes linking to your pages
Perfect for developers, marketers, designers, and entrepreneurs who need fast, reliable HTML hosting with built-in tracking and monetization capabilities.
π₯ Installation
Install via NuGet Package Manager:
dotnet add package Posty5.HtmlHosting
Or via Package Manager Console:
Install-Package Posty5.HtmlHosting
π Quick Start
Here's a minimal example to get you started:
using System.Text;
using Posty5.Core.Configuration;
using Posty5.Core.Http;
using Posty5.HtmlHosting;
using Posty5.HtmlHosting.Models;
// Initialize the HTTP client with your API key
var options = new Posty5Options
{
ApiKey = "your-api-key" // Get from https://studio.posty5.com/account/settings?tab=APIKeys
};
var httpClient = new Posty5HttpClient(options);
// Create the HTML Hosting client
var htmlHosting = new HtmlHostingClient(httpClient);
// Create and deploy an HTML page
var htmlContent = @"
<!DOCTYPE html>
<html>
<head>
<title>My Landing Page</title>
</head>
<body>
<h1>Welcome to My Page!</h1>
<p>This page is hosted on Posty5.</p>
</body>
</html>";
using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(htmlContent));
var page = await htmlHosting.CreateWithFileAsync(
new CreateHtmlPageFileRequest
{
Name = "My First Landing Page", // Page name for your dashboard
FileName = "landing.html" // File name
},
fileStream
);
Console.WriteLine($"Page URL: {page.ShorterLink}");
Console.WriteLine($"Page ID: {page.Id}");
π API Reference & Examples
Creating HTML Pages
CreateWithFileAsync
Upload an HTML file to create a hosted page.
Parameters:
data(CreateHtmlPageFileRequest): Configuration for the pageName(string): Display name for the page in your dashboardFileName(string): Name of the HTML fileCustomLandingId(string?, optional): Custom URL identifierIsEnableMonetization(bool?, optional): Enable ad monetizationAutoSaveInGoogleSheet(bool?, optional): Auto-save form data to Google SheetsTag(string?, optional): Tag for categorizationRefId(string?, optional): Your custom reference ID
fileStream(Stream): The HTML file content streamcontentType(string, optional): Content type (default: "text/html")
Returns: Task<HtmlPageFileResponse>
Id(string): Unique page IDShorterLink(string): Public URL to access the pageFileUrl(string): Direct URL to the uploaded file
Example:
// Basic page creation
var htmlContent = "<html><body><h1>Hello World</h1></body></html>";
using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(htmlContent));
var page = await htmlHosting.CreateWithFileAsync(
new CreateHtmlPageFileRequest
{
Name = "Simple Page",
FileName = "index.html"
},
fileStream
);
Console.WriteLine($"Live URL: {page.ShorterLink}");
// Page with custom URL and monetization
var page = await htmlHosting.CreateWithFileAsync(
new CreateHtmlPageFileRequest
{
Name = "Product Launch Page",
FileName = "product.html",
CustomLandingId = "product-2024", // Custom URL: posty5.com/product-2024
IsEnableMonetization = true, // Enable ads for revenue
Tag = "marketing",
RefId = "campaign-spring-2024"
},
fileStream
);
// Page with form submission tracking
var page = await htmlHosting.CreateWithFileAsync(
new CreateHtmlPageFileRequest
{
Name = "Contact Form",
FileName = "contact.html",
AutoSaveInGoogleSheet = true, // Auto-save form data to Google Sheets
Tag = "forms"
},
fileStream
);
CreateWithGithubFileAsync
Deploy an HTML file directly from a GitHub repository.
Parameters:
data(CreateHtmlPageGithubRequest): Configuration for the pageName(string): Display name for the pageGithubInfo(GithubInfo): GitHub file informationFileURL(string): Full GitHub file URL (e.g.,https://github.com/user/repo/blob/main/index.html)
CustomLandingId(string?, optional): Custom URL identifierIsEnableMonetization(bool?, optional): Enable monetizationAutoSaveInGoogleSheet(bool?, optional): Auto-save form dataTag(string?, optional): Tag for categorizationRefId(string?, optional): Your custom reference ID
Returns: Task<HtmlPageGithubResponse>
Id(string): Unique page IDShorterLink(string): Public URL to access the pageGithubInfo(GithubInfo): GitHub file information
Example:
// Deploy from GitHub
var page = await htmlHosting.CreateWithGithubFileAsync(new CreateHtmlPageGithubRequest
{
Name = "Portfolio Site",
GithubInfo = new GithubInfo
{
FileURL = "https://github.com/username/portfolio/blob/main/index.html"
}
});
Console.WriteLine($"Deployed URL: {page.ShorterLink}");
// GitHub deployment with all options
var page = await htmlHosting.CreateWithGithubFileAsync(new CreateHtmlPageGithubRequest
{
Name = "Open Source Landing Page",
GithubInfo = new GithubInfo
{
FileURL = "https://github.com/Netflix/netflix.github.com/blob/master/index.html"
},
CustomLandingId = "oss-project",
IsEnableMonetization = false, // No ads on this page
Tag = "open-source",
RefId = "github-deploy-001"
});
Retrieving HTML Pages
GetAsync
Retrieve details of a specific HTML page by ID.
Parameters:
id(string): The unique page ID
Returns: Task<HtmlPageModel> - Complete page details
Example:
var page = await htmlHosting.GetAsync("page-id-123");
Console.WriteLine($"Page Name: {page.Name}");
Console.WriteLine($"URL: {page.ShorterLink}");
Console.WriteLine($"Created: {page.CreatedAt}");
if (page.SourceType == "github")
{
Console.WriteLine($"GitHub URL: {page.GithubInfo?.FileURL}");
}
ListAsync
Search and filter HTML pages with pagination.
Parameters:
listParams(ListHtmlPagesParams, optional): Filter criteriaName(string): Search by page nameSourceType(string): Filter by source type ('file' or 'github')Tag(string): Filter by tagRefId(string): Filter by reference IDIsEnableMonetization(bool?): Filter by monetization statusAutoSaveInGoogleSheet(bool?): Filter by Google Sheets integrationIsTemp(bool?): Filter temporary pages
pagination(PaginationParams, optional): Pagination optionsPageNumber(int): Page number (default: 1) -- Note: C# uses PageNumber vs TS 'page'PageSize(int): Items per page (default: 10)
Returns: Task<PaginationResponse<HtmlPageModel>>
Example:
// Get all pages with pagination
var result = await htmlHosting.ListAsync(
null,
new PaginationParams { PageNumber = 1, PageSize = 20 }
);
Console.WriteLine($"Found {result.Pagination.TotalItems} pages");
foreach (var page in result.Data)
{
Console.WriteLine($"- {page.Name}: {page.ShorterLink}");
}
// Search by name
var result = await htmlHosting.ListAsync(
new ListHtmlPagesParams { Name = "landing" },
new PaginationParams { PageNumber = 1, PageSize = 10 }
);
// Filter by multiple criteria
var filtered = await htmlHosting.ListAsync(new ListHtmlPagesParams
{
SourceType = "file", // Only uploaded files
IsEnableMonetization = true, // Only monetized pages
Tag = "marketing" // Tagged as 'marketing'
});
// Get pages by your reference ID
var myPages = await htmlHosting.ListAsync(new ListHtmlPagesParams
{
RefId = "campaign-2024-q1"
});
LookupAsync
Get a simplified list of pages (ID and name only). Useful for dropdowns and selection lists.
Returns: Task<List<HtmlPageLookupItem>> - List of objects with Id and Name.
Example:
var pages = await htmlHosting.LookupAsync();
// Use in a dropdown or list
foreach (var page in pages)
{
Console.WriteLine($"ID: {page.Id}, Name: {page.Name}");
}
LookupFormsAsync
Get form IDs detected in an HTML page (useful for form submission tracking).
Parameters:
id(string): HTML page ID
Returns: Task<List<FormLookupItem>> - List of form information
Example:
var forms = await htmlHosting.LookupFormsAsync("page-id-123");
Console.WriteLine($"Found {forms.Count} forms on this page");
foreach (var form in forms)
{
Console.WriteLine($"Form ID: {form.Id}, Name: {form.Name}");
}
Updating HTML Pages
UpdateWithFileAsync
Update an existing page with a new HTML file.
Parameters:
id(string): Page ID to updatedata(UpdateHtmlPageFileRequest): Update configurationName(string?): New page nameFileName(string): New file nameCustomLandingId(string?): New custom URLIsEnableMonetization(bool?): Toggle monetizationAutoSaveInGoogleSheet(bool?): Toggle Google SheetsTag(string?): New tagRefId(string?): New reference ID
fileStream(Stream): New HTML file content stream
Returns: Task<HtmlPageFileResponse>
Example:
var updatedContent = "<html><body><h1>Content has been updated!</h1></body></html>";
using var fileStream = new MemoryStream(Encoding.UTF8.GetBytes(updatedContent));
var updated = await htmlHosting.UpdateWithFileAsync(
"page-id-123",
new UpdateHtmlPageFileRequest
{
Name = "Updated Landing Page",
FileName = "landing-v2.html"
},
fileStream
);
Console.WriteLine($"Updated URL: {updated.ShorterLink}");
UpdateWithGithubFileAsync
Update a page to use a different GitHub file or update GitHub settings.
Parameters:
id(string): Page ID to updatedata(UpdateHtmlPageGithubRequest): Update configurationName(string?): New page nameGithubInfo(GithubInfo): New GitHub file information- ... other optional fields same as create
Returns: Task<HtmlPageGithubResponse>
Example:
var updated = await htmlHosting.UpdateWithGithubFileAsync(
"page-id-123",
new UpdateHtmlPageGithubRequest
{
Name = "Updated from GitHub",
GithubInfo = new GithubInfo
{
FileURL = "https://github.com/username/repo/blob/main/updated.html"
},
IsEnableMonetization = false
}
);
Page Operations
CleanCacheAsync
Clear the cache for a page to force fresh content delivery. Useful after updating content.
Parameters:
id(string): HTML page ID
Returns: Task
Example:
// Clear cache after updating external content
await htmlHosting.CleanCacheAsync("page-id-123");
Console.WriteLine("Cache cleared - fresh content will be served");
DeleteAsync
Permanently delete an HTML page.
Parameters:
id(string): HTML page ID to delete
Returns: Task
Example:
await htmlHosting.DeleteAsync("page-id-123");
Console.WriteLine("Page deleted successfully");
π Error Handling
All methods may throw exceptions from Posty5.Core.Exceptions. Handle them appropriately:
using Posty5.Core.Exceptions;
try
{
var page = await htmlHosting.GetAsync("invalid-id");
}
catch (Posty5AuthenticationException ex)
{
Console.WriteLine("Invalid API key");
}
catch (Posty5NotFoundException ex)
{
Console.WriteLine("Page not found");
}
catch (Posty5ValidationException ex)
{
Console.WriteLine($"Invalid data: {ex.Message}");
}
catch (Posty5RateLimitException ex)
{
Console.WriteLine("Rate limit exceeded");
}
catch (Posty5Exception ex)
{
Console.WriteLine($"Unexpected error: {ex.Message}");
}
π Resources
- Official Guides: https://guide.posty5.com
- API Reference: https://docs.posty5.com
- Source Code: https://github.com/Posty5/dotnet-sdk
π¦ Packages
This SDK ecosystem contains the following tool packages:
| Package | Description | Version | NuGet |
|---|---|---|---|
| Posty5.Core | Core HTTP client and models | 1.0.0 | π¦ NuGet |
| Posty5.ShortLink | URL shortener client | 1.0.0 | π¦ NuGet |
| Posty5.QRCode | QR code generator client | 1.0.0 | π¦ NuGet |
| Posty5.HtmlHosting | HTML hosting client | 1.0.0 | π¦ NuGet |
| Posty5.HtmlHostingVariables | Variable management | 1.0.0 | π¦ NuGet |
| Posty5.HtmlHostingFormSubmission | Form submission management | 1.0.0 | π¦ NuGet |
| Posty5.SocialPublisherWorkspace | Social workspace management | 1.0.0 | π¦ NuGet |
| Posty5.SocialPublisherTask | Social publishing task client | 1.0.0 | π¦ NuGet |
π Support
MIT License - see LICENSE file for details.
Made with β€οΈ by the Posty5 team
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net8.0
- Posty5.Core (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.