Essential CSS
JavaScript Roadmap
Learn JavaScript
Mastering Web Typography
Practical Astro
Understanding Async JS
Unorthodox Tailwind
API Masterclass
Build and Deploy
The Beginner Freelancer
Real World Node
Profile Billing Logout
Understanding Async JS
Lesson Plan
  1. Introduction
    1. What is Asynchronous JS?
    2. Callbacks are not automatically asynchronous
    3. What is an API?
    4. Evolution of HTTP APIs
    5. Ajax vs Asynchronous JavaScript
  2. Fundamental Concepts
    1. How to fetch resources
    2. Using XHR
    3. Using the Fetch API
    4. Using libraries
    5. Core JavaScript concepts
    6. Understanding Promises
    7. Understanding Async Functions
    8. Understanding the Event Loop
    9. Understanding JSON
    10. Async JS Best Practices
    11. Using Optimistic UI
  3. Understanding Rest API
    1. Diving into Rest APIs
    2. The Rest Architecture
    3. The Rest Structure
    4. Anatomy of a Request
    5. What's an endpoint
    6. Request methods
    7. Understanding request headers
    8. Understanding the request body
    9. Authentication
    10. Basic Authentication
    11. Bearer Authentication
    12. Authenticating with API keys and API Secrets
    13. Cross Origin Resource Sharing
    14. Anatomy of a response
    15. HTTP Statuses
    16. Response headers
    17. The response body
    18. Handling Errors
    19. Reading API documentations
    20. Understanding Curl
  4. Node Basics
    1. Why we are using Node
    2. Command Line Basics
    3. Installing Node
    4. Managing dependencies
    5. Using ES Modules in Node
    6. Using Node
    7. Restarting the server automatically
    8. Sending requests via Node
    9. Protecting API keys and secrets
  5. Building a server
    1. What's a server
    2. Building a simple server with Express
    3. Two kinds of servers
    4. API Server architecture
    5. Handling routes
    6. Understanding Middlewares
    7. Enabling CORS
    8. Receiving data
    9. Sending responses
    10. Handling errors in Express
    11. Using the server as a proxy
    12. Minimum viable server
  6. Open Authorization
    1. Open Authorisation (OAuth)
    2. Authenticating with Access Tokens
    3. Obtaining Access Tokens
    4. Public and Confidential Clients
    5. Authorisation Code Grant
    6. Understanding scope
    7. Proof Key for Code Exchange (PKCE)
    8. PKCE with Twitter
    9. Dynamic state and `code_verifier`
    10. Saving the access token in cookies
    11. Passing access tokens to the browser
    12. Saving the access token in local storage
    13. Refresh Token Grant
    14. Device Code Grant
    15. Client libraries vs REST
  7. Building Social Media Logins
    1. Introduction
    2. Starter Files
    3. Creating SSL certificates
    4. Login in with Github
    5. Github: Saving the token to local storage
    6. Github: Persisting the login status
    7. Login with Twitter
    8. Twitter: Saving the token to local storage
    9. Twitter: Persisting the login status
    10. Twitter: Refreshing the access token
    11. Login with Facebook
    12. Facebook: Saving the token to localStorage
    13. Facebook: Persisting the login status
    14. Facebook: Refreshing the access token
    15. Login with google
    16. Google: Saving the token to localStorage
    17. Google: Refreshing the access token

Reading API documentations

2m:33s

I want to walk you through what I do when I read API documentation. Knowing this will help you find information from API docs quickly.

I break what I do into three steps:

  1. Read the overview
  2. Figure out how to authenticate
  3. Check the reference

Step 1. Read the overview

The first thing you should do is to read the overview (or introduction) section of the API.

This section normally includes information you need to know to use the API. This includes things like:

  • The root endpoint
  • Rate limits
  • How to authenticate requests
  • Notes on custom headers you may need to send
  • Pagination (for list responses)

The root endpoint

Each API will have one root. This root can often be found at the start of all API documentation. For example, you can find GitHub’s root in the Overview section

Github's endpoint.

Rate limits

Rate limits tell you how many requests you can send per a certain unit of time.

For example, GitHub lets you send 60 requests every hour. If you send more, you’ll get a 403 error.

Error from a rate limit

Most APIs also let you raise the rate limits if you are authenticated. For example, GitHub lets you send up to 5,000 authenticated requests every hour.

Step 2. Figure out how to authenticate

Most APIs require authentication. It will usually use one of these three methods:

  1. Basic Authentication
  2. Open Authorization (OAuth)
  3. API Key and Secret

You will be able to authenticate with the server successfully once you know which method(s) they accept.

Step 3. Check the reference

The reference contains a list of all available endpoints — this gives you an idea about what data you can get.

Knowing the data you can get helps you plan what you can do with the API.

A note on endpoint structure

Most REST APIs share a similar url structure as follows:

  • GET /items - get a list of items.
  • GET /items/:id - get an item
  • POST /items - create one or more items
  • PUT /items/:id - change an item
  • PATCH /items/:id - change an item
  • DELETE /items/:id - delete an item

The : signifies a placeholder. :id here means you should replace the value with the actual id.

Some APIs may use other placeholder signifiers like {} and <>. For example, GitHub shows you the following URL to fetch a user’s repositories.

In this case, {username} is a placeholder. You should replace it with an actual username when you use the endpoint.

Next, it helps to understand cURL

Here’s a fact you should know:

  • Most APIs don’t write their docs in JavaScript or Node
  • They may not use other languages like PHP, Ruby, or Python as well.
  • But they will (almost always) use cURL

If you can understand cURL, you will be able to read every Rest API documentation.

That’s what you’re going to learn next.