Crowdin.Api 2.22.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Crowdin.Api --version 2.22.0                
NuGet\Install-Package Crowdin.Api -Version 2.22.0                
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="Crowdin.Api" Version="2.22.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Crowdin.Api --version 2.22.0                
#r "nuget: Crowdin.Api, 2.22.0"                
#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.
// Install Crowdin.Api as a Cake Addin
#addin nuget:?package=Crowdin.Api&version=2.22.0

// Install Crowdin.Api as a Cake Tool
#tool nuget:?package=Crowdin.Api&version=2.22.0                

<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://support.crowdin.com/assets/logos/symbol/png/crowdin-symbol-cWhite.png"> <source media="(prefers-color-scheme: light)" srcset="https://support.crowdin.com/assets/logos/symbol/png/crowdin-symbol-cDark.png"> <img width="150" height="150" width=""src="https://support.crowdin.com/assets/logos/symbol/png/crowdin-symbol-cDark.png"> </picture> </p>

Crowdin .NET client Tweet GitHub Repo stars

The Crowdin .NET client is a lightweight interface to the Crowdin API. It provides common services for making API requests.

Our API is a full-featured RESTful API that helps you to integrate localization into your development process. The endpoints that we use allow you to easily make calls to retrieve information and perform necessary actions.

<div align="center">

Docs  |  Examples  |  Crowdin API  |  Crowdin Enterprise API

Nuget Nuget Tests codecov GitHub contributors GitHub

</div>

Requirements

  • .NET Standard 2.0 support
  • C# language version - 8.0+

Installation

Install via NuGet:

// Package Manager
Install-Package Crowdin.Api -Version 2.22.0

// .Net CLI
dotnet add package Crowdin.Api --version 2.22.0

// Package Reference
<PackageReference Include="Crowdin.Api" Version="2.22.0" />

// Paket CLI
paket add Crowdin.Api --version 2.22.0

Usage examples

Initialization

Instantiate a client with all available APIs:


var credentials = new CrowdinCredentials
{
    AccessToken = "<paste token here>",
    Organization = "organizationName (for Crowdin Enterprise only)"
};
var client = new CrowdinApiClient(credentials);

Or use only the executors you need:

var credentials = new CrowdinCredentials
{
    AccessToken = "<paste token here>",
    Organization = "organizationName (for Crowdin Enterprise only)"
};

var client = new CrowdinApiClient(credentials);
var executor = new SourceFilesApiExecutor(client);
Storage
  1. List storages
ResponseList<StorageResource> storages = await client.Storage.ListStorages();
  1. Add storage
await using FileStream fileStream = File.Open("/path/to/file", FileMode.Open);
StorageResource storageResource = await client.Storage.AddStorage(fileStream, filename: "MyFile");
Projects
  1. List projects
ResponseList<EnterpriseProject> response = await client.ProjectsGroups.ListProjects<EnterpriseProject>();
  1. Edit project
const int projectId = 1;

// Edit info & settings with one request
var patches = new List<ProjectPatch>
{
    // Edit project info
    new ProjectInfoPatch
    {
        Value = "name",
        Path = ProjectInfoPathCode.Cname,
        Operation = PatchOperation.Replace
    },
    new ProjectInfoPatch
    {
        Value = "value here",
        Path = new ProjectInfoPath(ProjectInfoPathCode.LanguageMapping, "languageId", "mapping"),
        Operation = PatchOperation.Test
    },

    // Edit project settings
    new ProjectSettingPatch
    {
        Value = true,
        Path = ProjectSettingPathCode.AutoSubstitution,
        Operation = PatchOperation.Replace
    }
};

// PATCH request
var projectSettingsResponse = await client.ProjectsGroups.EditProject<ProjectSettings>(projectId, patches);
Console.WriteLine(projectSettingsResponse);
Fetch all records

Get a list of all the data available from the API via automatic pagination control:

const int parentId = 1;
const int maxAmountOfItems = 50; // amount of needed items. Optional parameter, default: no limit
const int amountPerRequest = 10; // amount of items in response per 1 request. Optional parameter, default: 25

Group[] allGroups = await CrowdinApiClient.WithFetchAll((limit, offset) =>
{
    Console.WriteLine("Limit: {0} | Offset: {1}", limit, offset);
    return client.ProjectsGroups.ListGroups(parentId, limit, offset);
}, maxAmountOfItems, amountPerRequest);

Only for list async methods that return Task<ResponseList<T>>.

Rate limiting

API client has built-in support for rate limiting services. The library provides an implementation of Exponential Backoff Algorithm.

Usage:

var rateLimiter = new ExponentialBackoffRateLimiter(new RateLimitConfiguration
{
    // Maximum attempts count
    MaxAttempts = 5,
    // Maximum delay (top limit)
    MaxDelay = TimeSpan.FromSeconds(5),
    // Initial delay (bottom limit)
    InitialDelay = TimeSpan.FromMilliseconds(200),
});

// Pass created Rate Limiter instance as named argument to API client instance
// If rate limiter not passed - the request will fail immediately after HTTP 429 Too Many Requests error
var client = new CrowdinApiClient(new CrowdinCredentials
{
    AccessToken = "<paste token here>",
    Organization = "optional organization (for Enterprise API)"
}, rateLimiter: rateLimiter);

A custom rate limiting service should also implement the IRateLimiter interface. Rate limiting is disabled by default because users may be using custom resilience approaches (such as Polly) that may conflict with each other. This solution only covers simple resilience cases. If you need advanced customization - please try Polly or alternatives.

Retry configuration

Pass retry service (built-in or custom):

IRetryService myRetryService = new RetryService(new RetryConfiguration
{
    RetriesCount = 5,
    WaitIntervalMilliseconds = 1000,
    SkipRetryConditions =
    {
        exception => ((CrowdinApiException) exception).Code.GetValueOrDefault() == 1
    }
});

var apiClient = new CrowdinApiClient(new CrowdinCredentials
{
    AccessToken = "<paste token here>",
    Organization = "optional organization (for Enterprise API)"
}, retryService: myRetryService);

A custom retry service should also implement the IRetryService interface.

Contribution

If you would like to contribute please read the Contributing guidelines.

Seeking Assistance

If you find any problems or would like to suggest a feature, please feel free to file an issue on GitHub at the Issues Page.

License

<pre> The Crowdin .NET client is licensed under the MIT License. See the LICENSE file distributed with this work for additional information regarding copyright ownership.

Except as contained in the LICENSE file, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. </pre>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.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 was computed. 
.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 (1)

Showing the top 1 NuGet packages that depend on Crowdin.Api:

Package Downloads
Jumoo.TranslationManager.Crowdin

Crowdin connector for Translation manager v9

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Crowdin.Api:

Repository Stars
cyanfish/naps2
Scan documents to PDF and more, as simply as possible.
Version Downloads Last updated
2.27.0 519 11/1/2024
2.26.0 1,006 10/16/2024
2.25.0 1,342 8/29/2024
2.24.0 2,718 7/3/2024
2.23.1 10,610 6/13/2024
2.23.0 184 5/30/2024
2.22.1 497 5/16/2024
2.22.0 2,411 3/29/2024
2.21.0 1,336 3/19/2024
2.20.0 2,511 1/15/2024
2.19.0 7,416 11/2/2023
2.18.0 1,612 9/25/2023
2.17.1 760 8/22/2023
2.17.0 547 8/10/2023
2.16.0 636 7/31/2023
2.15.0 657 7/21/2023
2.14.3 660 7/18/2023
2.14.2 653 6/22/2023
2.14.1 652 6/13/2023
2.14.0 786 5/26/2023
2.13.1 3,888 5/5/2023
2.13.0 2,182 5/4/2023
2.12.0 8,889 3/3/2023
2.11.1 11,778 2/3/2023
2.11.0 859 1/17/2023
2.10.0 7,670 11/2/2022
2.9.1 8,575 9/22/2022
2.9.0 996 9/8/2022
2.8.0 1,685 7/13/2022
2.7.1 896 7/1/2022
2.7.0 882 6/30/2022
2.6.0 3,693 5/2/2022
2.5.2 2,461 4/7/2022
2.5.1 892 4/7/2022
2.5.0 1,226 3/29/2022
2.4.2 923 3/21/2022
2.4.1 932 3/9/2022
2.4.0 1,112 2/16/2022
2.3.2 949 1/28/2022
2.3.1 932 1/24/2022
2.3.0 1,036 1/10/2022
2.2.0 705 12/30/2021
2.1.0 723 12/22/2021
2.0.0 753 12/18/2021
1.0.3 3,023 3/6/2020
1.0.2 1,151 12/7/2019
1.0.1 1,014 12/6/2019
1.0.0 1,029 12/6/2019