npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

deeplx-lib

v0.0.5

Published

Powerful free DeepL API wrapper with no token required.

Readme

DeepLX-Lib

npm version npm downloads bundle JSDocs License

🌍 Powerful free DeepL API wrapper with no token required. Easily integrate DeepLX into any application.

Features

  • 📦 Zero dependencies, extremely lightweight
  • 🌐 Supports all DeepL languages (including variants like EN-GB, ZH-HANS)
  • 💡 Automatically constructs jsonrpc request bodies, mimicking browser behavior
  • 🧪 Fully tested with unit tests for reliability

Installation

npm i deeplx-lib
# or
pnpm add deeplx-lib
# or
yarn add deeplx-lib

Usage

import { translate } from 'deeplx-lib'

const result = await translate({
  from: 'EN',
  to: 'ZH',
  text: 'Hello, world!',
})

const data = await result.json()
console.log(data)
/*
{
  jsonrpc: '2.0',
  id: 123456789,
  result: {
    texts: [
      {
        alternatives: [ { text: '世界,你好' }, { text: '你好,世界!' }, { text: '大家好' } ],
        text: '你好,世界'
      }
    ],
    lang: 'EN',
    lang_is_confident: false,
    detectedLanguages: {
      EN: 0.48555099999999995,
      DE: 0.038853,
      FR: 0.003078,
      ES: 0.008555,
      PT: 0.0049429999999999995,
      IT: 0.016312,
      NL: 0.061256,
      PL: 0.017636,
      RU: 0.0004969999999999999,
      ZH: 0.0036209999999999997,
      JA: 0.000523,
      BG: 0.00007099999999999999,
      CS: 0.009665,
      DA: 0.0034609999999999997,
      EL: 0.00016099999999999998,
      ET: 0.008915,
      FI: 0.002085,
      HU: 0.004044,
      LT: 0.00029099999999999997,
      LV: 0.001053,
      RO: 0.004389,
      SK: 0.002541,
      SL: 0.00106,
      SV: 0.002949,
      TR: 0.00075,
      ID: 0.005395,
      UK: 0.00010899999999999999,
      KO: 0.006984,
      NB: 0.042485999999999996,
      AR: 0.000068,
      VI: 0.001168,
      HE: 0.000098,
      unsupported: 0.26143
    }
  }
}
*/

API

translate(options: IOptions): Promise<Response>

Send a translation request to DeepL's internal JSON-RPC endpoint.

Parameters

| Name | Type | Description | | ------ | ----------------- | ----------------- | | from | TSourceLanguage | Source language | | to | TTargetLanguage | Target language | | text | string | Text to translate |

parse2DeepLX(data: IOptions & IDeepLData): IDeepLXData

Parses the raw DeepL JSON-RPC response into a simplified, standardized format for easier usage.

Useful when you want to normalize the translate or fetch result into a consistent structure.

Example

import { parse2DeepLX, translate } from 'deeplx-lib'

const translateData: IOptions = {
  from: 'EN',
  to: 'ZH',
  text: 'Good morning',
}

const response = await translate(translateData)

const raw = (await response.json()) as IDeepLData
const normalized = parse2DeepLX({
  ...translateData,
  ...raw,
})

console.log(normalized)
/*
{
  code: 200,
  id: 123456789,
  method: 'Free',
  from: 'EN',
  to: 'ZH',
  source_lang: 'EN',
  target_lang: 'ZH',
  data: '早上好',
  alternatives: ['早安', '上午好']
}
*/

getBody(options: IOptions): string

Generates a JSON-RPC-compliant request body that mimics DeepL’s internal format. You can use it to manually perform the request using your own fetch implementation.

Example

import { DEEPL_URL, getBody } from 'deeplx-lib'

const body = getBody({
  from: 'EN',
  to: 'ZH',
  text: 'Hello, world!',
})

const response = await fetch(DEEPL_URL, {
  method: 'POST',
  body,
  headers: { 'Content-Type': 'application/json' },
})

const result = await response.json()
console.log(result) // The result is the same as `translate(options: IOptions)`

Language Types

// Subsequent changes may be made, see details at: https://github.com/lete114/deeplx-lib/blob/main/src/types.d.ts
export type TVariant = 'EN-GB' | 'EN-US' | 'PT-BR' | 'PT-PT' | 'ZH-HANS' | 'ZH-HANT'
export type TLanguage =
  | 'AR' | 'BG' | 'CS' | 'DA' | 'DE' | 'EL' | 'EN' | 'ES' | 'ET'
  | 'FI' | 'FR' | 'HU' | 'ID' | 'IT' | 'JA' | 'KO' | 'LT' | 'LV' | 'NB'
  | 'NL' | 'PL' | 'PT' | 'RO' | 'RU' | 'SK' | 'SL' | 'SV' | 'TR' | 'UK' | 'ZH'
export type TSourceLanguage = 'AUTO' | TLanguage
export type TTargetLanguage = TLanguage | TVariant

export interface IOptions {
  from: TSourceLanguage
  to: TTargetLanguage
  text: string
}

Other Exports

| Method | Description | | ------------------- | ---------------------------------------------------- | | parse2DeepLX | Parses the full DeepL response into a DeepLX format | | getBody | Constructs the JSON-RPC request body | | getICount | Counts the number of "i" characters in the text | | getTimestamp | Generates a timestamp adjusted by the text content | | getRandomNumber | Generates a pseudo-random request ID | | handlerBodyMethod | Modifies the method field to emulate client format |

Testing

Unit tests are written using Vitest. Run the tests with:

pnpm test

License

MIT License © Lete114