Grammar API
This API provides data about spelling and grammar checks.
- The Different Languages Offered:
- Below is the proccess of getting text checked gramatically. The result displayed is the error and possible reccomendations to change
import requests
url = "https://dnaber-languagetool.p.rapidapi.com/v2/languages"
headers = {
"X-RapidAPI-Key": "7b146afe20msh92e84c02ae27c6ap1185b5jsnb7a574f24cbe",
"X-RapidAPI-Host": "dnaber-languagetool.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
# print(response.text)
print("Languages Supported")
languagelist = response.json()
for language in languagelist:
print(language["name"], " = ", language["code"]) #this code is used in the next step to check the grammer in a specified language
import requests
import json
url = "https://dnaber-languagetool.p.rapidapi.com/v2/check"
payload = "language=en-US&text=" #because of use of code'eu' this is checking in English
headers = {
"content-type": "application/x-www-form-urlencoded",
"X-RapidAPI-Key": "7b146afe20msh92e84c02ae27c6ap1185b5jsnb7a574f24cbe",
"X-RapidAPI-Host": "dnaber-languagetool.p.rapidapi.com"
}
text = input("Please enter the text you would like checked")
payload += text #this appends the string defined above to add the text needing to be checked
response = requests.request("POST", url, data=payload, headers=headers)
# print(response.text)
#print(json.dumps(response.json(), indent=4))
print(json.dumps(response.json()["matches"], indent=4)) #the json.dumps formats the data to be prettier :)