Sirv.RestApi 1.0.2

dotnet add package Sirv.RestApi --version 1.0.2
                    
NuGet\Install-Package Sirv.RestApi -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sirv.RestApi" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sirv.RestApi" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Sirv.RestApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sirv.RestApi --version 1.0.2
                    
#r "nuget: Sirv.RestApi, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sirv.RestApi@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sirv.RestApi&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Sirv.RestApi&version=1.0.2
                    
Install as a Cake Tool

Sirv.RestApi

Official .NET SDK for the Sirv REST API.

NuGet License: MIT

Features

  • Supports .NET 6, 7, 8, 9, 10 and .NET Standard 2.0/2.1
  • Full async/await support
  • Automatic token management with refresh
  • IAsyncEnumerable for efficient pagination
  • Retry logic with exponential backoff
  • All 40+ API endpoints implemented
  • Comprehensive XML documentation

Installation

NuGet Package Manager

Install-Package Sirv.RestApi

.NET CLI

dotnet add package Sirv.RestApi

PackageReference

<PackageReference Include="Sirv.RestApi" Version="1.0.0" />

Quick Start

using Sirv.RestApi;
using Sirv.RestApi.Models;

// Create client
var client = new SirvClient(new SirvClientConfig
{
    ClientId = "your-client-id",
    ClientSecret = "your-client-secret"
});

// Connect (optional - auto-connects on first request)
await client.ConnectAsync();

// Get account info
var account = await client.GetAccountInfoAsync();
Console.WriteLine($"CDN URL: {account.CdnUrl}");

// Upload a file
await client.UploadFileFromPathAsync("/images/photo.jpg", "./local-photo.jpg");

// Search files
var results = await client.SearchFilesAsync(new SearchParams { Query = "product" });
foreach (var file in results.Hits)
{
    Console.WriteLine(file.Filename);
}

Configuration

var client = new SirvClient(new SirvClientConfig
{
    // Required
    ClientId = "your-client-id",
    ClientSecret = "your-client-secret",

    // Optional
    BaseUrl = "https://api.sirv.com",  // API base URL
    AutoRefreshToken = true,            // Auto-refresh token before expiry
    TokenRefreshBuffer = 60,            // Seconds before expiry to refresh
    Timeout = 30000,                    // Request timeout in ms
    MaxRetries = 3                      // Retry failed requests
});
Option Type Default Description
ClientId string - Your Sirv API client ID (required)
ClientSecret string - Your Sirv API client secret (required)
BaseUrl string https://api.sirv.com API base URL
AutoRefreshToken bool true Automatically refresh tokens
TokenRefreshBuffer int 60 Seconds before expiry to refresh
Timeout int 30000 Request timeout in milliseconds
MaxRetries int 3 Max retries for failed requests

Custom Token Expiry

You can customize the token expiry time (5 to 604,800 seconds / 7 days):

// Token valid for 1 hour
await client.ConnectAsync(3600);

// Token valid for 7 days
await client.ConnectAsync(604800);

Async Enumeration

Use IAsyncEnumerable for efficient iteration over large result sets:

// Iterate through all files in a folder
await foreach (var file in client.IterateFolderContentsAsync("/images"))
{
    Console.WriteLine(file.Filename);
}

// Iterate through search results
await foreach (var file in client.IterateSearchResultsAsync(new SearchParams { Query = "product" }))
{
    Console.WriteLine(file.Filename);
}

API Coverage

Authentication

  • ConnectAsync() - Obtain bearer token
  • IsConnected() - Check connection status
  • GetAccessToken() - Get current token

Account API

  • GetAccountInfoAsync() - Get account information
  • UpdateAccountAsync() - Update account settings
  • GetAccountLimitsAsync() - Get API rate limits
  • GetStorageInfoAsync() - Get storage usage
  • GetAccountUsersAsync() - Get account users
  • GetBillingPlanAsync() - Get billing plan
  • SearchEventsAsync() - Search account events
  • MarkEventsSeenAsync() - Mark events as seen

User API

  • GetUserInfoAsync() - Get user information

Files API - Reading

  • GetFileInfoAsync() - Get file information
  • ReadFolderContentsAsync() - Read folder contents
  • IterateFolderContentsAsync() - Async iteration over folder
  • GetFolderOptionsAsync() - Get folder options
  • SetFolderOptionsAsync() - Set folder options
  • SearchFilesAsync() - Search files
  • ScrollSearchAsync() - Continue search pagination
  • IterateSearchResultsAsync() - Async iteration over search
  • DownloadFileAsync() - Download file as bytes
  • DownloadFileToAsync() - Download file to local path

Files API - Writing

  • UploadFileAsync() - Upload from byte array or stream
  • UploadFileFromPathAsync() - Upload from local path
  • CreateFolderAsync() - Create folder
  • DeleteFileAsync() - Delete file
  • BatchDeleteAsync() - Delete multiple files
  • GetBatchDeleteStatusAsync() - Get batch delete status
  • CopyFileAsync() - Copy file
  • RenameFileAsync() - Rename/move file
  • FetchUrlAsync() - Fetch from URL
  • BatchZipAsync() - Create ZIP archive
  • GetZipStatusAsync() - Get ZIP job status

Metadata API

  • GetFileMetaAsync() / SetFileMetaAsync() - File metadata
  • GetFileTitleAsync() / SetFileTitleAsync() - File title
  • GetFileDescriptionAsync() / SetFileDescriptionAsync() - File description
  • GetFileTagsAsync() / AddFileTagsAsync() / RemoveFileTagsAsync() - File tags
  • GetProductMetaAsync() / SetProductMetaAsync() - Product metadata
  • GetApprovalFlagAsync() / SetApprovalFlagAsync() - Approval flag

JWT API

  • GenerateJwtAsync() - Generate protected URL

Spins/360 API

  • Spin2VideoAsync() - Convert spin to video
  • Video2SpinAsync() - Convert video to spin
  • ExportSpinToAmazonAsync() - Export to Amazon
  • ExportSpinToWalmartAsync() - Export to Walmart
  • ExportSpinToHomeDepotAsync() - Export to Home Depot
  • ExportSpinToLowesAsync() - Export to Lowe's
  • ExportSpinToGraingerAsync() - Export to Grainger

Points of Interest API

  • GetPointsOfInterestAsync() - Get POIs
  • SetPointOfInterestAsync() - Set POI
  • DeletePointOfInterestAsync() - Delete POI

Statistics API

  • GetHttpStatsAsync() - HTTP transfer statistics
  • GetSpinViewsStatsAsync() - Spin view statistics
  • GetStorageStatsAsync() - Storage statistics

Error Handling

using Sirv.RestApi.Exceptions;

try
{
    await client.UploadFileFromPathAsync("/images/photo.jpg", "./photo.jpg");
}
catch (SirvApiException ex)
{
    Console.WriteLine($"API Error: {ex.Message}");
    Console.WriteLine($"Status: {ex.StatusCode}");
    Console.WriteLine($"Code: {ex.ErrorCode}");
}

Getting API Credentials

  1. Log in to your Sirv account
  2. Go to Settings > API
  3. Create a new API client
  4. Copy your Client ID and Client Secret

Documentation

License

MIT License - see LICENSE for details.

Support

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.2 123 2/5/2026
1.0.1 112 1/27/2026
1.0.0 113 1/27/2026

Initial release with full API coverage including authentication, account management, file operations, metadata, spins/360, statistics, and more.