-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
193 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ DB_PORT=5432 | |
DB_USER=root | ||
DB_PASSWORD=root | ||
DB_DATABASE=app | ||
OPENAI_API_KEY= | ||
OPENAI_API_KEY=elo_zelo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,193 @@ | ||
# backend-translator | ||
|
||
 | ||
 | ||
|
||
# Translation API Documentation | ||
|
||
## Base URL | ||
|
||
``` | ||
/api/v1 | ||
``` | ||
|
||
## Endpoints | ||
|
||
### Languages | ||
|
||
#### Get All Languages | ||
|
||
``` | ||
GET /languages | ||
``` | ||
|
||
**Response:** List of all available languages. | ||
|
||
#### Create a Language | ||
|
||
``` | ||
POST /languages | ||
``` | ||
|
||
**Body:** | ||
|
||
```json | ||
{ | ||
"isoCode": "en", | ||
"name": "English" | ||
} | ||
``` | ||
|
||
**Response:** Created language object. | ||
|
||
#### Get Language by ISO Code | ||
|
||
``` | ||
GET /languages/:isoCode | ||
``` | ||
|
||
**Response:** Language object. | ||
|
||
#### Update Language | ||
|
||
``` | ||
PUT /languages/:isoCode | ||
``` | ||
|
||
**Body:** | ||
|
||
```json | ||
{ | ||
"name": "Updated Name" | ||
} | ||
``` | ||
|
||
**Response:** Updated language object. | ||
|
||
#### Delete Language | ||
|
||
``` | ||
DELETE /languages/:isoCode | ||
``` | ||
|
||
**Response:** No content. | ||
|
||
--- | ||
|
||
### Translations | ||
|
||
#### Get All Translations | ||
|
||
``` | ||
GET /translations | ||
``` | ||
|
||
**Response:** List of all translations. | ||
|
||
#### Create a Translation | ||
|
||
``` | ||
POST /translations | ||
``` | ||
|
||
**Body:** | ||
|
||
```json | ||
{ | ||
"originalText": "Hello", | ||
"originalLanguageCode": "en", | ||
"translatedLanguageCode": "fr", | ||
"translatedText": "Bonjour" | ||
} | ||
``` | ||
|
||
**Response:** Created translation object. | ||
|
||
#### Get Translations for a Specific Text | ||
|
||
``` | ||
GET /translations/:hash | ||
``` | ||
|
||
**Response:** List of translations for the given text hash. | ||
|
||
#### Get Translations for a Specific Language | ||
|
||
``` | ||
GET /translations/:isoCode | ||
``` | ||
|
||
**Response:** List of translations in the given language. | ||
|
||
#### Get Specific Translation | ||
|
||
``` | ||
GET /translations/:hash/:isoCode | ||
``` | ||
|
||
**Response:** Translation object. | ||
|
||
#### Update Translation | ||
|
||
``` | ||
PUT /translations/:hash/:isoCode | ||
``` | ||
|
||
**Body:** | ||
|
||
```json | ||
{ | ||
"originalText": "Hello", | ||
"translatedText": "Salut" | ||
} | ||
``` | ||
|
||
**Response:** Updated translation object. | ||
|
||
#### Delete Translation | ||
|
||
``` | ||
DELETE /translations/:hash/:isoCode | ||
``` | ||
|
||
**Response:** No content. | ||
|
||
#### Approve Translation | ||
|
||
``` | ||
POST /translations/:hash/:isoCode/approve | ||
``` | ||
|
||
**Response:** Approved translation object. | ||
|
||
#### Request Translation via OpenAI | ||
|
||
``` | ||
POST /translations/openAI | ||
``` | ||
|
||
**Body:** | ||
|
||
```json | ||
{ | ||
"originalText": "Hello", | ||
"originalLanguageCode": "en", | ||
"translatedLanguageCode": "es" | ||
} | ||
``` | ||
|
||
**Response:** Translation object created using OpenAI. | ||
|
||
--- | ||
|
||
## Notes | ||
|
||
- The `hash` parameter is generated using SHA-256 from `originalText`. | ||
- The OpenAI translation request utilizes `gpt-4o-mini`. | ||
- All responses follow JSON format. | ||
- Errors return appropriate HTTP status codes with messages. | ||
- **The API is generated by ChatGPT - watch out for inconsistencies** | ||
|
||
## Links | ||
|
||
[](https://docs.solvro.pl) |