Sirv.RestApi
1.0.2
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
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" />
<PackageReference Include="Sirv.RestApi" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Sirv.RestApi&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sirv.RestApi
Official .NET SDK for the Sirv REST API.
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 tokenIsConnected()- Check connection statusGetAccessToken()- Get current token
Account API
GetAccountInfoAsync()- Get account informationUpdateAccountAsync()- Update account settingsGetAccountLimitsAsync()- Get API rate limitsGetStorageInfoAsync()- Get storage usageGetAccountUsersAsync()- Get account usersGetBillingPlanAsync()- Get billing planSearchEventsAsync()- Search account eventsMarkEventsSeenAsync()- Mark events as seen
User API
GetUserInfoAsync()- Get user information
Files API - Reading
GetFileInfoAsync()- Get file informationReadFolderContentsAsync()- Read folder contentsIterateFolderContentsAsync()- Async iteration over folderGetFolderOptionsAsync()- Get folder optionsSetFolderOptionsAsync()- Set folder optionsSearchFilesAsync()- Search filesScrollSearchAsync()- Continue search paginationIterateSearchResultsAsync()- Async iteration over searchDownloadFileAsync()- Download file as bytesDownloadFileToAsync()- Download file to local path
Files API - Writing
UploadFileAsync()- Upload from byte array or streamUploadFileFromPathAsync()- Upload from local pathCreateFolderAsync()- Create folderDeleteFileAsync()- Delete fileBatchDeleteAsync()- Delete multiple filesGetBatchDeleteStatusAsync()- Get batch delete statusCopyFileAsync()- Copy fileRenameFileAsync()- Rename/move fileFetchUrlAsync()- Fetch from URLBatchZipAsync()- Create ZIP archiveGetZipStatusAsync()- Get ZIP job status
Metadata API
GetFileMetaAsync()/SetFileMetaAsync()- File metadataGetFileTitleAsync()/SetFileTitleAsync()- File titleGetFileDescriptionAsync()/SetFileDescriptionAsync()- File descriptionGetFileTagsAsync()/AddFileTagsAsync()/RemoveFileTagsAsync()- File tagsGetProductMetaAsync()/SetProductMetaAsync()- Product metadataGetApprovalFlagAsync()/SetApprovalFlagAsync()- Approval flag
JWT API
GenerateJwtAsync()- Generate protected URL
Spins/360 API
Spin2VideoAsync()- Convert spin to videoVideo2SpinAsync()- Convert video to spinExportSpinToAmazonAsync()- Export to AmazonExportSpinToWalmartAsync()- Export to WalmartExportSpinToHomeDepotAsync()- Export to Home DepotExportSpinToLowesAsync()- Export to Lowe'sExportSpinToGraingerAsync()- Export to Grainger
Points of Interest API
GetPointsOfInterestAsync()- Get POIsSetPointOfInterestAsync()- Set POIDeletePointOfInterestAsync()- Delete POI
Statistics API
GetHttpStatsAsync()- HTTP transfer statisticsGetSpinViewsStatsAsync()- Spin view statisticsGetStorageStatsAsync()- 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
- Log in to your Sirv account
- Go to Settings > API
- Create a new API client
- Copy your Client ID and Client Secret
Documentation
License
MIT License - see LICENSE for details.
Support
| Product | Versions 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.
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 9.0.1)
- System.Text.Json (>= 9.0.1)
-
.NETStandard 2.1
- System.Text.Json (>= 9.0.1)
-
net10.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release with full API coverage including authentication, account management, file operations, metadata, spins/360, statistics, and more.