Search code examples
google-apigoogle-cloud-platformgoogle-api-php-clientgoogle-api-clientgoogle-translate

Does Google offer an API for their translate service?


A simple, normal API like: send a CURL to this endpoint with those parameters and that secret key, here's your response, have fun?

Something that does not require you to include their huge crazy cloud SDK that is dependent on tons of other third party libraries?


Solution

  • Google offers a Cloud Translation API to which you send simple CURL request with parameters and get back JSON response.

    Without Cloud SDK installed you can use curl command like this:

    curl -k "https://translation.googleapis.com/language/translate/v2?q=Hello+World&target=de&key=<API_Key>"
    

    Required parameters are:

    1. q: Text that you want to translate.
    2. target: Language in which you are translating. You have to insert a language code.
    3. key: A valid API key to handle requests for this API.

    You can also use Cloud Translation API Client Libraries with your language of choice.

    If having Cloud SDK installed is not an issue, you can follow a quickstart guide to get you started.