Skip to content

Latest commit

 

History

History
105 lines (72 loc) · 2.9 KB

README.md

File metadata and controls

105 lines (72 loc) · 2.9 KB

crowdin-node

Node module for accessing the Crowdin API

Disclaimer

This is an unofficial API client library. Crowdin and the Crowdin API are the property of Crowdin, LLC.

Install

npm install crowdin

Usage

apiKey and endpointUrl parameters must be set to create the instance, an error will be thrown otherwise.

var crowdin = new Crowdin({
    apiKey: '7d38782fa7cb4b6a9fbae2de65e91989',
    endpointUrl: 'https://api.crowdin.net/api/project/<your-project>'
});

And, in this fork, in order to handle the crowdin branchs, optionally is possible to set a branch parameter,

var crowdin = new Crowdin({
    apiKey: '7d38782fa7cb4b6a9fbae2de65e91989',
    endpointUrl: 'https://api.crowdin.net/api/project/<your-project>',
    branch: 'branch-name'
});

to add the branch parameter to the real background crowdin api requests:

GET https://api.crowdin.com/api/project/{project-identifier}
/export?key={project-key}&branch={branch-name}

GET https://api.crowdin.com/api/project/{project-identifier}
/download/{package}.zip?key={project-key}&branch={branch-name}

API

.requestData(Object parameters)

Returns a Promise of a call to the API endpoint with specified parameters.
Parses the response body and rejects if the API returns an error.

.getRequest(String endpoint)

Returns a Promise of a GET request to the set API endpoint. Uses requestData().

.postRequest(String endpoint)

Returns a Promise of a POST request to the set API endpoint. Uses requestData().

.getInfo()

Returns a Promise of project information. Uses postRequest().

.getLanguages()

Returns a Promise of project languages. Uses getInfo().

.export()

Returns a Promise of an API call to the export endpoint. Uses getRequest().

.download()

Downloads the translations ZIP and returns the Stream.
You might call export() before to ensure you have the latest translations.

.downloadToStream(Stream)

Downloads the translations ZIP to the specified stream. Uses download() and returns an empty Promise.

.downloadToZip(String path)

Downloads the translations ZIP to the specified path. Uses download() and returns an empty Promise.

.downloadToPath(String path)

Downloads and extracts the translations ZIP to the specified path. Uses download() and returns an empty Promise.

.downloadAndParse()

Downloads and parses the translations ZIP. Uses download() and returns the Stream of file entries. See the node-unzip documentation.

.downloadToObject()

Downloads, extracts and converts the translations ZIP to a JS object. Returns a Promise.

Tests

Tests are written with mocha

npm test

Coverage using istanbul

npm run coverage

License

Apache 2.0
Copyright 2015 Hailo