Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@crowdin/crowdin-api-client

Package Overview
Dependencies
Maintainers
5
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crowdin/crowdin-api-client

JavaScript library for Crowdin API v2.

  • 1.6.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
41K
decreased by-2.54%
Maintainers
5
Weekly downloads
 
Created
Source

Crowdin JavaScript client

The Crowdin JavaScript client is a lightweight interface to the Crowdin API v2 that works in any JavaScript environment, including web browsers, workers in web browsers, extensions in web browsers or desktop applications, Node.js etc. 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 to execute actions needed.

For more about Crowdin API v2 see the documentation.

npm npm GitHub issues License

codecov GitHub commit activity GitHub Release Date GitHub contributors

Build Status

Azure CI (Linux)Azure CI (Windows)Azure CI (MacOS)
Build StatusBuild StatusBuild Status
Azure DevOps tests (branch)Azure DevOps tests (branch)Azure DevOps tests (branch)

Table of Contents

Installation

npm

npm i @crowdin/crowdin-api-client

yarn

yarn add @crowdin/crowdin-api-client

Quick Start

Typescript
import crowdin, { Credentials } from '@crowdin/crowdin-api-client';

// credentials
const credentials: Credentials = {
  token: 'personalAccessToken',
  organization: 'organizationName' // optional
};

// initialization of crowdin client
const { projectsGroupsApi } = new crowdin(credentials);

// get project list
projectsGroupsApi.listProjects()
  .then(projects => console.log(projects))
  .catch(error => console.error(error));

// You can also use async/wait. Add `async` keyword to your outer function/method
async function getProjects() {
  try {
    const projects = await projectsGroupsApi.listProjects();
    console.log(projects);
  } catch (error) {
    console.error(error);
  }
}

Or specific API instances:

import { Credentials, ProjectsGroups } from '@crowdin/crowdin-api-client';

// credentials
const credentials: Credentials = {
  token: 'personalAccessToken',
  organization: 'organizationName' // optional
};

// initialization of ProjectsGroups
const projectsGroupsApi = new ProjectsGroups(credentials);

// get project list
projectsGroupsApi.listProjects()
  .then(projects => console.log(projects))
  .catch(error => console.error(error));
Javascript
import crowdin from '@crowdin/crowdin-api-client';

// initialization of crowdin client
const { projectsGroupsApi } = new crowdin({
  token: 'personalAccessToken',
  organization: 'organizationName' // optional
});

// get project list
projectsGroupsApi.listProjects()
  .then(projects => console.log(projects))
  .catch(error => console.error(error));

// You can also use async/wait. Add `async` keyword to your outer function/method
async function getProjects() {
  try {
    const projects = await projectsGroupsApi.listProjects();
    console.log(projects);
  } catch (error) {
    console.error(error);
  }
}

Or specific API instances:

import { ProjectsGroups } from '@crowdin/crowdin-api-client';

// initialization of ProjectsGroups
const projectsGroupsApi = new ProjectsGroups({
  token: 'personalAccessToken',
  organization: 'organizationName' // optional
});

// get project list
projectsGroupsApi.listProjects()
  .then(projects => console.log(projects))
  .catch(error => console.error(error));

You can generate Personal Access Token in your Crowdin Account Settings.

List of projects with Fetch API

In addition if you use client in non-Node.js environment you might have a troubles with http calls. This client uses axios which internally uses http and https Node modules. So there is an option to use http client based on Fetch API.

import { ProjectsGroups, HttpClientType } from '@crowdin/crowdin-api-client';

const projectsGroupsApi = new ProjectsGroups(credentials, {
  httpClientType: HttpClientType.FETCH
});

Or even pass your own http client as httpClient property which should implement HttpClient interface.

Retry configuration

There is a possibility to configure client invoke http calls with retry mechanism.

import { ProjectsGroups, HttpClientType } from '@crowdin/crowdin-api-client';

const projectsGroupsApi = new ProjectsGroups(credentials, {
  retryConfig: {
    retries: 2, // amount of retries (gte 1)
    waitInterval: 100, // wait interval in ms between retries
    conditions: [ // array of conditions which will check if retry should not be applied
      {
        test(error) {
          return error.code === 40
        }
      }
    ]
  }
});

Contribution

We are happy to accept contributions to the Crowdin JavaScript client. To contribute please do the following:

  1. Fork the repository on GitHub.
  2. Decide which code you want to submit. Commit your changes and push to the new branch.
  3. Ensure that your code adheres to standard conventions, as used in the rest of the library.
  4. Ensure that there are unit tests for your code.
  5. Submit a pull request with your patch on Github.

Seeking Assistance

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

If you've found an error in these samples, please contact our Support Team.

License

Copyright © 2020 Crowdin

The Crowdin JavaScript client is licensed under the MIT License. 
See the LICENSE.md 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.

Keywords

FAQs

Package last updated on 24 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc