Translate
Translates some Text to any Language
POST /api/ai/translate
https://api.cookie-api.com/api/ai/translate
Authentication Learn how to get your API Key and use it in your requests!
URL Parameters | |
---|---|
text | The text that should be translated |
language | The language the text should be translated to |
source_language optional | For more accurate Translations put the source language of the text to be translated here |
curl --location --request POST 'https://api.cookie-api.com/api/translate?language=german&text=Hello%20how%20are%20you%3F' \--header 'Authorization: API_Key'
import requests
url = 'https://api.cookie-api.com/api/translate'headers = { 'Authorization': 'API_Key'}params = { 'language': 'german', 'text': 'Hello how are you?'}
response = requests.post(url, headers=headers, params=params)print(response.json())
const fetch = require('node-fetch');
const url = 'https://api.cookie-api.com/api/translate';const headers = { 'Authorization': 'API_Key', 'Content-Type': 'application/json'};const params = new URLSearchParams({ language: 'german', text: 'Hello how are you?'});
fetch(`${url}?${params}`, { method: 'POST', headers: headers}).then(res => res.json()).then(data => console.log(data)).catch(err => console.error(err));
package main
import ( "bytes" "fmt" "log" "net/http" "net/url")
func main() { apiUrl := "https://api.cookie-api.com/api/translate" params := url.Values{} params.Add("language", "german") params.Add("text", "Hello how are you?")
req, err := http.NewRequest("POST", apiUrl+"?"+params.Encode(), nil) if err != nil { log.Fatal(err) }
req.Header.Set("Authorization", "API_Key") req.Header.Set("Content-Type", "application/json")
client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close()
var res map[string]interface{} if err := json.NewDecoder(resp.Body).Decode(&res); err != nil { log.Fatal(err) }
fmt.Println(res)}
const https = require('https');
const params = new URLSearchParams({ language: 'german', text: 'Hello how are you?'});
const options = { hostname: 'api.cookie-api.com', path: '/api/translate?' + params.toString(), method: 'POST', headers: { 'Authorization': 'API_Key', 'Content-Type': 'application/json' }};
const req = https.request(options, res => { let body = '';
res.on('data', chunk => { body += chunk; });
res.on('end', () => { console.log(JSON.parse(body)); });});
req.on('error', error => { console.error(error);});
req.end();
require 'net/http'require 'uri'require 'json'
uri = URI.parse('https://api.cookie-api.com/api/translate')
params = { language: 'german', text: 'Hello how are you?'}
uri.query = URI.encode_www_form(params)
request = Net::HTTP::Post.new(uri)request['Authorization'] = 'API_Key'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request)end
puts response.body
use reqwest::blocking::Client;use reqwest::header::{HeaderMap, CONTENT_TYPE};use std::collections::HashMap;
fn main() { let url = "https://api.cookie-api.com/api/translate"; let client = Client::new();
let mut headers = HeaderMap::new(); headers.insert("Authorization", "API_Key".parse().unwrap()); headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
let mut params = HashMap::new(); params.insert("language", "german"); params.insert("text", "Hello how are you?");
let res = client .post(url) .headers(headers) .form(¶ms) .send() .unwrap();
println!("{}", res.text().unwrap());}
Responses
{ "response": "Hallo, wie geht es Ihnen?", "success": true}