pythonjsonapiunirestyandex

Python Yandex translate example


so for example I am trying to use unirest for this so i put

base = 'translate.yandex.net'
post = '/api/v1.5/tr./getLangs?ui=en&key=' + api_key
request = unirest.get(base+post, headers={'accept' : "json"})

and the code says something about not a valid url this is directly from the docs.

What I am asking for is a working example on how to get this api to work with the unirest module. If not possible how would I use with another package.

This may be a stupid question but maybe I just don't comprehend the docs from Yandex.

update a link to the docs is here. https://tech.yandex.com/translate/doc/dg/reference/translate-docpage/


Solution

  • Try adding http:// or https:// in the base url:

    base = 'http://translate.yandex.net'
    post = '/api/v1.5/tr.json/getLangs?ui=en&key=' + api_key
    request = unirest.get(base+post, headers={'accept' : "json"})
    

    and it should be fine.

    This is based on yandex documentation.