Skip to main content

API

API -Application Programming Interface

API stands for Application Programming Interface. An API is a software intermediary that allows two applications to talk to each other. In other words, an API is the messenger that delivers your request to the provider that you're requesting it from and then delivers the response back to you.

 

SOAP  - Simple Object Access Protocol – MicroSoft  - XMLHttpRequest

REST API  - Representational State Transfer – Supported by Google

XMLHttpRequest + JSON – Look Like a WEB URL

         

OPEN API

https://restcountries.eu/rest/v2/all

 

CORS API  - Cross Origin Resource Sharing

https://api.domainsdb.info/v1/domains/search?domain=facebook&zone=com

Will give you Cors Error .To avoid that we need to use proxyserver infront of the url

 

https://cors-anywhere.herokuapp.com/https://api.domainsdb.info/v1/domains/search?domain=facebook&zone=com'

 

AUTH API

We need to get the specific auth Key to access the API

http://api.openweathermap.org/data/2.5/weather?q=New%20Delhi&appid=4d28367ef9a7022ee96d046c2a1f2b5f

 

How to use API to get data

var req = new XMLHttpRequest();

req.open('GET',"https://api.covid19api.com/countries",true)

req.send()

req.onload = function(){

    var data =(JSON.parse(this.response))

    console.log(data)

}

 

Comments

Popular posts from this blog

  You are provided with the radius of a circle "A". Find the length of its circumference. Note: In case the output is coming in decimal, roundoff to 2nd decimal place. In case the input is a negative number, print "Error". function   coc () { var   r = document . getElementById ( "num1" ). value ; var   pi = 3.1415 ; var   Circumference =( 2 * pi * r ); if  ( r >= 0 ) console . log ( Circumference ); else console . log ( "Error" )} 
The area of an equilateral triangle is ¼(√3a 2 ) where "a" represents a side of the triangle. You are provided with the side "a". Find the area of the equilateral triangle. function   sqrt () { var   a = document . getElementById ( "a" ). value ; b =  Math . sqrt ( 3 ); c =( 1 / 4 )* b * a * a ; console . log (  "Area =" + c )}

HOISTING

  HOISTING Variables” and “ function” declarations are moved to the top of their scope before code execution. Variables are hosted and not their values Only the normal function will be hoisted not the anonymous,IIFE and Arrow Function will be hoisted Properties are not hoisted PROPERTY  Any variable declared globally  become property of window variable declared without keyword variable declared with keyword var except function scope var console . log ( a )   // Error a not defined console . log ( a );  // undefined --> var a is hoisted not value var   a  =  20 ; console . log ( a , b )  // Error --->property b can't hoist var   a  =  20 ; b  =  40 ; var   a  = add ( 2 , 5 )  // Error console . log ( a ) var   a  = add ( 2 , 5 )  // 7 function add hoist console . ...