- Head to API Manager
- Click on credentials
- Create new credential->Api Key
- Your api key is a string in the form of something like:
BIzqTyzdDdg3fBqaouJI6z2nC3ygJNZ1qZsoYGc
Last active
May 12, 2017 15:50
-
-
Save cobookman/b8dcf407b9db76a04a25b1452cf46c7f to your computer and use it in GitHub Desktop.
Translate API Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Example translate API Call.""" | |
import requests | |
API_KEY="...." # Your API Key | |
API_URL="https://translation.googleapis.com/language/translate/v2" | |
r = requests.post(API_URL, data={ | |
"key": API_KEY, | |
"q": "Hi World", | |
"target": "de", | |
}) | |
print(r.text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
API_KEY="....." # Your API Key | |
DATA="{ | |
'q': 'Hello world', | |
'target': 'de' | |
}" | |
curl -XPOST \ | |
-H "Content-Type: application/json" \ | |
--data "$DATA" \ | |
"https://translation.googleapis.com/language/translate/v2?key=${API_KEY}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment