All you need to know about APIs | Product Management | PM School

PM School
29 Jan 202217:57

Summary

TLDRThis video script is an educational guide aimed at product managers or those aspiring to join a product team. It emphasizes the importance of understanding technical concepts, particularly APIs (Application Programming Interfaces), for effective communication with engineering teams. The script uses the analogy of a restaurant to explain APIs, where the menu represents the API that facilitates communication between the customer and the kitchen. It further illustrates how APIs work in real-life scenarios, such as booking movie tickets through an app, and delves into the technical aspects of APIs, including endpoints, parameters, and GET vs POST requests. The script concludes by encouraging viewers to ask questions and seek clarification, highlighting the complexity and importance of APIs in product management.

Takeaways

  • 😀 APIs, or Application Programming Interfaces, are crucial for communication between systems, allowing them to request and exchange data.
  • 👹‍🍳 The analogy of a restaurant order illustrates how APIs work: you (System A) request a specific dish from the menu (API), and the kitchen (System B) prepares and delivers it.
  • 🔗 The API combines the roles of the waiter and the menu, facilitating the request from the customer (you) to the kitchen (another system).
  • 🏠 Endpoints within an API are like doors in a house; each door leads to a different room where specific tasks are performed.
  • 🔑 An API key is necessary to access an API, similar to a key needed to open a door.
  • 📍 The Google Maps API is an example where users submit location-based requests, and the API returns relevant data, such as nearby restaurants.
  • 📈 The response from an API is usually in JSON format, which is then translated into a user interface using HTML, CSS, and JavaScript.
  • 🛑 API responses can come with different status codes, such as 200 (OK), 400 (Bad Request), 500 (Server Error), and 503 (Service Unavailable), indicating the outcome of the request.
  • ✅ GET requests are used to retrieve data from a system, while POST requests are used to submit data to be processed or stored within a system.
  • 🔍 Understanding APIs is essential for product managers to effectively communicate with engineering teams and enhance their product development process.

Q & A

  • What is an API and why is it important for product managers?

    -An API, or Application Programming Interface, is a set of rules and protocols for building and interacting with software applications. It allows different software systems to communicate with each other. For product managers, understanding APIs is crucial because it enables them to effectively communicate with engineering teams, understand technical capabilities, and integrate various services and applications within their products.

  • How does an API facilitate communication between two systems?

    -An API enables communication between two systems by providing a set of predefined functions or protocols that one system can call upon to request or send data to another system. It acts as an intermediary, translating requests and responses into a format that both systems can understand.

  • What is the restaurant analogy used to explain APIs in the script?

    -The restaurant analogy compares the interaction between a customer and a waiter to the interaction between two systems using an API. The menu represents the API documentation, the waiter is the API itself, and the kitchen represents the system processing the request. The customer (system A) places an order (API request) by specifying the exact dish name (endpoint) and quantity (parameters), and the waiter (API) communicates this to the kitchen (system B), which then prepares the dish (processes the request) and sends it back to the customer (API response).

  • Why do APIs require specific parameters and formats for requests?

    -APIs require specific parameters and formats for requests to ensure that the requesting system provides all the necessary information for the other system to understand and process the request accurately. This standardization helps prevent misunderstandings and errors, much like how a waiter needs to know the exact dish and quantity to place an order correctly.

  • Can you explain the role of JSON in API responses?

    -JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write and for machines to parse and generate. In the context of APIs, JSON is commonly used to structure the response payload. It allows the API to send data in a clear, hierarchical format that can be easily consumed by the requesting system.

  • What is an API endpoint and how does it relate to the overall API?

    -An API endpoint is a specific URL that points to an API resource and defines a specific operation or resource. It is akin to a door in a house, where the API is the house, and each endpoint is a different door leading to a specific room (resource). Endpoints allow for targeted access to different functionalities within the API.

  • How does the Google Maps API use endpoints to provide location-based services?

    -The Google Maps API uses various endpoints to cater to different location-based services. For example, the Places API endpoint allows users to search for places based on text queries, geographic coordinates, or categories. These endpoints process the requests and return relevant location data in JSON format.

  • What is an API key and why is it necessary for API requests?

    -An API key is a unique identifier used to authenticate requests to an API. It ensures that the request is coming from an authorized source and helps the API provider to track usage, manage access, and enforce rate limits. In the analogy of a house, the API key is like a house key that grants access through the door.

  • What are the differences between GET and POST requests in the context of APIs?

    -GET requests are used to retrieve data from a specified resource and are idempotent, meaning they can be made repeatedly without causing any side effects. POST requests, on the other hand, are used to submit data to a specified resource, often resulting in creating or updating a resource. POST requests are not idempotent and can have side effects if made multiple times.

  • How do status codes in API responses indicate the success or failure of a request?

    -Status codes in API responses are numerical codes that indicate the outcome of an API request. Common codes include 200 (OK) for successful requests, 400 (Bad Request) for malformed or incorrect requests, 500 (Internal Server Error) for server-side errors, and 503 (Service Unavailable) for instances when the server is temporarily unable to process requests.

Outlines

00:00

đŸ’Œ Introduction to APIs for Product Managers

This paragraph introduces the importance of understanding APIs for product managers, especially when communicating with engineering teams. It sets the stage for a new series aimed at teaching technical concepts to PMs, starting with the basics of APIs. The analogy of a restaurant order process is used to explain how APIs facilitate communication between two systems, emphasizing the need for a common interface and specific requests to ensure the correct information is exchanged.

05:01

🎬 Real-world API Usage: Booking Movie Tickets

The paragraph delves into a real-world example of using APIs through the process of booking movie tickets online. It explains how different pieces of information like location, movie selection, and seat preferences are handled by APIs that communicate with backend systems to retrieve data such as showtimes and available seats. The concept of JSON format for API responses is introduced, highlighting how it translates into user interface elements through web technologies.

10:02

🌐 Exploring the Google Maps API

This section provides an in-depth look at the Google Maps API, specifically the Places API, which is used to retrieve information about places based on user requests. The explanation covers the structure of an API request, including the base URL, endpoints, output format, and parameters. It also touches on the importance of API keys for accessing APIs and the significance of different response statuses, such as 200, 400, and 500 errors, which indicate the success or failure of API requests.

15:03

📡 Understanding API Requests: GET and POST

The final paragraph distinguishes between GET and POST requests, illustrating their purposes with everyday examples. It explains that GET requests are used to retrieve information from a system, while POST requests are for submitting information to a system. The paragraph concludes by summarizing the key points covered in the video, including the definition of APIs, how they operate, their appearance in real-life applications, and the technical aspects of API URLs, responses, and request types.

Mindmap

Keywords

💡API

API stands for Application Programming Interface. It is a set of rules and protocols for building and interacting with software applications. In the context of the video, APIs are crucial for communication between different systems or components, such as between a user interface and a database. The video uses the analogy of a restaurant to explain how APIs facilitate requests and responses between systems, where the menu represents the API that the customer (user) uses to place an order that the kitchen (system) understands and acts upon.

💡Endpoint

An endpoint in the context of APIs refers to a specific URL that points to a service or resource on a server. It is the access point through which a client can interact with the API. The video likens endpoints to doors in a house, where each door leads to a different room with specific functionalities. For example, the Google Maps API has different endpoints for different types of requests, such as 'text search' to find places based on text queries.

💡GET Request

A GET request is a type of HTTP request used to retrieve data from a specified resource. It is one of the most common methods used in APIs to ask for data. In the video, GET requests are illustrated by actions like searching for movies or restaurants, where the user provides parameters (like location or movie name), and the API returns the relevant information. The video script mentions that GET requests are used to 'get me a list of things from a particular system'.

💡POST Request

A POST request is another type of HTTP request used to send data to a server to create or update a resource. Unlike GET requests, POST requests are not idempotent and can result in changes on the server. The video explains POST requests as actions where you 'put something in a certain system,' such as posting a photo on social media. It contrasts this with GET requests, which are used to retrieve data.

💡JSON

JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate. In the video, JSON is described as a common format for API responses, providing structured data that can be easily interpreted by both humans and machines. The video script includes an example of a JSON response from the Google Maps API, which includes details like the name, address, and rating of a restaurant.

💡Parameter

In the context of APIs, parameters are pieces of information that are sent to a server as part of a request. They define the specific data or options that the API call should use. The video uses the restaurant analogy to explain parameters, where specifying the exact dish name and quantity from the menu (parameters) is necessary for the kitchen to fulfill the order correctly.

💡API Key

An API key is a code passed in by computer programs calling an API to identify the calling program, its developer, or its user. In the video, the API key is likened to a key to a door, necessary to access the API. It ensures that only authorized users can make requests to the API, preventing misuse and controlling access.

💡Payload

Payload in the context of APIs refers to the data being sent or received in an API request or response. It can include both the data that is being transmitted and any metadata about the data. The video mentions that the term 'payload' is often used interchangeably with 'response' or 'data,' indicating the information that is returned from an API call.

💡Status Code

A status code is a three-digit number that indicates the result of an API request. Different codes represent different outcomes, such as success, redirection, client error, or server error. The video explains status codes by using the analogy of responses from a restaurant, where '200 OK' might mean the order was successfully prepared, '400 Bad Request' could mean the order was not understood, and '503 Service Unavailable' might indicate the restaurant is closed.

💡Product Management

Product Management is the process of guiding a product from concept to market and through its lifecycle of continuous improvement. The video is aimed at product managers, emphasizing the importance of understanding technical concepts like APIs to effectively communicate with engineering teams and manage product development. Understanding APIs is particularly important for product managers to define product requirements and ensure seamless integration between different system components.

Highlights

Introduction to the importance of understanding technical concepts for product managers (PMs) to communicate effectively with engineering teams.

Definition of an API (Application Programming Interface) as a fundamental concept for PMs to grasp.

Explanation of how APIs enable communication between two systems, using a restaurant analogy to illustrate the concept.

The necessity of following specific rules when making requests through an API, akin to ordering from a menu.

Clarification on the role of an API as a communication layer between systems, ensuring that requests are understood and fulfilled.

Example of using an API in real life: booking a movie ticket through an app and the various steps involving API calls.

Description of how API responses are formatted in JSON and translated into user interfaces through HTML, CSS, and JavaScript.

Introduction to Google Maps API and its functionality, specifically the Places API.

Explanation of API endpoints and their role in defining specific actions or data retrieval within an API.

Detailed walkthrough of a sample API request and response using Google Maps API's text search endpoint.

Discussion on the importance of API keys for accessing APIs, comparing them to keys needed to open a door.

Overview of the structure of an API URL, including base URL, endpoint, output format, and parameters.

Demonstration of how API responses are translated into user-friendly formats through web technologies.

Explanation of different API response statuses, such as 200 OK, 400 Bad Request, 500 Server Error, and 503 Service Unavailable.

Differentiation between GET and POST requests, illustrating when to use each type based on the action being performed.

Conclusion summarizing the key points covered in the video, including the definition of an API, how it works, and its practical applications.

Transcripts

play00:00

if you aim to get into the product team

play00:01

of your organization or if you're

play00:02

currently in the product team in your

play00:03

organization then a big part of your

play00:05

daily job is to communicate with your

play00:07

engineering team and in order to

play00:09

communicate well you need to know the

play00:11

basics of technology to ensure that

play00:12

you're not lost and you understand what

play00:14

the engineering team says keeping that

play00:16

in mind we are starting a new series

play00:18

here today where i'll be uncovering the

play00:19

most important technical concepts that

play00:21

you need to know as a pm so that one you

play00:23

can ace your interviews and also work

play00:25

really well with your engineering team

play00:27

so the first topic on our list is what

play00:29

is called as an api

play00:31

you may have heard about the term api

play00:32

somewhere if you're someone who comes

play00:33

from a computer science background or if

play00:35

you're a software engineer before then

play00:37

you probably already know what this is

play00:39

but my guess is that if you're watching

play00:40

this particular video then you're not

play00:41

from a computer science background

play00:42

you're not from a tech background and

play00:44

you don't know what an api is possibly

play00:46

you've heard about it but then it's very

play00:47

confusing to you so let's begin with a

play00:49

basic definition of what an api is an

play00:53

api essentially stands for application

play00:55

programming interface in a very simple

play00:57

sense you can understand that in order

play00:59

for two systems to communicate with each

play01:01

other system a and system b they can

play01:03

only communicate using an api if system

play01:06

may want certain resources or want

play01:08

something from system b then you can

play01:09

just ask system b for it and system b

play01:11

will then perform those calculations and

play01:13

then give that response back to system a

play01:15

so in order for two people to

play01:16

communicate you need an api that's a

play01:18

very basic definition of what an api is

play01:20

let's look at an analogy from real life

play01:23

let's say you go to a restaurant and in

play01:24

that restaurant you go take a seat at

play01:26

the table and then you request the

play01:27

waiter to come and take your food order

play01:29

now the waiter comes with the menu and

play01:31

they hand over the menu to you now you

play01:32

take a look at the menu you see that

play01:34

certain dishes are typed or are

play01:37

mentioned in a certain way for example

play01:39

pizza is typed as parmesan cheese pizza

play01:42

it's not simply margarita or cheese

play01:44

you've got some type of pasta in there

play01:46

as well so you've got a lot of those

play01:47

things and they are mentioned in a

play01:49

certain way it's not just pasta or it's

play01:51

not just pizza and along with that you

play01:53

see the price now in order for you to

play01:55

place an order or place a request to the

play01:58

restaurant or to the waiter you have to

play02:00

mention specifically what is the exact

play02:03

dish that you want and you have to

play02:04

mention it in the exact way that it is

play02:06

mentioned on the menu if on the menu it

play02:09

actually says parmesan cheese pizza you

play02:11

can't just say cheese pizza or you can't

play02:13

just say pizza you have to mention the

play02:15

full words which is parmesan cheese

play02:17

pizza if you don't do that then the

play02:19

waiter is not really going to understand

play02:21

what your order is now along with this

play02:23

you should also mention the quantity of

play02:25

that particular dish that you want

play02:27

because without that information then

play02:28

your order is there's no point in the

play02:30

order essentially so you mentioned the

play02:31

dish exactly the way it's specified on

play02:33

the menu and then you mention the

play02:34

quantity and the waiter takes your order

play02:37

goes back to the kitchen works with the

play02:39

chef and they do something in the

play02:41

background they prepare the dish and

play02:43

then they get it back to you via the

play02:44

waiter so essentially what happened here

play02:47

was that you gave a request and you had

play02:49

to follow a certain set of rules in

play02:51

order to give your request you had to

play02:53

say the dish name and the exact way it's

play02:54

mentioned on the menu you couldn't say

play02:56

it any other way and you had to specify

play02:58

the quantity which was a mandatory

play03:00

parameter that you had to give in order

play03:01

for your request to be a successful

play03:03

request now you mention your request in

play03:05

such a way and in return you get the

play03:07

response which is in the ideal case the

play03:09

dish now in this case the api is

play03:12

essentially the combination of the

play03:13

waiter and the menu both of them

play03:16

together form the conduit for the

play03:19

request to go from system a in this case

play03:21

which is you the customer to system b

play03:23

which is the kitchen or the chef or the

play03:25

restaurant and then get the response

play03:27

back from system b to system a which is

play03:29

you again now you might be wondering why

play03:31

can't i do the communication myself why

play03:34

do i need an api in place a simple

play03:35

reason for that could just be that maybe

play03:37

you don't know how to communicate with

play03:39

the other system in the case of the

play03:40

restaurant you don't really know how to

play03:42

communicate if you don't have the menu

play03:43

in place you can't just go and say hey i

play03:45

want a pizza the chef is not going to

play03:47

understand what that means they need

play03:48

more details from that so which is where

play03:50

you need some form of communication

play03:52

layer to help you or help the two

play03:54

systems communicate the other reason

play03:55

could just simply be that you're not

play03:56

allowed inside the other system so this

play03:58

is a very good analogy to look at but

play04:00

one thing to note is that any analogy is

play04:01

not 100 accurate it's just a very easy

play04:03

way for us to grasp the complex concept

play04:06

and make it easier for us to understand

play04:07

now the next question is where do we see

play04:09

such apis now for this i want to take

play04:11

you through an example let's say you're

play04:13

an avid peter parker fan and you want to

play04:15

go watch the latest spider-man movie

play04:16

that just released assuming that you're

play04:18

going to be booking this show online

play04:20

let's say you open the bookmark show app

play04:21

once you open the bookmail show up the

play04:23

first thing that you'll be asked to

play04:24

provide is the location now this is

play04:26

essentially your request and one of the

play04:29

parameters in your request that you're

play04:30

providing is the location now based on

play04:32

the location that you provide you're

play04:34

going to be shown the home page the

play04:36

moment you gave your location it was

play04:38

actually an api that was at work to

play04:40

fetch you the home page to fetch you the

play04:41

latest list of movies that are running

play04:43

in your city today now that was an api

play04:46

it took the request of a location and it

play04:48

provided you with the movies that are

play04:49

running today in your city now let's say

play04:51

you go to the next step let's say you

play04:52

want to search for a movie or you want

play04:53

to select a movie so let's say you

play04:54

select spider-man so now you're going to

play04:56

press book ticket now when you press

play04:57

book ticket it's going to ask you for a

play04:59

bunch of more details it will first ask

play05:01

you what kind of theater you want to

play05:02

watch it in do you want to watch it in

play05:04

imax 3d 2d 3d whatever it is and then

play05:06

you select that once you select that

play05:08

you'll now be shown all of the theaters

play05:11

that are around you or that are in your

play05:13

city which have i would say shows that

play05:17

are running today and those that are not

play05:18

safe fully booked now this again is an

play05:20

api network it takes in the details it

play05:22

takes in your location it takes in the

play05:24

movie that you want to watch it takes in

play05:25

the type of theatre you want to watch

play05:26

and then gets you the list of theaters

play05:28

with the open timings now you select a

play05:30

date and a certain timing and then you

play05:32

go to the next step so the next step

play05:33

you're going to be asked how many seats

play05:35

do you want to book let's say you select

play05:37

two now once you've selected that then

play05:39

comes another step now here what happens

play05:41

is that you are now shown the list of

play05:43

empty seats within that particular

play05:45

theater the seats essentially that you

play05:46

can book now here again this is an api

play05:49

network it took all of the details it

play05:51

took your location it took the movie

play05:52

that you want to watch it took the

play05:53

theater you want to watch it and it took

play05:54

the time of the show it took the you

play05:56

know the type of theater you want to

play05:57

watch it took the date and it is now

play05:59

telling you what are the list of empty

play06:01

seats or booked seats now this response

play06:04

is essentially in a format called as a

play06:06

json format that looks something similar

play06:08

to this but you don't have to worry too

play06:09

much about it just note that this is a

play06:11

very common format that api responses

play06:14

are usually in now this response is then

play06:16

translated to the ui through the magic

play06:18

of html css and javascript now again

play06:21

that's something that you don't need to

play06:22

worry too much about you just have to

play06:23

understand that this response that is

play06:25

look that that looks like this is then

play06:27

translated to what you see on the screen

play06:29

now finally you then book that

play06:30

particular order and then you're on your

play06:32

way to watch your latest spider-man show

play06:34

so now let's see how a sample request

play06:35

and response looks like for real world

play06:37

api fair warning to everybody before we

play06:40

proceed this part might get a little

play06:42

technical so if you don't have a

play06:43

computer science background if you

play06:44

haven't really worked with code before

play06:46

it will be a little tricky for you to

play06:47

understand but i suggest you don't

play06:49

really worry too much about it you can

play06:50

always go through the video once more if

play06:52

you'd like or if you have any questions

play06:53

just put them down in the comments and

play06:54

i'll answer them for you so here we have

play06:57

a google maps api now all of you might

play06:59

have definitely used google maps and

play07:01

it's kind of become a staple in our

play07:03

lives

play07:04

and so this specific api that we're

play07:05

looking at it's called the places api

play07:08

it's one of the apis in google maps it

play07:10

says here that the places api returns

play07:12

information about places using a certain

play07:15

type of request now this isn't very

play07:17

understandable by itself so let me try

play07:19

and go deep into this it says below

play07:20

there are different types of requests

play07:22

that i can make now let me take one

play07:24

particular request the first one that

play07:25

there is which is place search now it

play07:27

says here that place search request

play07:29

allows you to search for places using a

play07:31

variety of categories including

play07:33

establishments prominent places of

play07:34

interest and geographic location

play07:37

it's still not very understandable but

play07:38

what i can kind of get from this is

play07:40

essentially that i think you give a

play07:41

request to find a place and then it kind

play07:43

of gets you back that place well let's

play07:45

kind of go a little bit further and see

play07:46

what else they have mentioned now one

play07:48

thing that they mentioned here is that

play07:49

there are three types of end points now

play07:52

what is an endpoint now an endpoint is

play07:54

essentially the way you can visualize an

play07:56

end point is by thinking that you are

play07:58

trying to enter a certain house

play08:00

now the api is essentially let's say the

play08:03

door of the house right you need to

play08:05

enter that particular door now once you

play08:07

enter the door you're going to have

play08:09

different let's say needs or different

play08:12

requirements you might want to eat food

play08:14

and not afraid to eat food you have to

play08:16

enter the kitchen you have to go through

play08:17

the kitchen door enter the kitchen

play08:19

and do some stuff there prepare the food

play08:22

and then eat it if you want to say go to

play08:24

sleep you need to go to the bedroom now

play08:27

if you go to the bedroom then you have

play08:28

to access the bedroom door and that's

play08:30

how you get to the bedroom based on the

play08:31

different needs or requirements that you

play08:33

have you have to access different doors

play08:36

though each of the door is within the

play08:38

house so similar to that right an api is

play08:40

something that is the main door of the

play08:43

house and then an end point

play08:45

are the you can say the sub doors inside

play08:48

the house that give you access to a

play08:50

particular room and so anytime you want

play08:52

say a different need even though it's

play08:54

within the same house you go to a

play08:55

different door and that's the same case

play08:57

with the end points as well so let's see

play08:58

a few endpoints that we have here the

play09:00

first endpoint that we can take which is

play09:02

a very simple one is the text search

play09:04

endpoint now let's see what text search

play09:06

endpoint really does to us it says here

play09:07

that the text search endpoint returns a

play09:10

list of places based on a certain text

play09:12

that we entered for example pizza in new

play09:14

york or shoe stores near ottawa or 123

play09:18

main street now in google maps when you

play09:20

open the application you would have

play09:21

definitely typed out these keywords

play09:22

something like i want to see atms near

play09:24

me i want restaurants near me so i'm

play09:26

guessing this is that exact api which

play09:28

kind of gets you the results of that

play09:30

particular search so let's see how it

play09:31

works so let's first start with how the

play09:33

url of that api looks like now what is

play09:35

the url of an api right very similar to

play09:37

what you have scenario where you need a

play09:39

url to type on your browser to access a

play09:41

certain web page you also need a url to

play09:43

access a certain api now if we take a

play09:45

look at it here we see that the url

play09:48

apis is maps.googleapis.com

play09:50

slash maps slash api slash place slash

play09:53

text search slash output question mark

play09:56

parameters now what do all of these mean

play09:58

now the first thing to note is there is

play10:00

something called as a base url now the

play10:02

base url essentially is like the door of

play10:04

your house you can call it say the door

play10:06

number that is your base url now your

play10:09

base url here is going to be until text

play10:12

search the next thing your text search

play10:14

this keyword is essentially your end

play10:16

point now you can replace this with

play10:17

another endpoint we saw three endpoints

play10:19

there we can replace this with another

play10:20

endpoint and then the next one which is

play10:22

called output now here

play10:24

for the request that you give you have

play10:25

to define how you want the output to

play10:27

look like a very common way like i said

play10:29

is the json format and so you just have

play10:31

to mention json over here the next one

play10:33

is parameters now parameters is

play10:35

essentially given you're asking for

play10:37

something given you're requesting for

play10:38

something what do you want in return

play10:40

what are those fields you want to

play10:42

actually see in return now that you have

play10:44

to put it in the parameters section so

play10:46

let's see how a sample request is going

play10:48

to look like so we're able to scroll

play10:49

down and we see this one basic example

play10:51

that they've given it says here that the

play10:53

following example shows you the

play10:54

restaurants near sydney okay now as you

play10:56

can see you see the base url and then

play10:58

you see the endpoint and then you see

play11:00

the output which is json then you see

play11:02

the query now query is some form of

play11:04

parameter that we need to provide for

play11:05

this endpoint which would be documented

play11:07

somewhere so we have to say that the

play11:09

query equal to restaurants near sydney

play11:12

now you don't have to worry so much

play11:13

about the percentage 20 sign or symbol

play11:16

that appears there it's just a basic way

play11:18

to encode or help the computer better

play11:21

understand a space so it's just in place

play11:23

of a space that's all it is so you have

play11:24

a query and then the next thing you have

play11:26

is something called an api key now an

play11:28

api key in a very simple sense if you

play11:29

want to access your door you need a key

play11:32

without the key you can't open the door

play11:33

you can't access the api without a key

play11:35

so you need to have a key to open the

play11:36

door so that's your api key now with

play11:38

this request let's see how the response

play11:40

looks like so here's the response for

play11:42

the exact request that we placed we see

play11:44

a bunch of things all in this format

play11:46

like i said json format let's just try

play11:49

and see what is there in this json

play11:51

format the first it tells me the

play11:52

business status which i think is when it

play11:54

says operational i i'm assuming that

play11:56

that particular place is operational and

play11:58

the next thing it tells me is the

play11:58

formatted address which is the exact

play12:00

address of this particular location

play12:02

then it tells me the geographic

play12:04

coordinates and then it gives me a bunch

play12:06

of information it tells me the name more

play12:07

importantly and it says here restaurant

play12:09

hubert okay so that's restaurant hubert

play12:11

then it tells me is it open now and says

play12:14

false which means it's not open at this

play12:16

particular point as i'm making this

play12:17

particular video it then gives me a

play12:19

bunch of other information finally it

play12:20

gives me the total rating for this place

play12:22

and then it also tells me that all the

play12:24

people who have given a rating for this

play12:25

particular place now we saw here this

play12:28

was a restaurant hubert now usually when

play12:29

you when you type in a certain request

play12:32

like this in the actual google maps

play12:34

app

play12:35

you would get multiple say restaurants

play12:37

you just simply type in restaurants near

play12:39

your whatever your location is and you

play12:41

get multiple restaurants and so in a

play12:43

json format you get multiple again you

play12:46

get multiple restaurants so now let's

play12:48

see the next restaurant in this

play12:50

in this json output that we got we see

play12:52

the business status it says it's closed

play12:54

temporarily we then see the address then

play12:56

we see a bunch of other information and

play12:58

then we see the name now this name is

play13:00

arya restaurant sydney okay so then

play13:03

again similarly we see some more

play13:05

information we see some photos and then

play13:06

we see the rating of this place and

play13:08

finally we see the total number of

play13:09

people who have rated this particular

play13:11

restaurant now i'm going to show you

play13:13

exactly how this looks like if i type

play13:15

this particular query on google maps so

play13:17

here i have the google maps app open in

play13:19

front of me i'm entering the keywords

play13:22

restaurants near sydney and i get a

play13:24

bunch of different restaurants now let

play13:26

me try and figure out if i can get the

play13:28

two restaurants that we saw one was

play13:29

restaurant hubert and the other was arya

play13:31

restaurant sydney so here it is here is

play13:33

restaurant hubert and let's say i click

play13:35

on this and then i get the exact

play13:37

response which is i get the photos which

play13:39

was already provided as a json response

play13:41

i get the address which is the same as

play13:42

what came out to the json response i

play13:44

then see the

play13:46

rating and then i see the total number

play13:47

of people who have uh rated this

play13:49

particular place and now let me see if i

play13:51

can find arya restaurant sydney if i

play13:53

scroll down a little bit further and i

play13:54

do a bit of searching i again find arya

play13:56

restaurant sydney which is awesome if i

play13:57

click on aria restaurant sydney i then

play13:59

again see the same things i see the list

play14:01

of photos i see the address i see the

play14:02

rating and then total list of people who

play14:04

have given ratings for this particular

play14:06

restart now that's essentially how the

play14:07

google maps api works every time you

play14:09

enter a search query on the particular

play14:12

app you're essentially asking an api

play14:14

you're giving a request to the api and

play14:16

you get a certain response back now this

play14:18

request is in a format that you can't

play14:21

really understand really well it's in

play14:23

this url format you and i as common

play14:25

people are not going to be writing urls

play14:27

each time we want to say search for atms

play14:29

near us we are not going to do that

play14:31

which is why the system understands all

play14:33

of that and then does that for you now

play14:35

the response that comes back it again

play14:36

comes back in a very raw format now this

play14:38

response is then translated to the ui

play14:40

through the magic of html css and

play14:42

javascript now one thing to note is that

play14:44

if you look at the response you also get

play14:45

something called as a status now a

play14:47

status is essentially telling you how

play14:49

the response is there are multiple

play14:52

statuses that you could have the most

play14:53

common ones being status ok or

play14:57

code 200 200 essentially means

play14:59

everything went fine and here is your

play15:00

response back status 400 means that it

play15:03

was a bad request that the request could

play15:04

not be understood now let's say you're

play15:06

in a restaurant and then you just

play15:07

mentioned the name of the dish you want

play15:09

without the quantity now in this case

play15:10

the waiter the chef the kitchen they're

play15:13

not going to understand what it is that

play15:14

you want so they're going to give you a

play15:15

400 error and then they're going to say

play15:16

hey that's a bad request now if it's a

play15:18

500 error then this means that for some

play15:20

reason your request was good but then

play15:22

for some reason the dish could not be

play15:24

prepared maybe we ran out of electricity

play15:27

or maybe the items were not there so

play15:29

they couldn't prepare the dish for you

play15:31

now a 503 error essentially means that

play15:34

the kitchen or the restaurant was

play15:36

unserviceable or unavailable to take on

play15:39

any orders at this point maybe you

play15:40

landed at the restaurant at say 12 in

play15:42

the midnight and the restaurant has

play15:43

already closed and you're trying to

play15:45

place a request but then the restaurants

play15:46

closed so that's when the restaurant is

play15:48

going to give you a 503 error

play15:50

the other thing to also keep in mind is

play15:52

there is this term called as payload now

play15:54

a payload is essentially another name

play15:56

for the response or is essentially the

play15:58

data that you receive and so you would

play16:00

see the terms response payload data

play16:03

being used interchangeably now the last

play16:05

thing to look at is what are get and

play16:07

post requests so within request itself

play16:09

there is something called a get and a

play16:10

post request now so far we've always

play16:13

seen get requests get as in get me a

play16:15

list of things from a particular system

play16:18

now each time we saw let's say in the

play16:19

example of booking a movie ticket you

play16:21

wanted the system to get you the list of

play16:23

open seats in the particular theater

play16:26

based on your requirements now again

play16:28

similarly in the google maps api when we

play16:29

were saying i want the list of

play16:31

restaurants near me it was again a get

play16:32

request get me the list of restaurants

play16:34

that are near me but there's something

play16:36

also called as a post request now a post

play16:38

request essentially you can understand

play16:39

it this way so anytime you don't want to

play16:41

get something but you want to put

play16:42

something in a certain system this is

play16:44

when you use something called as a post

play16:45

request in a very simple sense you can

play16:47

think that this is you trying to say

play16:49

post a photo on facebook or instagram or

play16:51

post a comment or you know like a

play16:53

particular post so each time you're

play16:55

trying to do that you're not trying to

play16:56

get something in return but then you're

play16:58

just trying to post something that

play16:59

you're trying to push something to the

play17:00

other system

play17:01

so that's essentially the difference

play17:03

between get and post requests so that

play17:06

concludes the short primer on what apis

play17:08

are we looked at a whole bunch of things

play17:10

we looked at the example of the

play17:11

restaurant we saw what the definition of

play17:12

an api is we saw how it kind of works we

play17:15

then saw how it looks like in real life

play17:17

we take an example of the bookmark show

play17:19

app and then we saw how the api is

play17:21

looking like there then we even saw how

play17:23

the api truly looks like how does that

play17:25

url look like we saw what is the base

play17:26

url we saw was an endpoint we saw what

play17:28

is the output we saw what is json we saw

play17:30

what are parameters and then we saw how

play17:32

to read an api response lastly we also

play17:34

saw what is a payload and we also saw

play17:36

what is meant by a get and a post

play17:38

request

play17:39

now that's a lot and to tell you the

play17:41

truth that is a lot of information for

play17:43

you to grasp in just this 10-15 minute

play17:46

video so i'm sure you might possibly

play17:47

want to maybe revise this video multiple

play17:49

times or you might have questions so do

play17:50

feel free to put them down in the

play17:51

comments and i'll make sure i get them

play17:52

answered to you so hope this was helpful

play17:54

and under the next video bye

Rate This
★
★
★
★
★

5.0 / 5 (0 votes)

Étiquettes Connexes
API BasicsProduct ManagementTech CommunicationEngineering SyncWeb DevelopmentJSON FormatGet & PostGoogle Maps APITech ConceptsInterdisciplinary Bridge
Besoin d'un résumé en anglais ?