Crowdin.Api 2.26.0

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

// Install Crowdin.Api as a Cake Tool
#tool nuget:?package=Crowdin.Api&version=2.26.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.26.0

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

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

// Paket CLI
paket add Crowdin.Api --version 2.26.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>>.

Sorting

An optional orderBy parameter is used to apply sorting.

var executor = new ProjectsGroupsApiExecutor(mockClient.Object);

ResponseList<EnterpriseProject> projectsList = await executor.ListProjects<EnterpriseProject>(
        userId, groupId, hasManagerAccess,
        orderBy: new[]
        {
            new SortingRule
            {
                Field = "createdAt",
                Order = SortingOrder.Descending
            },
            new SortingRule
            {
                Field = "name",
                Order = SortingOrder.Ascending
            }
        });

Property SortingRule.Order is also optional (ascending order applied by default).

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 1,464 11/1/2024
2.26.0 1,589 10/16/2024
2.25.0 1,728 8/29/2024
2.24.0 3,288 7/3/2024
2.23.1 12,011 6/13/2024
2.23.0 195 5/30/2024
2.22.1 723 5/16/2024
2.22.0 2,458 3/29/2024
2.21.0 1,354 3/19/2024
2.20.0 2,849 1/15/2024
2.19.0 7,581 11/2/2023
2.18.0 1,634 9/25/2023
2.17.1 776 8/22/2023
2.17.0 550 8/10/2023
2.16.0 642 7/31/2023
2.15.0 663 7/21/2023
2.14.3 664 7/18/2023
2.14.2 657 6/22/2023
2.14.1 657 6/13/2023
2.14.0 790 5/26/2023
2.13.1 4,130 5/5/2023
2.13.0 2,187 5/4/2023
2.12.0 9,252 3/3/2023
2.11.1 11,955 2/3/2023
2.11.0 862 1/17/2023
2.10.0 7,687 11/2/2022
2.9.1 8,580 9/22/2022
2.9.0 999 9/8/2022
2.8.0 1,689 7/13/2022
2.7.1 900 7/1/2022
2.7.0 886 6/30/2022
2.6.0 3,699 5/2/2022
2.5.2 2,468 4/7/2022
2.5.1 897 4/7/2022
2.5.0 1,235 3/29/2022
2.4.2 928 3/21/2022
2.4.1 936 3/9/2022
2.4.0 1,117 2/16/2022
2.3.2 957 1/28/2022
2.3.1 936 1/24/2022
2.3.0 1,041 1/10/2022
2.2.0 709 12/30/2021
2.1.0 727 12/22/2021
2.0.0 757 12/18/2021
1.0.3 3,085 3/6/2020
1.0.2 1,158 12/7/2019
1.0.1 1,021 12/6/2019
1.0.0 1,037 12/6/2019