All you need to know about APIs | Product Management | PM School
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
đŒ 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.
đŹ 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.
đ 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.
đĄ 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
đĄEndpoint
đĄGET Request
đĄPOST Request
đĄJSON
đĄParameter
đĄAPI Key
đĄPayload
đĄStatus Code
đĄProduct Management
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
if you aim to get into the product team
of your organization or if you're
currently in the product team in your
organization then a big part of your
daily job is to communicate with your
engineering team and in order to
communicate well you need to know the
basics of technology to ensure that
you're not lost and you understand what
the engineering team says keeping that
in mind we are starting a new series
here today where i'll be uncovering the
most important technical concepts that
you need to know as a pm so that one you
can ace your interviews and also work
really well with your engineering team
so the first topic on our list is what
is called as an api
you may have heard about the term api
somewhere if you're someone who comes
from a computer science background or if
you're a software engineer before then
you probably already know what this is
but my guess is that if you're watching
this particular video then you're not
from a computer science background
you're not from a tech background and
you don't know what an api is possibly
you've heard about it but then it's very
confusing to you so let's begin with a
basic definition of what an api is an
api essentially stands for application
programming interface in a very simple
sense you can understand that in order
for two systems to communicate with each
other system a and system b they can
only communicate using an api if system
may want certain resources or want
something from system b then you can
just ask system b for it and system b
will then perform those calculations and
then give that response back to system a
so in order for two people to
communicate you need an api that's a
very basic definition of what an api is
let's look at an analogy from real life
let's say you go to a restaurant and in
that restaurant you go take a seat at
the table and then you request the
waiter to come and take your food order
now the waiter comes with the menu and
they hand over the menu to you now you
take a look at the menu you see that
certain dishes are typed or are
mentioned in a certain way for example
pizza is typed as parmesan cheese pizza
it's not simply margarita or cheese
you've got some type of pasta in there
as well so you've got a lot of those
things and they are mentioned in a
certain way it's not just pasta or it's
not just pizza and along with that you
see the price now in order for you to
place an order or place a request to the
restaurant or to the waiter you have to
mention specifically what is the exact
dish that you want and you have to
mention it in the exact way that it is
mentioned on the menu if on the menu it
actually says parmesan cheese pizza you
can't just say cheese pizza or you can't
just say pizza you have to mention the
full words which is parmesan cheese
pizza if you don't do that then the
waiter is not really going to understand
what your order is now along with this
you should also mention the quantity of
that particular dish that you want
because without that information then
your order is there's no point in the
order essentially so you mentioned the
dish exactly the way it's specified on
the menu and then you mention the
quantity and the waiter takes your order
goes back to the kitchen works with the
chef and they do something in the
background they prepare the dish and
then they get it back to you via the
waiter so essentially what happened here
was that you gave a request and you had
to follow a certain set of rules in
order to give your request you had to
say the dish name and the exact way it's
mentioned on the menu you couldn't say
it any other way and you had to specify
the quantity which was a mandatory
parameter that you had to give in order
for your request to be a successful
request now you mention your request in
such a way and in return you get the
response which is in the ideal case the
dish now in this case the api is
essentially the combination of the
waiter and the menu both of them
together form the conduit for the
request to go from system a in this case
which is you the customer to system b
which is the kitchen or the chef or the
restaurant and then get the response
back from system b to system a which is
you again now you might be wondering why
can't i do the communication myself why
do i need an api in place a simple
reason for that could just be that maybe
you don't know how to communicate with
the other system in the case of the
restaurant you don't really know how to
communicate if you don't have the menu
in place you can't just go and say hey i
want a pizza the chef is not going to
understand what that means they need
more details from that so which is where
you need some form of communication
layer to help you or help the two
systems communicate the other reason
could just simply be that you're not
allowed inside the other system so this
is a very good analogy to look at but
one thing to note is that any analogy is
not 100 accurate it's just a very easy
way for us to grasp the complex concept
and make it easier for us to understand
now the next question is where do we see
such apis now for this i want to take
you through an example let's say you're
an avid peter parker fan and you want to
go watch the latest spider-man movie
that just released assuming that you're
going to be booking this show online
let's say you open the bookmark show app
once you open the bookmail show up the
first thing that you'll be asked to
provide is the location now this is
essentially your request and one of the
parameters in your request that you're
providing is the location now based on
the location that you provide you're
going to be shown the home page the
moment you gave your location it was
actually an api that was at work to
fetch you the home page to fetch you the
latest list of movies that are running
in your city today now that was an api
it took the request of a location and it
provided you with the movies that are
running today in your city now let's say
you go to the next step let's say you
want to search for a movie or you want
to select a movie so let's say you
select spider-man so now you're going to
press book ticket now when you press
book ticket it's going to ask you for a
bunch of more details it will first ask
you what kind of theater you want to
watch it in do you want to watch it in
imax 3d 2d 3d whatever it is and then
you select that once you select that
you'll now be shown all of the theaters
that are around you or that are in your
city which have i would say shows that
are running today and those that are not
safe fully booked now this again is an
api network it takes in the details it
takes in your location it takes in the
movie that you want to watch it takes in
the type of theatre you want to watch
and then gets you the list of theaters
with the open timings now you select a
date and a certain timing and then you
go to the next step so the next step
you're going to be asked how many seats
do you want to book let's say you select
two now once you've selected that then
comes another step now here what happens
is that you are now shown the list of
empty seats within that particular
theater the seats essentially that you
can book now here again this is an api
network it took all of the details it
took your location it took the movie
that you want to watch it took the
theater you want to watch it and it took
the time of the show it took the you
know the type of theater you want to
watch it took the date and it is now
telling you what are the list of empty
seats or booked seats now this response
is essentially in a format called as a
json format that looks something similar
to this but you don't have to worry too
much about it just note that this is a
very common format that api responses
are usually in now this response is then
translated to the ui through the magic
of html css and javascript now again
that's something that you don't need to
worry too much about you just have to
understand that this response that is
look that that looks like this is then
translated to what you see on the screen
now finally you then book that
particular order and then you're on your
way to watch your latest spider-man show
so now let's see how a sample request
and response looks like for real world
api fair warning to everybody before we
proceed this part might get a little
technical so if you don't have a
computer science background if you
haven't really worked with code before
it will be a little tricky for you to
understand but i suggest you don't
really worry too much about it you can
always go through the video once more if
you'd like or if you have any questions
just put them down in the comments and
i'll answer them for you so here we have
a google maps api now all of you might
have definitely used google maps and
it's kind of become a staple in our
lives
and so this specific api that we're
looking at it's called the places api
it's one of the apis in google maps it
says here that the places api returns
information about places using a certain
type of request now this isn't very
understandable by itself so let me try
and go deep into this it says below
there are different types of requests
that i can make now let me take one
particular request the first one that
there is which is place search now it
says here that place search request
allows you to search for places using a
variety of categories including
establishments prominent places of
interest and geographic location
it's still not very understandable but
what i can kind of get from this is
essentially that i think you give a
request to find a place and then it kind
of gets you back that place well let's
kind of go a little bit further and see
what else they have mentioned now one
thing that they mentioned here is that
there are three types of end points now
what is an endpoint now an endpoint is
essentially the way you can visualize an
end point is by thinking that you are
trying to enter a certain house
now the api is essentially let's say the
door of the house right you need to
enter that particular door now once you
enter the door you're going to have
different let's say needs or different
requirements you might want to eat food
and not afraid to eat food you have to
enter the kitchen you have to go through
the kitchen door enter the kitchen
and do some stuff there prepare the food
and then eat it if you want to say go to
sleep you need to go to the bedroom now
if you go to the bedroom then you have
to access the bedroom door and that's
how you get to the bedroom based on the
different needs or requirements that you
have you have to access different doors
though each of the door is within the
house so similar to that right an api is
something that is the main door of the
house and then an end point
are the you can say the sub doors inside
the house that give you access to a
particular room and so anytime you want
say a different need even though it's
within the same house you go to a
different door and that's the same case
with the end points as well so let's see
a few endpoints that we have here the
first endpoint that we can take which is
a very simple one is the text search
endpoint now let's see what text search
endpoint really does to us it says here
that the text search endpoint returns a
list of places based on a certain text
that we entered for example pizza in new
york or shoe stores near ottawa or 123
main street now in google maps when you
open the application you would have
definitely typed out these keywords
something like i want to see atms near
me i want restaurants near me so i'm
guessing this is that exact api which
kind of gets you the results of that
particular search so let's see how it
works so let's first start with how the
url of that api looks like now what is
the url of an api right very similar to
what you have scenario where you need a
url to type on your browser to access a
certain web page you also need a url to
access a certain api now if we take a
look at it here we see that the url
apis is maps.googleapis.com
slash maps slash api slash place slash
text search slash output question mark
parameters now what do all of these mean
now the first thing to note is there is
something called as a base url now the
base url essentially is like the door of
your house you can call it say the door
number that is your base url now your
base url here is going to be until text
search the next thing your text search
this keyword is essentially your end
point now you can replace this with
another endpoint we saw three endpoints
there we can replace this with another
endpoint and then the next one which is
called output now here
for the request that you give you have
to define how you want the output to
look like a very common way like i said
is the json format and so you just have
to mention json over here the next one
is parameters now parameters is
essentially given you're asking for
something given you're requesting for
something what do you want in return
what are those fields you want to
actually see in return now that you have
to put it in the parameters section so
let's see how a sample request is going
to look like so we're able to scroll
down and we see this one basic example
that they've given it says here that the
following example shows you the
restaurants near sydney okay now as you
can see you see the base url and then
you see the endpoint and then you see
the output which is json then you see
the query now query is some form of
parameter that we need to provide for
this endpoint which would be documented
somewhere so we have to say that the
query equal to restaurants near sydney
now you don't have to worry so much
about the percentage 20 sign or symbol
that appears there it's just a basic way
to encode or help the computer better
understand a space so it's just in place
of a space that's all it is so you have
a query and then the next thing you have
is something called an api key now an
api key in a very simple sense if you
want to access your door you need a key
without the key you can't open the door
you can't access the api without a key
so you need to have a key to open the
door so that's your api key now with
this request let's see how the response
looks like so here's the response for
the exact request that we placed we see
a bunch of things all in this format
like i said json format let's just try
and see what is there in this json
format the first it tells me the
business status which i think is when it
says operational i i'm assuming that
that particular place is operational and
the next thing it tells me is the
formatted address which is the exact
address of this particular location
then it tells me the geographic
coordinates and then it gives me a bunch
of information it tells me the name more
importantly and it says here restaurant
hubert okay so that's restaurant hubert
then it tells me is it open now and says
false which means it's not open at this
particular point as i'm making this
particular video it then gives me a
bunch of other information finally it
gives me the total rating for this place
and then it also tells me that all the
people who have given a rating for this
particular place now we saw here this
was a restaurant hubert now usually when
you when you type in a certain request
like this in the actual google maps
app
you would get multiple say restaurants
you just simply type in restaurants near
your whatever your location is and you
get multiple restaurants and so in a
json format you get multiple again you
get multiple restaurants so now let's
see the next restaurant in this
in this json output that we got we see
the business status it says it's closed
temporarily we then see the address then
we see a bunch of other information and
then we see the name now this name is
arya restaurant sydney okay so then
again similarly we see some more
information we see some photos and then
we see the rating of this place and
finally we see the total number of
people who have rated this particular
restaurant now i'm going to show you
exactly how this looks like if i type
this particular query on google maps so
here i have the google maps app open in
front of me i'm entering the keywords
restaurants near sydney and i get a
bunch of different restaurants now let
me try and figure out if i can get the
two restaurants that we saw one was
restaurant hubert and the other was arya
restaurant sydney so here it is here is
restaurant hubert and let's say i click
on this and then i get the exact
response which is i get the photos which
was already provided as a json response
i get the address which is the same as
what came out to the json response i
then see the
rating and then i see the total number
of people who have uh rated this
particular place and now let me see if i
can find arya restaurant sydney if i
scroll down a little bit further and i
do a bit of searching i again find arya
restaurant sydney which is awesome if i
click on aria restaurant sydney i then
again see the same things i see the list
of photos i see the address i see the
rating and then total list of people who
have given ratings for this particular
restart now that's essentially how the
google maps api works every time you
enter a search query on the particular
app you're essentially asking an api
you're giving a request to the api and
you get a certain response back now this
request is in a format that you can't
really understand really well it's in
this url format you and i as common
people are not going to be writing urls
each time we want to say search for atms
near us we are not going to do that
which is why the system understands all
of that and then does that for you now
the response that comes back it again
comes back in a very raw format now this
response is then translated to the ui
through the magic of html css and
javascript now one thing to note is that
if you look at the response you also get
something called as a status now a
status is essentially telling you how
the response is there are multiple
statuses that you could have the most
common ones being status ok or
code 200 200 essentially means
everything went fine and here is your
response back status 400 means that it
was a bad request that the request could
not be understood now let's say you're
in a restaurant and then you just
mentioned the name of the dish you want
without the quantity now in this case
the waiter the chef the kitchen they're
not going to understand what it is that
you want so they're going to give you a
400 error and then they're going to say
hey that's a bad request now if it's a
500 error then this means that for some
reason your request was good but then
for some reason the dish could not be
prepared maybe we ran out of electricity
or maybe the items were not there so
they couldn't prepare the dish for you
now a 503 error essentially means that
the kitchen or the restaurant was
unserviceable or unavailable to take on
any orders at this point maybe you
landed at the restaurant at say 12 in
the midnight and the restaurant has
already closed and you're trying to
place a request but then the restaurants
closed so that's when the restaurant is
going to give you a 503 error
the other thing to also keep in mind is
there is this term called as payload now
a payload is essentially another name
for the response or is essentially the
data that you receive and so you would
see the terms response payload data
being used interchangeably now the last
thing to look at is what are get and
post requests so within request itself
there is something called a get and a
post request now so far we've always
seen get requests get as in get me a
list of things from a particular system
now each time we saw let's say in the
example of booking a movie ticket you
wanted the system to get you the list of
open seats in the particular theater
based on your requirements now again
similarly in the google maps api when we
were saying i want the list of
restaurants near me it was again a get
request get me the list of restaurants
that are near me but there's something
also called as a post request now a post
request essentially you can understand
it this way so anytime you don't want to
get something but you want to put
something in a certain system this is
when you use something called as a post
request in a very simple sense you can
think that this is you trying to say
post a photo on facebook or instagram or
post a comment or you know like a
particular post so each time you're
trying to do that you're not trying to
get something in return but then you're
just trying to post something that
you're trying to push something to the
other system
so that's essentially the difference
between get and post requests so that
concludes the short primer on what apis
are we looked at a whole bunch of things
we looked at the example of the
restaurant we saw what the definition of
an api is we saw how it kind of works we
then saw how it looks like in real life
we take an example of the bookmark show
app and then we saw how the api is
looking like there then we even saw how
the api truly looks like how does that
url look like we saw what is the base
url we saw was an endpoint we saw what
is the output we saw what is json we saw
what are parameters and then we saw how
to read an api response lastly we also
saw what is a payload and we also saw
what is meant by a get and a post
request
now that's a lot and to tell you the
truth that is a lot of information for
you to grasp in just this 10-15 minute
video so i'm sure you might possibly
want to maybe revise this video multiple
times or you might have questions so do
feel free to put them down in the
comments and i'll make sure i get them
answered to you so hope this was helpful
and under the next video bye
5.0 / 5 (0 votes)