Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@lokalise/node-api
Advanced tools
Official Node interface for the Lokalise API.
This library has no special requirements. Install it with NPM:
npm install @lokalise/node-api
In order to perform API requests, you require a special token that can be obtained in your personal profile (API tokens section). Note that the owner of the token must have admin access rights.
After you've obtained the token, initialize the client:
const { LokaliseApi } = require('@lokalise/node-api');
const lokaliseApi = new LokaliseApi({ apiKey: '<apiKey>'});
Now you may perform API requests, for example:
const projects = lokaliseApi.projects.list();
projects[0].name;
All object attributes may be found in the interfaces.
Bulk fetches support pagination. There are two common parameters available:
limit
(defaults to 100
, maximum is 5000
) - number of records to display per pagepage
(defaults to 1
) - page to fetchFor instance:
lokaliseApi.translationProviders.list({team_id: team_id, page: 2, limit: 10});
Every request returns a promise with a corresponding object (or array of objects) as the result.
lokaliseApi.comments.list_project_comments({ project_id: project_id });
lokaliseApi.comments.list({project_id: project_id, key_id: key_id})
lokaliseApi.comments.get(comment_id, {project_id: project_id, key_id: key_id});
lokaliseApi.comments.create({
'comments': [
{ comment: "Project comment 1" },
{ comment: "Project comment 2" }
]
}, { project_id: project_id, key_id: key_id});
lokaliseApi.comments.delete(comment_id, {project_id: project_id, key_id: key_id});
lokaliseApi.contributors.list({project_id: project_id});
lokaliseApi.contributors.get(user_id, {project_id: project_id});
lokaliseApi.contributors.create([
{
"email": "translator2@mycompany.com",
"fullname": "Mr. Translator",
"is_admin": false,
"is_reviewer": true,
"languages": [
{
"lang_iso": "en",
"is_writable": false
}
]
}
], {project_id: project_id});
lokaliseApi.contributors.update(
user_id,
{is_admin: true},
{project_id: project_id}
);
lokaliseApi.contributors.delete(user_id, {project_id: project_id});
lokaliseApi.files.list({project_id: project_id});
lokaliseApi.files.upload(project_id, {data: data_base64, filename: 'test1.json', lang_iso: 'en'})
lokaliseApi.files.download(project_id, {format: 'json', "original_filenames": true});
lokaliseApi.keys.list({project_id: project_id});
lokaliseApi.keys.get(key_id, {project_id: project_id});
lokaliseApi.keys.create([
{
"key_name": "welcome_web",
"description": "Index app welcome",
"platforms": ["web"],
"translations": [
{
"language_iso": "en",
"translation": "Welcome"
}
]
},
{
"key_name": "welcome_ios",
"description": "Welcome apple",
"platforms": ["ios"],
"is_plural": true,
"translations": [
{
"language_iso": "en",
"translation": {
"one": "I have one apple",
"other": "I have a lot of apples"
}
}
]
}
], {project_id: project_id});
lokaliseApi.keys.update(key_id, {
"platforms": ["web", "other"],
"description": "Node updated"
}, { project_id: project_id });
lokaliseApi.keys.bulk_update([
{
"key_id": key_id,
"description": "Bulk node",
"platforms": ["web"]
},
{
"key_id": second_key_id,
"description": "Second bulk",
}
], { project_id: project_id});
lokaliseApi.keys.delete(key_id, { project_id: project_id });
lokaliseApi.keys.bulk_delete([
key_id, second_key_id
], { project_id: project_id });
lokaliseApi.languages.system_languages();
lokaliseApi.languages.list({project_id: project_id});
lokaliseApi.languages.get(lang_id, {project_id: project_id});
lokaliseApi.languages.create([
{
"lang_iso": "ak"
}
], { project_id: project_id });
lokaliseApi.languages.update(lang_id, {
"lang_name": "Chinese Traditional Custom"
}, { project_id: project_id });
lokaliseApi.languages.delete(lang_id, { project_id: project_id });
lokaliseApi.orders.list({team_id: team_id})
lokaliseApi.orders.get(order_id, {team_id: team_id})
lokaliseApi.orders.create({
project_id: '803xyz145ba90b42abc.46800',
card_id: '1774',
briefing: 'My briefing',
source_language_iso: 'en',
target_language_isos: ['nl'],
keys: [12345],
provider_slug: 'gengo',
translation_tier: '1'
},
{team_id: team_id});
lokaliseApi.paymentCards.list();
lokaliseApi.paymentCards.get(card_id);
lokaliseApi.paymentCards.create({
number: '4242424242424242',
cvc: 123,
exp_month: 10,
exp_year: 2030
});
lokaliseApi.paymentCards.delete(card_id);
lokaliseApi.projects.list();
lokaliseApi.projects.get(project_id)
lokaliseApi.projects.create({ name: "Project name", description: "Project description" });
lokaliseApi.projects.update(project_id, { name: "New name", description: "New description"});
lokaliseApi.projects.empty(project_id)
lokaliseApi.projects.delete(project_id);
lokaliseApi.screenshots.list({project_id: project_id});
lokaliseApi.screenshots.get(screenshot_id, {project_id: project_id});
lokaliseApi.screenshots.create([
{
data: data,
"ocr": false,
"key_ids": [key_id],
"tags": ["onboarding"]
}
],{project_id: project_id});
lokaliseApi.screenshots.update(screenshot_id,
{title: 'node screen', description: 'node desc'},
{project_id: project_id}
);
lokaliseApi.screenshots.delete(screenshot_id, {project_id: project_id});
lokaliseApi.snapshots.list({project_id: project_id});
lokaliseApi.snapshots.create({"title": "API snapshot"}, {project_id: project_id});
lokaliseApi.snapshots.restore(snapshot_id, {project_id: project_id});
lokaliseApi.snapshots.delete(snapshot_id, {project_id: project_id});
lokaliseApi.tasks.list({project_id: project_id});
lokaliseApi.tasks.get(task_id, {project_id: project_id});
lokaliseApi.tasks.create({
title: 'node task',
keys: [key1, key2],
languages: [
{
"language_iso": "en",
"users": [user1, user2]
}
]
}, {project_id: project_id});
lokaliseApi.tasks.update(
task_id,
{title: 'node updated'},
{project_id: project_id}
);
lokaliseApi.tasks.delete(task_id, {project_id: project_id});
lokaliseApi.teams.list();
lokaliseApi.teamUsers.list({team_id: team_id});
lokaliseApi.teamUsers.get(user_id, {team_id: team_id});
lokaliseApi.teamUsers.update(
user_id,
{role: 'admin'},
{team_id: team_id}
);
lokaliseApi.teamUsers.delete(user_id, {team_id: team_id});
lokaliseApi.userGroups.list({team_id: team_id});
lokaliseApi.userGroups.get(group_id, {team_id: team_id});
lokaliseApi.userGroups.create(
{
name: 'Node',
is_reviewer: false,
is_admin: true,
admin_rights: ['upload']
},
{team_id: team_id}
);
lokaliseApi.userGroups.update(
group_id,
{
name: 'Node updated',
is_reviewer: false,
is_admin: true,
admin_rights: ['upload']
},
{team_id: team_id}
);
lokaliseApi.userGroups.add_projects_to_group(
team_id,
group_id,
[project_id]
);
lokaliseApi.userGroups.remove_projects_from_group(
team_id,
group_id,
[project_id]
);
lokaliseApi.userGroups.add_members_to_group(
team_id,
group_id,
[user_id]
);
lokaliseApi.userGroups.remove_members_from_group(
team_id,
group_id,
[user_id]
);
lokaliseApi.userGroups.delete(new_group_id, {team_id: team_id});
lokaliseApi.translations.list({project_id: project_id});
lokaliseApi.translations.get(translation_id, {project_id: project_id});
lokaliseApi.translations.update(
translation_id,
{translation: 'updated'},
{project_id: project_id}
);
lokaliseApi.translationProviders.list({team_id: team_id})
lokaliseApi.translationProviders.get(translation_provider_id, {team_id: team_id});
lokaliseApi.translationStatuses.list({project_id: project_id});
lokaliseApi.translationStatuses.get(status_id, {project_id: project_id});
lokaliseApi.translationStatuses.create(
{title: 'my status', color: '#344563'},
{project_id: project_id}
);
lokaliseApi.translationStatuses.update(
status_id,
{title: 'my status updated', color: '#f2d600'},
{project_id: project_id}
);
lokaliseApi.translationStatuses.delete(status_id, {project_id: project_id});
lokaliseApi.translationStatuses.available_colors({project_id: project_id});
Error codes are listed in the API docs.
Lokalise does not rate-limit API requests, however retain a right to decline the service in case of excessive use. Only one concurrent request per token is allowed. To ensure data consistency, it is not recommended to access the same project simultaneously using multiple tokens.
This library is tested with Node 8, 9, 10, 11, and 12. To test it locally:
.env.example
file as .env
. Put your API token inside. The .env
file is excluded from version control so your token is safe. All in all, we use pre-recorded cassettes, so the actual API requests won't be sent. However, providing at least some token is required.npm test
. Observe test results and coverage.npm run-script build
dist/
folderThis library is licensed under the MIT License.
Copyright (c) Lokalise team, Roman Kutanov, Ilya Bodrov
FAQs
Official Lokalise API 2.0 Node.js client
The npm package @lokalise/node-api receives a total of 131,640 weekly downloads. As such, @lokalise/node-api popularity was classified as popular.
We found that @lokalise/node-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.