$get_api_url = "https://maps.googleapis.com/maps/api/place/details/json?key=$api_key&placeid=$place_id&language=$language_code";
//clean the URL
$result = file_get_contents($url);
The request above is made and received on the server side. I cannot seem to find the exact terminology used to describe the API key embedded URL.
When using JavaScript MAPs API,
let map;
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: { lat: -34.397, lng: 150.644 },
zoom: 8,
});
}
window.initMap = initMap;
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/jskey=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initMap&v=weekly" defer></script>
- Which part of the code qualifies as an API call in both the cases?
- How does the response received vary in case of the client side call?
- Is the URL used called an endpoint?
CodePudding user response:
Which part of the code qualifies as an API call in both the cases?
An API call is a call to a remote function. In simple word, an API call will always return you some sort of data (JSON, XML, Plain Text etc.)
<script src="https://maps.googleapis.com/maps/api/jskey=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initMap&v=weekly" defer></script>
This is not an API call neither and end point. Because you will notice that the URL returns Java Script. So its just an URL (location of a resource)
How does the response received vary in case of the client side call?
There is no difference if you call an API / End Point from client side or at server side. Because what you are doing is simply initiating an HTTP request and in turns it gives you back the HTTP Response.
Is the URL used called an endpoint?
This is an end point (to an API). You will notice that this returns some JSON data (Output of the function executed at that end point)
Hope this helps.
Note: Never expose sensitive data like API KEY and etc. with your question.