Skip to content

Latest commit

 

History

History
74 lines (52 loc) · 1.16 KB

README.md

File metadata and controls

74 lines (52 loc) · 1.16 KB

go-deepl

Unofficial DeepL API client for Go.

Install

go get -u github.com/candy12t/go-deepl@latest

Usage

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"
	"os"

	"github.com/candy12t/go-deepl"
)

func main() {
	authkey := os.Getenv("DEEPL_AUTH_KEY")
	client := deepl.NewClient(authkey)

	translatetext, err := client.TranslateText(context.Background(), []string{"Hello world"}, "JA", deepl.TranslateOption{SourceLang: "EN"})
	if err != nil {
		log.Fatal(err)
	}
	b, err := json.Marshal(translatetext)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(b))
}

References

APIs

Translate Text

  • POST /v2/translate

Translate Documents

  • POST /v2/document
  • POST /v2/document/{document_id}
  • POST /v2/document/{document_id}/result

Manage Glossaries

  • GET /v2/glossary-language-pairs
  • POST /v2/glossaries
  • GET /v2/glossaries
  • GET /v2/glossaries/{glossary_id}
  • DELETE /v2/glossaries/{glossary_id}
  • GET /v2/glossaries/{glossary_id}/entries

General

  • GET /v2/usage
  • GET /v2/languages

License

MIT License