Using your first API

Cloud Computing - Data Science
API

Last day we learnt what is API and why we need API as a developer. And Today we will learn and use our first API in our script. Like we said we will send the request to the server in a predefined format and the server will return the information we want.

Using API

Currency API:

For the fist call we choose an API which do not need any credential to use it. This gives us the foreign exchange reference rates both current and historical data. It was published by European Central Bank. And you can learn all the requests from this API website.

For this post we will use Request library on Python to get the data from the server.

libraries
Importing libraries
API website
The request URL from the website

At first we import the libraries and check out the request format from the website.

Then we will send the request. using the get function and the predefined URL to get the data which we will parse and print.

From the printed result we can see the result is in Json format, which most of the API responses are. And the base currency is Euro. And also the data is latest, which we know from the date.

Let us find out the exchange rate of EUR to USD.

Currency Data
Data printed in the format we wanted. Like this we extract all the data from the json.

Now let us look for ways to customize our request and extract different data.

From the API website we see we can extract historical currency data by swapping the ‘latest’ with a date and we can change the base currency adding it to the URL with ‘?base=’ at the end.
like we will use the URL

https://api.exchangeratesapi.io/2015-09-28?base=USD

getting historical data
changing base currency

From the result we can see the base currency is changed to USD and the date is changed to September 28th, 2015.

Final result
Customizing the requests and print the response

You can use this API to do a lot of projects. Like you get your script hosted on cloud which sends you currency change analysis on schedule like in a certain time everyday.

9 thoughts on “Using your first API”

  1. This fnb.xwrj.datalators.com.rey.lo isn’t blood-borne vastus [URL=http://bodywit.com/buy-viagra-online/ – best website use generic viagra[/URL – [URL=http://columbiainnastoria.com/cialis-price/ – cialis generic[/URL – [URL=http://buynewaustin.com/achat-kamagra-en-france/ – kamagra mit alkohol[/URL – [URL=http://redlightcameraticket.net/toradol-injection/ – buy toradol injection online[/URL – [URL=http://sci-ed.org/viagra-buy-in-canada/ – can caverject be used with viagra[/URL – [URL=http://handleyumc.org/online-viagra/ – viagra in india[/URL – [URL=http://anguillacayseniorliving.com/levitra-generic/ – levitra experiences old[/URL – [URL=http://ecareagora.com/pharmacy/ – pharmacy[/URL – [URL=http://mannycartoon.com/cialis-professional/ – cialis professional 20 mg[/URL – [URL=http://damcf.org/item/ascorbic-acid/ – ascorbic acid price[/URL – [URL=http://ecareagora.com/propecia-generic/ – propecia generic[/URL – [URL=http://thepaleomodel.com/levitra-genericos/ – generic levitra shipping[/URL – faculties modulated buy viagra online cialis.com generic cialis 20mg viagra on line toradol injection on internet cheap viagra online online viagra levitra generic pharmacy prices for levitra pharmacy cialis professional capsules for sale cheap ascorbic acid where to buy propecia online levitra existence, http://bodywit.com/buy-viagra-online/ uk viagra no prescription http://columbiainnastoria.com/cialis-price/ cialis http://buynewaustin.com/achat-kamagra-en-france/ kamagra phone in orders http://redlightcameraticket.net/toradol-injection/ canadian toradol injection toradol injection on internet http://sci-ed.org/viagra-buy-in-canada/ acheter du viagra viagra http://handleyumc.org/online-viagra/ viagra http://anguillacayseniorliving.com/levitra-generic/ levitra 20 mg online http://ecareagora.com/pharmacy/ pharmacy prices for levitra http://mannycartoon.com/cialis-professional/ cialis professional 20 mg http://damcf.org/item/ascorbic-acid/ ascorbic acid best price http://ecareagora.com/propecia-generic/ propecia without prescription buy propecia without prescription http://thepaleomodel.com/levitra-genericos/ levitra online pharmacy 7c levitra genericos documented therapists deposit monocytes.

  2. Definitely believe that which you stated. Your favorite justification seemed to be on the
    internet the simplest thing to be aware of. I say to you, I definitely get annoyed while people consider worries that they
    plainly do not know about. You managed to hit the nail upon the top as
    well as defined out the whole thing without having side-effects , people can take a
    signal. Will likely be back to get more. Thanks

  3. It’s perfect time to make some plans for the future and it
    is time to be happy. I’ve read this post and if I could I desire to suggest you few interesting things or suggestions.
    Maybe you could write next articles referring to this article.
    I want to read more things about it!

Leave a Comment

Your email address will not be published.