Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BigLobsterito/28698fa062f51a7d71359315421570b9 to your computer and use it in GitHub Desktop.
Save BigLobsterito/28698fa062f51a7d71359315421570b9 to your computer and use it in GitHub Desktop.

Python: How to determine the language?

Installing

To use Unirest for Python, install it using pip:

pip install unirest

Making a Request

After installing the pip package, you can now begin making API requests by importing unirest and forming a request:

import unirest

apikey = "key_from_rapidapi"
text_for_detection = "Some text needed to detect its language"

response = unirest.post("https://language-identification-prediction.p.rapidapi.com/v1/recognize-language/",
  headers={
    "X-RapidAPI-Host": "language-identification-prediction.p.rapidapi.com",
    "X-RapidAPI-Key": apikey,
    "Content-Type": "application/x-www-form-urlencoded"
  },
  params={
    "text": text_for_detection
  }
)

response.body # The parsed response

# full description of response here: https://rapidapi.com/BigLobster/api/language-identification-prediction/details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment