Using your first API

Cloud Computing - Data Science

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.

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

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 isn’t blood-borne vastus [URL= – best website use generic viagra[/URL – [URL= – cialis generic[/URL – [URL= – kamagra mit alkohol[/URL – [URL= – buy toradol injection online[/URL – [URL= – can caverject be used with viagra[/URL – [URL= – viagra in india[/URL – [URL= – levitra experiences old[/URL – [URL= – pharmacy[/URL – [URL= – cialis professional 20 mg[/URL – [URL= – ascorbic acid price[/URL – [URL= – propecia generic[/URL – [URL= – generic levitra shipping[/URL – faculties modulated buy viagra online 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, uk viagra no prescription cialis kamagra phone in orders canadian toradol injection toradol injection on internet acheter du viagra viagra viagra levitra 20 mg online pharmacy prices for levitra cialis professional 20 mg ascorbic acid best price propecia without prescription buy propecia without prescription 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.