Google Translate API (paid) vs Google Translate API (free)?
Asked Answered
E

2

10

I need Translate API service for my app and have chosen Google Translate API, which will cost money and require authentication against the Google API. But during the search I've found this link which looks freely available and do what I need without cost:

https://translate.google.so/translate_a/t?client=any_client_id_works&sl=auto&tl=ru&q=wrapper&tbb=1&ie=UTF-8&oe=UTF-8

Try to issue a GET request and you'll see it by yourself.

So, my question is what is the difference between these above services and am I authorized to use the second one?

Empower answered 1/4, 2017 at 9:44 Comment(4)
It looks the link you provided is from Google Translate (a free multilingual machine translation service) [en.wikipedia.org/wiki/Google_Translate] instead of Cloud Translation API (provides a simple programmatic interface for translating an arbitrary string into any supported language using state-of-the-art Neural Machine Translation) [cloud.google.com/translate/]Deciliter
So actually these are two different services that you're comparing.Deciliter
What is so special in Google from Somalia?Decasyllabic
@Empower The above mentioned free API for translation is actually not free. It will result in 503 after some fast and repetitive usage.Appellative
S
5

Of course it is free and you can implement it (I included an example below). However, DO NOT USE IT because after a while Google can detect suspicious traffic –it happened to me, sadly- so you will receive an error message. I'm not sure how long can you use it until they can detect your activity so my advice for you is to test extensively your app with the "free service" and if you see some troubles perhaps you should buy the service or look for another API. https://api.mymemory.translated.net is a free but limited alternative.

In iOS Swift 4 you can implement the free service by using the following function:

func translate(str: String, lang1: String, lang2: String) {

    let escapedStr = str.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)
    let lastPart = lang1 + "&tl=" + lang2 + "&dt=t&dt=t&q=" + escapedStr!
    let urlStr: String = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" + lastPart
    let url = URL(string: urlStr)

    let task = URLSession.shared.downloadTask(with: url!) { localURL, urlResponse, error in
        if let localURL = localURL {
            if let string = try? String(contentsOf: localURL) {
                let index = string.firstIndex(of: "\"")
                let index2 = string.index(after: index!)
                let subst = string.substring(from: index2)
                let indexf = subst.firstIndex(of: "\"")
                let result = subst.substring(to: indexf!)
                DispatchQueue.main.async {
                    if flag1country != flag2country {
                        self.texto.text = result
                    }
                }
            }
        }
    }
    task.resume()
}

(Perhaps this is not the best implementation, but it works).

Sidesaddle answered 29/12, 2018 at 5:10 Comment(2)
It was implemented in an iOS app. I was testing the app without my computer, so I'm not sure. However, my application made too many requests in a short period of time, more or less 7 requests/second. In about five minutes the application was gone. Nevertheless, I will continue testing and after that I'll inform my findings. The error message –quite long– basically said that I did several requests in a short period. However, it seems that Google do not allow that kind of usage for the service, according with their terms of usage.Sidesaddle
Seems that you can avoid the detection by using the API slowly, but not sure that it's legal that way.Sidesaddle
D
1

It looks the link you provided is from Google Translate (not an API but a free multilingual machine translation service) instead of Cloud Translation API, which provides a simple programmatic interface for translating an arbitrary string into any supported language using state-of-the-art Neural Machine Translation; so they are not the way you think.

Deciliter answered 21/4, 2017 at 19:54 Comment(3)
Thank you for your response? But can I use this free service and where can I read a little more about it?Empower
I just seen that some Chrome extensions which available in Chrome app store use this service.Empower
Hi, you can read more details regarding Google Translate at en.wikipedia.org/wiki/Google_Translate and support.google.com/translate/?hl=en#topic=7011755; you can definitely use this free service.Deciliter

© 2022 - 2024 — McMap. All rights reserved.