REST API Overview
Relevant source files
The following files were used as context for generating this wiki page:
The Ever® Traduora platform provides a comprehensive REST API to automate and integrate translation workflows. This API is the backbone of the platform, enabling developers to manage projects, terms, translations, and users programmatically. It allows for the automation of tasks such as importing and exporting translation files, which is essential for continuous integration and delivery pipelines. The API is versioned, with the current stable version being v1.
All API endpoints are documented and organized into categories such as Authentication, Roles & Permissions, and specific resource Endpoints. This structure allows for a clear understanding of the API's capabilities. The API is designed to be used by both the official web application and third-party tools, like the community-contributed CLI.
Sources: README.md:17-23, docs-website/sidebars.json:4-6
API Architecture
The API is built with NestJS and follows standard RESTful conventions. All endpoints are prefixed with /api/v1/. Access to the API requires authentication, which is handled via bearer tokens.
Sources: api/test/project.e2e-spec.ts:13-24, api/src/controllers/project.controller.ts:10
Authentication
Authentication is required for most endpoints. The API supports two primary grant types for obtaining an access token: password for user credentials and client_credentials for programmatic access via API clients.
The authentication flow involves sending a POST request to /api/v1/auth/token with the appropriate grant_type and credentials. A successful request returns an access_token which must be included in subsequent requests as a Bearer token in the Authorization header.
Sources: api/src/domain/http.ts:344-374, api/test/project-client.e2e-spec.ts:111-123
The following diagram illustrates the authentication sequence for obtaining a token using client credentials.
Roles & Permissions
The API employs a role-based access control (RBAC) system to manage permissions within a project. A user or an API client can be assigned a specific role for each project. The primary roles are:
| Role | Description |
|---|---|
Admin | Full control over the project, including managing settings, users, and billing. |
Editor | Can add/edit terms and translations, and import/export data. |
Viewer | Read-only access to project data. |
Sources: api/src/domain/http.ts:15-16, webapp/src/app/projects/projects.module.ts:46-47, api/test/project-client.e2e-spec.ts:211-217
Permissions are enforced at the controller level. For example, creating a project requires the user to be authenticated, and deleting a project requires the DeleteProject action, which is typically granted to the Admin role.
Sources: api/src/controllers/project.controller.ts:39, api/src/controllers/project.controller.ts:100-103
Core Resources
The API is organized around several core resources, each with a set of endpoints for CRUD (Create, Read, Update, Delete) operations.
Projects
Projects are the top-level containers for all translation data.
| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/projects | Lists all projects the authenticated user has access to. |
POST | /api/v1/projects | Creates a new project. The creator is assigned as the admin. |
GET | /api/v1/projects/:projectId | Retrieves a single project by its ID. |
PATCH | /api/v1/projects/:projectId | Updates a project's name or description. |
DELETE | /api/v1/projects/:projectId | Deletes a project. |
Sources: api/src/controllers/project.controller.ts, api/test/project.e2e-spec.ts
A ProjectDTO is the data transfer object representing a project.
Sources: api/src/domain/http.ts:100-115
Terms
Terms are the source strings to be translated. They are managed within the scope of a project.
| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/projects/:projectId/terms | Lists all terms in a project, sorted lexically. |
POST | /api/v1/projects/:projectId/terms | Adds a new term to a project. |
PATCH | /api/v1/projects/:projectId/terms/:termId | Updates an existing term. |
DELETE | /api/v1/projects/:projectId/terms/:termId | Deletes a term from a project. |
Sources: api/test/term.e2e-spec.ts
Translations
Translations are the target language strings for each term. They are managed per locale within a project.
| Method | Endpoint | Description |
|---|---|---|
POST | /api/v1/projects/:projectId/translations | Adds a new locale to a project. |
PATCH | /api/v1/projects/:projectId/translations/:localeCode | Adds or updates a translation for a specific term in a locale. |
DELETE | /api/v1/projects/:projectId/translations/:localeCode | Deletes a locale and all its translations from a project. |
Sources: api/test/export.e2e-spec.ts:57-81, api/test/project-plan.e2e-spec.ts:121-124
Import & Export
A key feature of the API is the ability to bulk import and export translation data in various formats.
Exporting Translations
To export translations, a GET request is made to the export endpoint with the desired locale and format.
The following diagram shows the data flow for an export request.
Importing Translations
To import translations, a POST request with a multipart/form-data payload is sent to the import endpoint. The locale and format must be specified as query parameters. The API can automatically create new terms and locales if they don't exist.
| Method | Endpoint | Description |
|---|---|---|
POST | /api/v1/projects/:projectId/imports | Imports a file, creating or updating terms and translations. |
Sources: api/test/import.e2e-spec.ts:131-135
Supported Formats
The API supports a wide range of common localization file formats for both import and export.
| Format Enum | Name |
|---|---|
androidxml | Android Resources (XML) |
csv | CSV |
xliff12 | XLIFF 1.2 |
jsonflat | JSON (flat) |
jsonnested | JSON (nested) |
yamlflat | YAML (flat) |
yamlnested | YAML (nested) |
properties | Java Properties |
po | Gettext (PO) |
strings | Apple Strings |
php | PHP Array |
resx | .NET ResX |
Sources: api/src/domain/http.ts:515-528
Project Statistics
The API provides an endpoint to retrieve detailed statistics about a project's translation progress.
| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/projects/:projectId/stats | Retrieves overall project stats and per-locale stats. |
The response includes projectStats (overall progress, total terms, locales) and localeStats (progress for each locale).
Sources: api/test/project-stats.e2e-spec.ts:17-31, api/src/domain/http.ts:183-193
Conclusion
The Traduora REST API is a powerful tool for developers looking to integrate translation management into their applications and CI/CD workflows. Its resource-oriented structure, clear authentication mechanism, and comprehensive feature set—including project management, translation handling, and robust import/export capabilities—make it a flexible and essential component of the Traduora platform. By leveraging the API, teams can significantly automate and streamline their localization processes.
Sources: README.md:17-23