Weglot
WebsiteGithubSlack
  • Developer Documentation
  • WordPress
    • Getting Started
    • Helpers Functions
    • Hooks
      • Translations Hooks
      • Other Hooks
    • Use cases
      • Lang attribute
      • Translate link
      • Implementing Custom Link Translation
      • Wp-rocket Lazyload
      • Deactivate Weglot on Elementor
      • Weglot translate on Elementor
      • Language Selector Styling
      • Change flag size
      • Exclude a Custom Post Type
      • Exclude the search page
      • Exclude draft or private status post
      • Plugin Woocommerce: Translate all email sent to customers
      • Plugin WooCommerce: Translate Product URLs
      • Use custom language code (URL, lang and hreflang attribute)
      • Theme OceanWP: Use language selector in the main menu
      • Theme Avada: Use language selector in the main menu
      • LinkedIn Share Post: Translate oEmbed WP URL
      • Hide button on excluded page
      • Auto switch only for HomePage
      • Proxify Url
      • Translate pdf for Woocommerce pdf invoice
      • Translate pdf with Gravity pdf
      • Translate Dublin core meta (or other meta)
      • How to not translate specific ajax action
      • How to get translated url programmatically
      • How to set WP locale based on Weglot current language
      • How to translate mail from Photo Reviews for WooCommerce
      • How to translate schema from schema.org generate by Yoast plugin
      • How to translate email sending by plugin WP Mail SMTP
      • How to hide the Weglot admin button for non administrator roles
      • Exemple of snippet to translate search from JetSearch plugin
      • Example of snippet to translate your checkout element (override/added by the Funnel Builder plugin)
      • LScache
      • How to fix live builder issue with Weglot
      • Add translated url to Rankmath sitemap index
      • Advanced Woo Search X Weglot
      • Conditionally Disabling Weglot Translation for Specific URLs
    • Weglot filters
      • weglot_translate_email
      • weglot_cancel_init
      • weglot_translate_email_languages_forced
      • weglot_menu_parent_item_title
      • weglot_active_current_menu_item
      • weglot_ajax_no_translate
      • weglot_active_translation_before_process
      • weglot_active_translation_before_treat_page
      • weglot_debug_file
      • weglot_autoredirect_only_home
      • weglot_autoredirect_skip
      • weglot_remove_google_translate
      • weglot_add_hreflang
      • weglot_get_replace_modify_link
      • get_replace_modify_link_in_xml
      • weglot_get_flag_class
      • weglot_get_name_with_language_entry
      • weglot_get_class_dropdown
      • weglot_button_html
      • weglot_get_dom_checkers
      • weglot_replace_div_id
      • weglot_replace_weglot_menu
      • weglot_render_default_button
      • weglot_render_switcher_editor_button
      • weglot_href_lang
      • weglot_get_options_from_cdn_cache
      • weglot_get_options_from_cdn_cache_duration
      • weglot_get_slugs_from_cache
      • weglot_get_slugs_cache_duration
      • weglot_exclude_blocks
      • weglot_exclude_urls
      • weglot_get_parser_ignored_nodes
      • weglot_navigator_language
      • weglot_url_auto_redirect
      • weglot_replace_url
      • weglot_replace_link
      • weglot_ajax_replace_urls
      • weglot_proxify_urls
      • weglot_add_json_keys
      • weglot_json_treat_page
      • weglot_html_treat_page
      • Copy of weglot_xml_treat_page
      • weglot_render_dom
      • weglot_default_current_language_empty
    • Algolia integration
  • Proxy
    • Headers
  • Javascript
    • Getting Started
    • Options
    • Javascript functions
    • Language link Hooks
    • Translate iframe
    • Advanced concepts
      • Translation engines
  • CMS Specific
    • Shopify
  • API
    • Reference
  • Cookies
Powered by GitBook
On this page
  • Public Endpoints
  • Status
  • List languages
  • Is language pair supported
  • Authenticated Endpoints
  • Translate
  • Resources
  • BotType
  • WordType
  1. API

Reference

Public Endpoints

Status

GET https://api.weglot.com/public/status

This endpoint is used as a health check. You can use it to check if the Weglot API is up and running.

[]

No content is returned by this endpoint, you will only get a 200 status code if the service is up and running.

This is only a health check endpoint, don't spam it.

List languages

GET https://api.weglot.com/public/languages

This endpoint returns all availaible languages.

Headers

Name
Type
Description

Content-Type

string

application/json

[
    {
        "code": "af",
        "local_name": "Afrikaans",
        "english_name": "Afrikaans"
    },
    {
        "code": "ar",
        "local_name": "العربية\u200f",
        "english_name": "Arabic"
    },
    {
        "code": "az",
        "local_name": "Azərbaycan dili",
        "english_name": "Azerbaijani"
    },
    {
        "code": "be",
        "local_name": "Беларуская",
        "english_name": "Belarusian"
    },
    {
        "code": "bg",
        "local_name": "български",
        "english_name": "Bulgarian"
    },
    ...
]    

Is language pair supported

GET https://api.weglot.com/public/languages/is-supported

Query Parameters

Name
Type
Description

languageTo

string

The language you wish to translate to

languageFrom

string

The original language

Headers

Name
Type
Description

Content-Type

string

application/json

{
    "is_supported": true
}

Authenticated Endpoints

The API key is to be included in all API requests to the server in the URL as the value of the api_key parameter, as follows:

https://api.weglot.com/endpoint?api_key=my_api_key

Make sure to replace my_api_key with your Weglot API key.

Translate

POST https://api.weglot.com/translate?api_key=my_api_key

This endpoint retrieves all translations. It takes an array of sentences in an original language in input and outputs the same array of sentences but translated in another language. The body is sent in the JSON format

Query Parameters

Name
Type
Description

api_key

string

Your Weglot API Key

Headers

Name
Type
Description

Content-Type

string

application/json

Request Body

Name
Type
Description

l_from

string

ISO 639-1 code of the original language

l_to

string

ISO 639-1 code of the destination language

words

array

Sentences in original language

words[t]

integer

Type of the word based on WordType resource

words[w]

string

Sentence to translate

bot

integer

Link to user agent based on BotType resource

request_url

string

URL where the request come from

title

string

Title of the page where these sentences come from

{  
   "l_from":"en",
   "l_to":"fr",
   "title":"My awesome page",
   "request_url":"https:\/\/www.website.com\/",
   "bot":0,
   "from_words":[  
      "This is a blue car",
      "This is a black car"
   ],
   "to_words":[  
      "C'est une voiture bleue",
      "C'est une voiture noire"
   ]
}

Here is a simple request example:

POST /translate?api_key=my_api_key HTTP/1.1
Host: api.weglot.com
Content-Type: application/json

{  
   "l_from":"en",
   "l_to":"fr",
   "request_url":"https://www.website.com/",
   "words":[  
      {"w":"This is a blue car", "t": 1},
      {"w":"This is a black car", "t": 1}
   ]
}
curl -X POST \
  'https://api.weglot.com/translate?api_key=my_api_key' \
  -H 'Content-Type: application/json' \
  -d '{  
   "l_from":"en",
   "l_to":"fr",
   "request_url":"https://www.website.com/",
   "words":[  
      {"w":"This is a blue car", "t": 1},
      {"w":"This is a black car", "t": 1}
   ]
}'

Resources

BotType

Used to define the source of a request.

Short-Name

Value

Description

HUMAN

0

Sent from human action

OTHER

1

Sent from unknown source

GOOGLE

2

Sent from Google Bot

BING

3

Sent from Bing Bot

YAHOO

4

Sent from Yahoo Bot

BAIDU

5

Sent from Baidu Bot

YANDEX

6

Sent from Yandex Bot

WordType

Used to provide context over where the text we wish to translate comes from. Any general text node is of WordType 1. We use the WordType to classify translations on the admin dashboard.

Short name

Value

Description

OTHER

0

None of the elements below (deprecated)

TEXT

1

General text (used most of the time)

VALUE

2

The value of an input tag'svalueattribute

PLACEHOLDER

3

The value of an input tag's placeholderattribute

META_CONTENT

4

The value of a meta tags' content attribute

IFRAME_SRC

5

The src link to a page used in an iframe

IMG_SRC

6

The srcvalue of an imgtag

IMG_ALT

7

The alt value of an imgtag

PDF_HREF

8

A URL pointing to a PDF document

PAGE_TITLE

9

Text from title tag

EXTERNAL_LINK

10

External links when dashboard option is enabled

PreviousShopifyNextCookies

Last updated 11 months ago

Weglot requires an API key to allow access to its endpoints. You can register and get a Weglot API Key at: .

You can find and resources at the end of this document.

Register
WordType
BotType