Fireship · @fireship
RESTful APIs in 100 Seconds // Build an API from Scratch with Node.js Express
Uploaded February 19, 2021 · Length 11:20
Summary
Learn how to build a RESTful API from scratch using Node.js and Express in 100 seconds.
- restful api
- node js
- express
- api development
- javascript
- web development
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
an application programming interface or
- 0:02
api is a way for two computers to talk
- 0:05
to each other using an api is just like
- 0:07
using a website in your browser but
- 0:09
instead of clicking buttons and filling
- 0:11
out forms you write code to explicitly
- 0:13
request data from a server for example
- 0:16
we could visit the nasa website to look
- 0:18
at asteroids or we could use their rest
- 0:20
api to request the raw json data that is
- 0:23
shown on the screen now most apis in the
- 0:25
world are restful which means they
- 0:27
follow a set of rules or constraints
- 0:29
known as representational state transfer
- 0:31
which has been the de facto standard for
- 0:33
api development since the early 2000s a
- 0:36
restful api organizes data entities or
- 0:39
resources into a bunch of unique urls
- 0:41
well technically not urls but uris or
- 0:44
uniform resource identifiers that
- 0:46
differentiate different types of data
- 0:48
resources on a server a client can get
- 0:51
data about a resource by making a
- 0:53
request to that endpoint over http the
- 0:56
request message has a very specific
- 0:58
format most importantly the start line
- 1:00
contains the uri that you wish to access
- 1:02
which is preceded by an http verb or
- 1:05
request method which signal your intent
- 1:07
with the resource a get request means
- 1:09
you just want to read the data while
- 1:11
post means you want to create a new
- 1:12
resource patch is for updates delete is
- 1:15
for removing data along with a few other
- 1:17
methods beyond those below the start
- 1:19
line we have headers which contain
- 1:20
metadata about the request the accept
- 1:22
header can tell the server you want the
- 1:24
data in a specific format or the
- 1:26
authorization header can be used to tell
- 1:28
the server that you're actually allowed
- 1:29
to make that request then following the
- 1:31
headers we have the body which contains
- 1:33
a custom payload of data the server will
- 1:36
receive the request message then execute
- 1:38
some code usually to read from a
- 1:39
database that can then be formatted into
- 1:41
a response message the top of the
- 1:43
message contains a status code to tell
- 1:45
the client what happened to their
- 1:47
request codes at the 200 level mean that
- 1:49
things went well at the 400 level it
- 1:51
means something was wrong with your
- 1:52
request and at the 500 level it means
- 1:55
that the server failed after the status
- 1:57
code we then have the response headers
- 1:59
which contain information about the


