yundict
v0.1.8
Published
The official Node.js / Typescript library for the Yundict API
Downloads
46
Maintainers
Readme
Yundict API JavaScript client
The official JavaScript / TypeScript / Node.js library for the Yundict API.
Features
- [x] Includes core API methods (teams, projects, keys)
- [x] ESM only
- [x] TypeScript support
- [x] Node.js / Bun.js / Deno / Browser support
Installation
npm install yundict
Usage
import { Yundict } from 'yundict';
const yundict = new Yundict({
token: 'API TOKEN'
});
Options
| name | Type | Description | | --- | --- | --- | | token | string | API token | | request.fetch | function | Custom replacement for built-in fetch method |
APIs
Teams
// Get all teams
yundict.teams.all()
// Get a team by name
yundict.teams.get('team-name')
// Create a team
yundict.teams.create({ name: "test-team", displayName: "Test Team" });
// Update a team
yundict.teams.update('test-team', { displayName: "Test Team 2" });
// Delete a team
yundict.teams.delete('test-team');
Projects
// Get all projects
yundict.projects.all({ teamName:"my-team" })
// Get a project by name
yundict.projects.get("my-team", 'my-proj')
// Create a project
yundict.projects.create("my-team", { displayName: "Test Project" });
// Update a project
yundict.projects.update("my-team", 'my-proj', { displayName: "Test Project 2" });
// Delete a project
yundict.projects.delete("my-team", 'my-proj')
Keys
// Get all keys
yundict.keys.all("my-team", 'my-proj')
// Create a key
yundict.keys.create("my-team", 'my-proj', "test-key");
// Update a key
yun.keys.update("my-team", 'my-proj', "test-key", { name: "new-key" });
// Delete a key
yundict.keys.delete("my-team", 'my-proj', "test-key");
// Import keys from a file
yundict.keys.import("my-team", 'my-proj', { file: ... });
// Export keys to a file
yundict.keys.export("my-team", 'my-proj', { languages: "en", type: "json" });