EnvatoBuildSDK 1.0.0
See the version list below for details.
dotnet add package EnvatoBuildSDK --version 1.0.0
NuGet\Install-Package EnvatoBuildSDK -Version 1.0.0
<PackageReference Include="EnvatoBuildSDK" Version="1.0.0" />
<PackageVersion Include="EnvatoBuildSDK" Version="1.0.0" />
<PackageReference Include="EnvatoBuildSDK" />
paket add EnvatoBuildSDK --version 1.0.0
#r "nuget: EnvatoBuildSDK, 1.0.0"
#:package EnvatoBuildSDK@1.0.0
#addin nuget:?package=EnvatoBuildSDK&version=1.0.0
#tool nuget:?package=EnvatoBuildSDK&version=1.0.0
EnvatoBuildSDK
A comprehensive .NET SDK for interacting with the Envato Market API. This library provides a simple and intuitive way to access Envato's API endpoints for managing user accounts, tracking sales, retrieving item details, and accessing financial statements.
Features
- User account management
- Sales tracking and history
- Item details and catalog access
- Financial statements and transactions
- Purchase code/license verification and activation
- Fully async/await compatible
- Strongly-typed models
- Comprehensive error handling
- Support for pagination
- Cancellation token support
Installation
NuGet Package Manager
Install-Package EnvatoBuildSDK
.NET CLI
dotnet add package EnvatoBuildSDK
Package Reference
<PackageReference Include="EnvatoBuildSDK" Version="1.0.0" />
Getting Started
Prerequisites
You'll need a personal token from Envato to use this SDK:
- Log in to your Envato account
- Navigate to Settings > API Keys
- Generate a new Personal Token with the required permissions
Basic Usage
using EnvatoBuildSDK.Api;
using EnvatoBuildSDK.Api.Models;
// Initialize the client with your personal token
using var client = new EnvatoClient("your-personal-token-here");
// Get user account information
var user = await client.GetUserAccountAsync();
Console.WriteLine($"Username: {user.Username}");
Console.WriteLine($"Sales: {user.Sales}");
Console.WriteLine($"Balance: ${user.Balance}");
API Examples
User Account Operations
// Get full account details
var account = await client.GetUserAccountAsync();
Console.WriteLine($"Name: {account.FirstName} {account.Surname}");
Console.WriteLine($"Email: {account.Email}");
Console.WriteLine($"Country: {account.Country}");
// Get just the username
var username = await client.GetUsernameAsync();
Console.WriteLine($"Logged in as: {username}");
Sales Management
// Get all sales (first page)
var sales = await client.GetSalesAsync();
foreach (var sale in sales)
{
Console.WriteLine($"Item: {sale.Item?.Name}");
Console.WriteLine($"Buyer: {sale.Buyer}");
Console.WriteLine($"Amount: {sale.Amount}");
Console.WriteLine($"Date: {sale.SoldAt}");
Console.WriteLine($"License: {sale.License}");
Console.WriteLine();
}
// Get sales with pagination
var page2Sales = await client.GetSalesAsync(page: 2);
Item Details
// Get details for a specific item
long itemId = 12345678;
var item = await client.GetItemAsync(itemId);
Console.WriteLine($"Name: {item.Name}");
Console.WriteLine($"Description: {item.Description}");
Console.WriteLine($"Price: ${item.PriceCents / 100.0}");
Console.WriteLine($"Sales: {item.NumberOfSales}");
Console.WriteLine($"Rating: {item.Rating?.RatingValue} ({item.Rating?.Count} reviews)");
Console.WriteLine($"Author: {item.AuthorUsername}");
Console.WriteLine($"URL: {item.Url}");
Financial Statements
// Get all statements
var statements = await client.GetStatementsAsync();
foreach (var statement in statements)
{
Console.WriteLine($"Date: {statement.OccurredAt}");
Console.WriteLine($"Type: {statement.Kind}");
Console.WriteLine($"Amount: {statement.Amount}");
Console.WriteLine($"Balance: {statement.Balance}");
Console.WriteLine($"Detail: {statement.Detail}");
Console.WriteLine();
}
// Get statements with date filtering
var startDate = new DateTime(2024, 1, 1);
var endDate = new DateTime(2024, 12, 31);
var filteredStatements = await client.GetStatementsAsync(
fromDate: startDate,
toDate: endDate
);
// Get statements with pagination
var page1 = await client.GetStatementsAsync(page: 1);
License/Purchase Code Verification
// Verify a purchase code when a customer activates their license
string purchaseCode = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
try
{
var verification = await client.VerifyPurchaseCodeAsync(purchaseCode);
Console.WriteLine($"Valid Purchase: {verification.IsValid}");
Console.WriteLine($"Buyer: {verification.Buyer}");
Console.WriteLine($"Item: {verification.Item?.Name}");
Console.WriteLine($"Purchase Date: {verification.SoldAt}");
Console.WriteLine($"License Type: {verification.License}");
Console.WriteLine($"Amount Paid: {verification.Amount}");
Console.WriteLine($"Support Until: {verification.SupportedUntil}");
Console.WriteLine($"Support Active: {verification.IsSupportActive}");
}
catch (EnvatoApiException ex)
{
Console.WriteLine($"Invalid purchase code: {ex.Message}");
}
// Quick validation check
bool isValid = await client.IsPurchaseCodeValidAsync(purchaseCode);
if (isValid)
{
Console.WriteLine("License activated successfully!");
}
// Check if support is still active
bool hasSupport = await client.IsSupportActiveAsync(purchaseCode);
if (!hasSupport)
{
Console.WriteLine("Support has expired. Please renew for continued support.");
}
// Get buyer information
string buyer = await client.GetBuyerFromPurchaseCodeAsync(purchaseCode);
Console.WriteLine($"Licensed to: {buyer}");
// Get the item ID for database storage
long? itemId = await client.GetItemIdFromPurchaseCodeAsync(purchaseCode);
Complete License Activation Flow
public async Task<bool> ActivateLicenseAsync(string purchaseCode, string domain)
{
try
{
// Step 1: Verify the purchase code is valid
var verification = await client.VerifyPurchaseCodeAsync(purchaseCode);
if (!verification.IsValid)
{
Console.WriteLine("Invalid purchase code");
return false;
}
// Step 2: Check if the purchase is for the correct item
if (verification.Item?.Id != YOUR_ITEM_ID)
{
Console.WriteLine("This purchase code is for a different product");
return false;
}
// Step 3: Store activation in your database
await SaveActivationToDatabase(new
{
PurchaseCode = purchaseCode,
Buyer = verification.Buyer,
Domain = domain,
ItemId = verification.Item.Id,
ItemName = verification.Item.Name,
ActivatedAt = DateTime.UtcNow,
SupportUntil = verification.SupportedUntil,
LicenseType = verification.License
});
// Step 4: Return success
Console.WriteLine($"License activated for {verification.Buyer} on {domain}");
Console.WriteLine($"Support valid until: {verification.SupportedUntil}");
return true;
}
catch (EnvatoApiException ex)
{
Console.WriteLine($"Activation failed: {ex.Message}");
return false;
}
}
Advanced Usage
Using Dependency Injection
// In Startup.cs or Program.cs
services.AddHttpClient<EnvatoClient>((serviceProvider, httpClient) =>
{
var token = serviceProvider.GetRequiredService<IConfiguration>()["Envato:PersonalToken"];
return new EnvatoClient(token, httpClient);
});
// In your service or controller
public class MyService
{
private readonly EnvatoClient _envatoClient;
public MyService(EnvatoClient envatoClient)
{
_envatoClient = envatoClient;
}
public async Task<User> GetUserInfo()
{
return await _envatoClient.GetUserAccountAsync();
}
}
Error Handling
try
{
var user = await client.GetUserAccountAsync();
}
catch (EnvatoApiException ex)
{
Console.WriteLine($"API Error: {ex.Message}");
Console.WriteLine($"Status Code: {ex.StatusCode}");
Console.WriteLine($"Response: {ex.ResponseBody}");
}
catch (Exception ex)
{
Console.WriteLine($"Unexpected error: {ex.Message}");
}
Using Cancellation Tokens
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
try
{
var sales = await client.GetSalesAsync(cancellationToken: cts.Token);
}
catch (OperationCanceledException)
{
Console.WriteLine("Request was cancelled");
}
Models
The SDK includes strongly-typed models for all API responses:
User- User account informationSale- Sales transaction dataItem- Marketplace item detailsStatement- Financial statement entriesPurchaseCodeVerification- Purchase code verification detailsPurchaseItem- Item information from purchase verificationLicenseActivation- License activation dataApiResponse<T>- Generic paginated response wrapperEnvatoApiException- API error handling
Building the Package
To build the NuGet package locally:
dotnet build -c Release
dotnet pack -c Release
The package will be created in bin/Release/.
Publishing to NuGet
dotnet nuget push bin/Release/EnvatoBuildSDK.1.0.0.nupkg --api-key YOUR_API_KEY --source https://api.nuget.org/v3/index.json
API Documentation
For more information about the Envato API, visit:
Requirements
- .NET 8.0 or higher
- Valid Envato personal token
License
MIT License - feel free to use this in your projects.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you encounter any issues or have questions:
- Open an issue on GitHub
- Check the Envato API documentation
- Review the example code in this README
Changelog
Version 1.0.0
- Initial release
- User account management
- Sales tracking
- Item details retrieval
- Financial statements access
- Purchase code/license verification and activation
- Full async/await support
- Comprehensive error handling
- Support validation helpers
- Buyer information retrieval
| 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
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EnvatoBuildSDK:
| Package | Downloads |
|---|---|
|
AlphaPay
Professional payment gateway abstraction for .NET. Includes 11 payment providers built-in: Stripe, PayPal, Checkout.com, M-Pesa, Paystack, Flutterwave, Razorpay, Square, Adyen, Braintree, and Authorize.Net. Works with WPF, MSIX, Windows, web, and console apps. Microsoft Store provider available separately. Commercial license - compiled binaries only. |
GitHub repositories
This package is not used by any popular GitHub repositories.