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 631 11/1/2024
2.26.0 1,086 10/16/2024
2.25.0 1,396 8/29/2024
2.24.0 2,783 7/3/2024
2.23.1 10,803 6/13/2024
2.23.0 186 5/30/2024
2.22.1 521 5/16/2024
2.22.0 2,413 3/29/2024
2.21.0 1,338 3/19/2024
2.20.0 2,563 1/15/2024
2.19.0 7,463 11/2/2023
2.18.0 1,629 9/25/2023
2.17.1 766 8/22/2023
2.17.0 549 8/10/2023
2.16.0 640 7/31/2023
2.15.0 659 7/21/2023
2.14.3 662 7/18/2023
2.14.2 655 6/22/2023
2.14.1 654 6/13/2023
2.14.0 788 5/26/2023
2.13.1 3,935 5/5/2023
2.13.0 2,184 5/4/2023
2.12.0 8,941 3/3/2023
2.11.1 11,810 2/3/2023
2.11.0 861 1/17/2023
2.10.0 7,677 11/2/2022
2.9.1 8,577 9/22/2022
2.9.0 998 9/8/2022
2.8.0 1,687 7/13/2022
2.7.1 898 7/1/2022
2.7.0 884 6/30/2022
2.6.0 3,697 5/2/2022
2.5.2 2,463 4/7/2022
2.5.1 894 4/7/2022
2.5.0 1,228 3/29/2022
2.4.2 925 3/21/2022
2.4.1 934 3/9/2022
2.4.0 1,114 2/16/2022
2.3.2 951 1/28/2022
2.3.1 934 1/24/2022
2.3.0 1,038 1/10/2022
2.2.0 707 12/30/2021
2.1.0 725 12/22/2021
2.0.0 755 12/18/2021
1.0.3 3,025 3/6/2020
1.0.2 1,153 12/7/2019
1.0.1 1,016 12/6/2019
1.0.0 1,031 12/6/2019