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
Post a Comment