Skip to content

Commit f743594

Browse files
committed
Merge remote-tracking branch 'origin/main' into glossary-languages
2 parents 0d9c18a + 10569e2 commit f743594

9 files changed

Lines changed: 82 additions & 19 deletions

File tree

.mintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
reviews/*

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ For the highest quality documentation, use both the diataxis plugin and docs-rev
8181

8282
This two-pass approach ensures both structural correctness (via diataxis) and editorial quality (via docs-reviewer).
8383

84+
3. **Check for broken links:**
85+
86+
Finally, you can run `mint broken-links` and `mint broken-links --check-anchors` to ensure all links are correct.
87+
8488
### Future Plans
8589

8690
- Add a subagent to search our codebase and backstage
178 KB
Loading

api-reference/translate.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The text-translation API currently consists of a single endpoint, `translate`, w
99

1010
For highest translation quality, we recommend using our next-gen models. For details, please see [here](/docs/api-reference/translate#about-the-model-type-parameter).
1111

12-
To learn more about context in DeepL API translations, see our [context parameter guide](/docs/learning-how-tos/how-to-use-context-parameter).
12+
To learn more about context in DeepL API translations, see our [context parameter guide](/docs/learning-how-tos/examples-and-guides/how-to-use-context-parameter).
1313

1414
For more detail about request body parameters, see the [Request Body Descriptions](/api-reference/translate#request-body-descriptions) section further down on the page.
1515

docs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,11 @@
399399
},
400400
{
401401
"source": "/docs/best-practices/working-with-context",
402-
"destination": "/docs/learning-how-tos/how-to-use-context-parameter"
402+
"destination": "/docs/learning-how-tos/examples-and-guides/how-to-use-context-parameter"
403403
},
404404
{
405405
"source": "/docs/learning-how-tos/cookbook/context-parameter-examples",
406-
"destination": "/docs/learning-how-tos/how-to-use-context-parameter"
406+
"destination": "/docs/learning-how-tos/examples-and-guides/how-to-use-context-parameter"
407407
}
408408
],
409409
"integrations": {

docs/best-practices/custom-instructions.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ Combining `custom_instructions` with `model_type: latency_optimized` will result
9494
## Related documentation
9595

9696
- [Text translation API reference](/api-reference/translate)
97-
- [Working with context](/docs/examples-and-guides/how-to-use-context-parameter)
97+
- [Working with context](/docs/learning-how-tos/examples-and-guides/how-to-use-context-parameter)
9898
- [Style rules API](/api-reference/style-rules)
9999
- [Multilingual glossaries](/api-reference/multilingual-glossaries)

docs/best-practices/pre-production-checklist.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ As you prepare to open your DeepL-powered application up to the world, these tip
1111
* Uploading a file for document translation requires an HTTP POST request with `Content-Type: multipart/form-data`; this content type should not be used for text translation.
1212
4. **No query parameters:** Please do not make API requests using query parameters. The examples throughout the API reference include properly formed HTTP POST requests. For security reasons, be especially sure not to send your authentication key via query parameters.
1313
5. **CORS requests:** It's not possible to send requests to the DeepL API from the browser, as requests to third-party APIs from front-end applications would expose your credentials on the web. [You can learn more here](/docs/best-practices/cors-requests).
14-
6. **Translation context:** DeepL considers the broader context of a source text or document when translating. In general, including more context in a source text or document can result in a higher-quality DeepL translation. For text translation, you can also try the [`context` parameter](/api-reference/translate#request-body-descriptions). [Learn more about working with context here](/docs/best-practices/working-with-context).
14+
6. **Translation context:** DeepL considers the broader context of a source text or document when translating. In general, including more context in a source text or document can result in a higher-quality DeepL translation. For text translation, you can also try the [`context` parameter](/api-reference/translate#request-body-descriptions). [Learn more about working with context here](/docs/learning-how-tos/examples-and-guides/how-to-use-context-parameter).
1515
7. **Cache results from translation requests:** Storing API responses lets apps serve content faster and avoids extra costs from repeated requests for unchanged content.
Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,94 @@
11
---
2-
title: "Node.js Proxy Server"
3-
description: "A lightweight local proxy for the DeepL API that enables browser-based applications to bypass CORS restrictions."
2+
title: "Making API calls from client-side JavaScript"
3+
description: "Two lightweight local proxies that let you try the DeepL API directly from a website"
44
public: true
55
---
66

7+
<Note>
8+
These proxies are intended for prototyping and frontend testing. For production environments, consider implementing your own backend service with additional security measures and rate limiting.
9+
</Note>
10+
11+
## Rationale
12+
13+
The DeepL API does not permit calls from client-side JavaScript - that is, from JavaScript running in a browser. This policy exists to keep your API key safe. When you place a call from your website directly to the DeepL API, that call needs to include your API key. Anyone using your website could look at the network calls or your code itself, find your API key, and use it themselves.
14+
15+
For this and other security considerations, DeepL [does not enable the CORS headers](/docs/best-practices/cors-requests) you would need to call the API from a webpage hosted on your origin. The industry-standard approach is to call APIs like DeepL’s from a back-end service. DeepL enforces this best practice to keep your credentials secure.
16+
17+
## When to use a quick proxy
18+
19+
But what do you do if you want to use the API quickly, in a prototype, a demo, or a hackathon, where you need to get up and running fast? What if you don’t have easy access to a server?
20+
21+
For such situations, here are two solutions.
22+
23+
## Node.js Proxy Server
24+
725
<Card title="GitHub - DeepLcom/deepl-api-nodejs-proxy" icon="github" horizontal href="https://github.com/DeepLcom/deepl-api-nodejs-proxy">
826
DeepL API Node.js Proxy on GitHub
927
</Card>
1028

29+
This full-featured proxy server supports all DeepL API endpoints, including text translation, document translation, and glossaries. Built with Node.js and Express with minimal dependencies, it handles CORS headers for you and keeps your API key secure. It even includes an interactive web demo for testing translations right in your browser.
1130

12-
## Overview
31+
This proxy includes an interactive setup wizard to get you started quickly. Clone the repo, run the setup, and start sending requests from your browser. Check out the [GitHub repository](https://github.com/DeepLcom/deepl-api-nodejs-proxy) for full setup instructions and Docker support.
1332

14-
This lightweight proxy server lets you call the DeepL API directly from browser-based applications. In simpler terms, it lets you make DeepL API calls from your client-side JavaScript without running into browser security restrictions.
33+
## Quick & dirty PHP proxy
1534

16-
Since the DeepL API doesn't allow direct browser requests (see [CORS requests documentation](/docs/best-practices/cors-requests)), this proxy handles CORS headers and keeps your API key secure. Perfect for hackathons, demos, and quick prototypes where you need to get up and running fast.
35+
If you’re just using our `/translate` endpoint and want an even quicker solution, or if you don’t use node.js, you could use the PHP code below to create an instant proxy server. If PHP is not already installed on your machine, you can download and install it at [php.net](https://www.php.net/downloads.php).
1736

18-
Built with Node.js and Express with minimal dependencies. Supports all DeepL API endpoints including text translation, document translation, and glossaries. Includes an interactive web demo for testing translations right in your browser.
37+
The PHP script takes the parameters in the query string and passes them into a `POST` request to `/translate`. It does not check that the parameters are valid and does not support any other endpoints, although you could modify it to do so.
1938

20-
<Note>
21-
This proxy is intended for prototyping and frontend testing. For production environments, consider implementing your own backend service with additional security measures and rate limiting.
22-
</Note>
39+
To use this while developing on your local machine:
40+
41+
* replace `{your API key here}` with your actual API key
42+
* create a file in your favorite directory with the PHP code below
43+
* go to your terminal and visit that directory
44+
* type `php -S localhost:8000`
45+
46+
Your JavaScript can then access the DeepL API at `http://localhost:8000/php-proxy.php`. For example, to send a translation request with `text` and `target_lang`:
47+
48+
```javascript
49+
const url = `http://localhost:8000/deepl-proxy.php?text=${encodeURIComponent(text)}&target_lang=${encodeURIComponent(targetLang)}`;
50+
const response = await fetch(url);
51+
const result = await response.text();
52+
```
53+
54+
Here is the PHP script:
2355

24-
## Quick Start
56+
```php
57+
<?php
58+
header('Content-Type: application/json');
59+
header('Access-Control-Allow-Origin: *');
60+
61+
$apiKey = '{your API key here}';
62+
$apiUrl = 'https://api.deepl.com/v2/translate';
63+
64+
$data = http_build_query($_GET);
65+
66+
$context = stream_context_create([
67+
'http' => [
68+
'method' => 'POST',
69+
'header' => "Authorization: DeepL-Auth-Key " . $apiKey . "\r\n" .
70+
"Content-Type: application/x-www-form-urlencoded\r\n",
71+
'content' => $data
72+
]
73+
]);
74+
75+
echo file_get_contents($apiUrl, false, $context);
76+
?>
77+
```
2578

26-
The proxy includes an interactive setup wizard to get you started quickly. Clone the repo, run the setup, and start sending requests from your browser. Check out the [GitHub repository](https://github.com/DeepLcom/deepl-api-nodejs-proxy) for full setup instructions and Docker support.
2779

2880
## Screenshots
2981

30-
<Frame>
82+
### Node.js proxy
83+
<Frame caption="Node.js proxy server running in a terminal">
3184
<img src="https://raw.githubusercontent.com/DeepLcom/deepl-api-nodejs-proxy/main/assets/proxy-running.png" alt="Node.js proxy server running and ready to accept requests" />
3285
</Frame>
3386

34-
<Frame>
87+
<Frame caption="Interactive web demo interface for testing translations">
3588
<img src="https://raw.githubusercontent.com/DeepLcom/deepl-api-nodejs-proxy/main/assets/dashboard-demo.png" alt="Interactive web demo interface for testing translations" />
3689
</Frame>
90+
91+
### PHP proxy
92+
<Frame caption='PHP proxy running in a terminal'>
93+
![](/_assets/images/php-proxy-screenshot.png)
94+
</Frame>

docs/learning-how-tos/examples-and-guides/translating-between-variants.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,5 @@ Now that you understand how to translate between language variants:
130130
- **Try it yourself:** Test out style rules and custom instructions in the [text translation API playground](/api-reference/translate)
131131
- **Learn about the Write API:** Explore the [/write/rephrase endpoint](/api-reference/improve-text) for high-quality variant translation and rephrasing
132132
- **Manage reusable rules:** Learn how to create [style rules](/api-reference/style-rules) for systematic variant transformations
133-
- **Improve translation quality:** Understand how [the context parameter](/docs/best-practices/working-with-context) can enhance ambiguous translations
133+
- **Improve translation quality:** Understand how [the context parameter](/docs/learning-how-tos/examples-and-guides/how-to-use-context-parameter) can enhance ambiguous translations
134134

0 commit comments

Comments
 (0)