{"id":28419371,"url":"https://github.com/deeplcom/deepl-mock","last_synced_at":"2025-06-27T04:32:12.790Z","repository":{"id":38191998,"uuid":"390404463","full_name":"DeepLcom/deepl-mock","owner":"DeepLcom","description":"deepl-mock is a mock HTTP server that simulates some behavior of the DeepL API to simplify application testing.","archived":false,"fork":false,"pushed_at":"2025-04-22T16:04:52.000Z","size":480,"stargazers_count":27,"open_issues_count":1,"forks_count":5,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-06-04T22:08:20.605Z","etag":null,"topics":["api","deepl","mock"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeepLcom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-07-28T15:38:47.000Z","updated_at":"2025-04-24T14:52:50.000Z","dependencies_parsed_at":"2024-01-24T16:47:57.358Z","dependency_job_id":"da7e3e59-3e19-4a87-b270-652cf7343033","html_url":"https://github.com/DeepLcom/deepl-mock","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/DeepLcom/deepl-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeepLcom%2Fdeepl-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeepLcom%2Fdeepl-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeepLcom%2Fdeepl-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeepLcom%2Fdeepl-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeepLcom","download_url":"https://codeload.github.com/DeepLcom/deepl-mock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeepLcom%2Fdeepl-mock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262188396,"owners_count":23272341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","deepl","mock"],"created_at":"2025-06-04T17:30:42.801Z","updated_at":"2025-06-27T04:32:12.777Z","avatar_url":"https://github.com/DeepLcom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeepL API mock server\nA mock server that simulates some behaviour of the\n[DeepL API](https://www.deepl.com/docs-api?utm_source=github\u0026utm_medium=github-deepl-mock-readme) to simplify application\ntesting. In addition, a proxy server is included to test proxy usage.\n\nNote: this server is intended for testing, not for use in production, and it might not receive\nregular security updates. \n\n## Usage\n\nThe server listens on two ports: the main port (by default: 3000) imitates the DeepL API, and the\nproxy port (by default: 3001) implements a basic proxy server.   \n\n### Using Docker\n\nWith Docker, no other software needs to be installed. Build a Docker image using the provided Dockerfile:\n```shell\ndocker image build -t deepl/deepl-mock .\n```\n\nRun a Docker container using the image, exposing ports 3000 and 3001:\n```shell\ndocker run -d --rm --name deepl-mock -p3000:3000 -p3001:3001 deepl/deepl-mock\n```\n\nIf you are executing unit tests of an official DeepL client library (for example\n[deepl-python](https://github.com/DeepLcom/deepl-python)\nor [deepl-dotnet](https://github.com/DeepLcom/deepl-dotnet)), define the following\nenvironment variables before executing the tests:\n```shell\nexport DEEPL_MOCK_SERVER_PORT=3000\nexport DEEPL_MOCK_PROXY_SERVER_PORT=3001\nexport DEEPL_SERVER_URL=http://localhost:3000\nexport DEEPL_PROXY_URL=http://localhost:3001\n\n# Execute tests -- see the corresponding client library documentation\n...\n```\n\nWhen finished, stop the Docker container:\n```shell\ndocker stop deepl-mock\n```\n\n### Manually\n\nYou can also run the server manually without using Docker. First install\n[Node.js](https://nodejs.dev/learn/how-to-install-nodejs), then proceed using `npm`:\n```shell\nnpm install     # Install required packages\nnpm audit       # Check for security updates\nnpm start       # Run the mock server\n```\n\nBy default, the mock server listens on ports 3000 (main API) and 3001 (basic proxy). Define the\n**DEEPL_MOCK_SERVER_PORT** and **DEEPL_MOCK_PROXY_SERVER_PORT** environment variables to change this\nbehaviour:\n```shell\nexport DEEPL_MOCK_SERVER_PORT=4000\nexport DEEPL_MOCK_PROXY_SERVER_PORT=4001\nnpm start\n```\nIf you are executing unit tests of an official DeepL client library the **DEEPL_SERVER_URL** and\n**DEEPL_PROXY_URL** environment variables should also be updated.\n\n## Server configuration via HTTP-request header\nThe HTTP-request header **mock-server-session** may be sent with any request, containing a unique string identifying the\ntest session. A session identifier could be, for example, a test-case name and UUID.\n\nWhen the server receives an unrecognized session identifier, it creates a new session and uses the session headers\n(listed in the table below) to configure the session. These settings affect all requests in that session. Note that\nonce created, sessions cannot be reconfigured.\n\nThe server removes sessions after 10 minutes of inactivity.\n\n| Header field                                 | Type    | Description                                                                                                                                       |\n|:---------------------------------------------|:--------|:--------------------------------------------------------------------------------------------------------------------------------------------------|\n| mock-server-session                          | Any     | Uniquely identifies this test session.                                                                                                            |\n| mock-server-session-no-response-count        | Integer | Specifies the number of requests that should result in no response before resuming normal behavior.                                               |\n| mock-server-session-429-count                | Integer | Specifies the number of **/translate** requests that should result in a **429 Too Many Requests** response before resuming normal behavior.       |\n| mock-server-session-doc-failure              | Integer | Specifies the number of documents that should fail during translation before resuming normal behavior.                                            |\n| mock-server-session-init-character-limit     | Integer | Specifies the character limit for user accounts created in this session, specify 0 to remove limit. Default: 20000000.                            |\n| mock-server-session-init-document-limit      | Integer | Specifies the document limit for user accounts created in this session, specify 0 to remove limit. Default: 10000.                                |\n| mock-server-session-init-team-document-limit | Integer | Specifies the team document limit for user accounts created in this session. Default: no limit.                                                   |\n| mock-server-session-doc-queue-time           | Integer | Specifies the time in milliseconds that documents are queued before being translated.                                                             |\n| mock-server-session-doc-translate-time       | Integer | Specifies the time in milliseconds that documents take to translate.                                                                              |\n| mock-server-session-expect-proxy             | Integer | If non-zero, only requests via the proxy server are accepted. Requests are considered to come via proxy if the Forwarded HTTP header is included. |\n| mock-server-session-allow-reconnections      | Integer | If non-zero, disables rejecting requests due to unnecessary reconnections.                                                                        |\n| mock-server-session-allow-missing-user-agent | Integer | If non-zero, disables rejecting requests due to missing User-Agent.                                                                               |\n\n## Limitations compared with the DeepL API\n### Limited translation\nThe real DeepL API can accurately translate arbitrary text, however this mock server can only translate the test\nphrase \"proton beam\" among the DeepL-supported languages, and multi-line text where each line contains the phrase\n\"proton beam\". The translation functions will check the desired target language and respond with the corresponding\ntranslation of \"proton beam\", regardless of the input text. \n\nAdditionally, this mock server cannot auto-detect the source language, unless it matches one of the test phrase\ntranslations. Otherwise, the source language is assumed to be English.\n\n### Simplified glossaries\nThis mock server implements glossaries and translations using glossaries, but translations will only\nmake use of glossary terms if the whole input text (or each line in a document) *exactly* matches a\nglossary term. In contrast, the real DeepL API uses sentence context and language grammar when\napplying glossary terms.\n\n### User accounts\nThis server creates a new user account whenever it receives a request with an unrecognized **auth_key**. To test\nbehaviour due to an incorrect key use either an empty key, or the value \"invalid\". The server removes user accounts\nafter 10 minutes of inactivity.\n\n### Only .txt and .htm/.html files\nThis mock server only supports .txt and .htm/.html files for document translation. The DeepL API additionally supports\n.docx, .pptx, .pdf, .html/.htm, .xlf/.xliff, and .xlsx files. The server removes documents after 10 minutes of inactivity.\n\n### Account usage\nThis mock server uses simplified calculations to update account usage. \n\n### Formality, tag-handling, formatting \nThis mock server does not implement these features, however the API input parameters are validated.\n\n### Model types\nThis mock server allows the quality-optimized models for all language pairs,\nunlike the real DeepL API (which supports a subset of language pairs). Note that\nas this mock server does not implement translation, the model type used has no\nimpact.\n\n## Additional checks compared with the DeepL API\n\n### User-Agent\n\nThis mock server rejects requests that do not include a non-empty `User-Agent` header, while the DeepL API accepts them.\nTo disable this check, set the `mock-server-session-allow-missing-user-agent` session header to non-zero.\n\n### Socket reconnections\n\nTo check that clients use `Keep-Alive` correctly, this mock server detects when a new socket is used for an\nexisting session and rejects these requests. Clients correctly using `Keep-Alive` should avoid these rejections.\nTo disable this check, set the `mock-server-session-allow-reconnections` session header to non-zero.\n\n## Issues\nIf you experience problems using the library, or would like to request a new feature, please open an\n[issue][issues]. \n\n## Development\n\nWe welcome Pull Requests, please read the [contributing guidelines](CONTRIBUTING.md).\n\n[issues]: https://www.github.com/DeepLcom/deepl-mock/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeplcom%2Fdeepl-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeeplcom%2Fdeepl-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeplcom%2Fdeepl-mock/lists"}