4.5.1.Simple APIs - sj50179/IBM-Data-Science-Professional-Certificate GitHub Wiki
REST APIs
REpresentational State Transfer APIs
- REST APIs are used to interact with web services, i.e., Applications that you call through the internet.
- They have a set of Rules regarding:
- Communication
- Input or Request
- Output or Response
PyCoinGecko for CoinGecko API:
Python Client by Christoforou Emmanouil
Watson Text to Speech API
from ibm_watson import LanguageTranslatorV3
url_It = 'https://gateway.watsonplatform.net/language-translator/api'
aplikey_It = 'dU2SaxxxxxxxxxxxxxxxasdfCuasdf'
verson_It = '2018-05-01'
language_translator = LanguageTranslatorV3(iam_aplikey=apikey_It,
url=url_It, version=version_It)
language_translator.list_identifiable_languages().get_result()
...{'language':'en', 'name':'English'},...,{'language':'es', 'name':'Spanish'}
recognized_text = 'hello this is python'
translation_response = language_translator.translate(text=recognized_text,
model_id='en-es')
translation = translation_response.get_result()
translation
{'translation':[{'translation':'Hola, esta es la pitón.'}],
'word_count':4, 'character_count':21}
spanish_translation = translation['translations'][0]['translation']
spanish_translation
'Hola, esta es la pitón.'
translation_new = language_translator.translate(text=spanish_translation,
model_id='es-en').get_result()
translation_eng = translation_new['translations'][0]['translation']
translation_eng
'Hey, this is the python.'
French_translation = language_translator.translate(text=translation_eng,
model_id='en-fr').get_result()
French_translation['translations'][0]['translation']
"Hé, c'est le python."