ABCsteps lesson path

How Apps Talk: APIs Revealed

Call a public API, inspect the response, and connect the idea to how modern applications communicate. Build one artifact, keep one review trail, and make the work easy to inspect later.

Lesson
09
Time
45 min
Access
public lesson

Learning objective

Understand requests, responses, status codes, and API contracts.

Lab outcome

Call an API and use the returned data in a small interface.

Module milestone

Containerize and share a working app through a verified deployment path.

Lesson proof workflow

Read, build, then review the evidence.

  1. Node.js hero workflow iconStep 1ReadStart with API contracts before touching tools.
  2. JSON hero workflow iconStep 2BuildBuild toward: Call an API and use the returned data in a small interface.
  3. JavaScript hero workflow iconStep 3ReviewReview the evidence using Payload reading.

Toolchain

APIs are contracts between systems, not magic endpoints.

These are the practical surfaces used in this lesson. Learn the habit first, then connect it to the wider engineering ecosystem.

Node.js iconNode.jsRequests

Call services and handle responses deliberately.

JSON iconJSONPayloads

Read the data shape returned by an API.

JavaScript iconJavaScriptInterface glue

Use response data inside a small app.

Proof of work

Leave one inspectable trail from this lesson.

The useful output is not a passive note. It is a small artifact another person can inspect: a working file, a command result, a commit, a screenshot, a README note, or a demo link.

Lesson lab: Call an API and use the returned data in a small interface.

Tool and platform logos are ecosystem references only: no affiliation, endorsement, interview access, hiring promise, salary promise, or placement guarantee.

Node.js proof icon

Build

Produce the artifact

Complete the lab and keep the result visible: Call an API and use the returned data in a small interface.

JSON proof icon

Record

Save review evidence

Capture what changed, what broke, and how API contracts became clearer through the work.

JavaScript proof icon

Explain

Write the vocabulary

Use your own words for Request response flow and Payload reading; this is what makes the lesson inspectable later.

Skills companies recognize

Translate the lesson into inspectable work language.

This lesson turns one small lab into the language a learner can use in a README, demo note, or technical conversation. The point is not to collect logos; the point is to explain work clearly enough that another engineer can inspect it.

Where this skill appears

API thinking is a cross-company skill because every useful product eventually talks to another system.

Backend engineeringIntegration teamsFull-stack product teams

Ecosystem references

AWS skill ecosystem logoGoogle Cloud skill ecosystem logoMicrosoft skill ecosystem logoGitHub skill ecosystem logoCloudflare skill ecosystem logoOpenAI skill ecosystem logoGoogle skill ecosystem logo

Platform and company logos are ecosystem references only: no affiliation, endorsement, interview access, hiring preference, salary outcome, or placement guarantee.

Node.js skill proof icon

README line

Name the artifact

Lab proof: Call an API and use the returned data in a small interface. Connect it to API contracts so the result reads like work, not a passive note.

JSON skill proof icon

Review line

Explain the stack

Use Node.js, JSON, JavaScript to explain Request response flow and what changed between the first attempt and the inspected result.

JavaScript skill proof icon

Conversation line

Answer with evidence

If a team asks about Payload reading, use this proof line: Show the request, response, status code, and how the UI changed after reading the payload.

Proof translation

Node.js proof translation icon

Skill signal

API contracts is the market word. The lesson makes it visible through a small working artifact.

JSON proof translation icon

Proof artifact

The inspectable artifact is: Call an API and use the returned data in a small interface.

JavaScript proof translation icon

Interview answer

Use Request response flow and Payload reading to explain what changed, what failed, and how you verified it.

Paid guidance

Read publicly. Upgrade when guidance will help you finish.

This lesson remains part of the public written syllabus. Paid help is online-only and human-led: video walkthroughs as they roll out, live class context, WhatsApp Q&A, and project review around the same work.

No account wall, automated checkout, or placement promise is introduced here. Enrollment stays human-led by WhatsApp or call, and the useful proof remains the learner's own artifact.

Node.js paid guidance icon

Public

Written lesson stays open

Read the prepare and review material for lesson 09 on the public site before buying anything.

JSON paid guidance icon

Recorded

Recorded and live guidance clarify the work

Paid guidance can add founder-led video walkthroughs as they roll out and live online class context; the teaching explains the work, but does not replace the written lesson.

JavaScript paid guidance icon

Human

Questions use real context

When stuck, useful guidance starts from the route, error, screenshot, repo fragment, and the lab artifact: Call an API and use the returned data in a small interface.

Phase 1 · Briefing

Lesson briefing

Before You Study (5 mins)

Lesson focus: Lesson 08 made you fluent in reading JSON files locally. Today you read JSON files that live on other people's computers — anywhere in the world — by making your first API calls. When you tap "refresh" in any app, what happens under the hood is: your client opens an HTTP request, a server somewhere receives it, runs some logic, and sends back a JSON response. That cycle is what you're going to perform yourself today, deliberately, with curl first and then fetch() from your game.

What you should have ready:

  • Terminal fluency from Lesson 04 — we'll use curl extensively
  • Browser DevTools open (F12 or Cmd+Option+I) — Network tab visible
  • Your Snake game project — we'll add an API call to it
  • Internet connection — APIs require it
  • About 60 minutes

The Concept

An API (Application Programming Interface) is a contract. The contract specifies: which URLs you can request, what HTTP method to use (GET, POST, ...), what headers to send, what shape the request body should have, and what shape the response will come back in. Your code holds up its side of the contract by sending well-formed requests; the server holds up its side by sending well-formed responses. When both sides honor the contract, two systems built by different people in different languages talk seamlessly.

The request–response cycle has a fixed shape:

text
       ┌────────────────┐         GET /weather?city=Mumbai           ┌──────────┐
       │   Your client  │────────────────────────────────────────────▶│  Server  │
       │  (browser/app) │                                              │  (API)   │
       │                │◀─── 200 OK + JSON body ────────────────────│          │
       └────────────────┘                                              └──────────┘

A request has four parts:

  • Endpoint (the URL): https://api.example.com/v1/weather?city=Mumbai
  • HTTP method (the verb): GET, POST, PUT, PATCH, DELETE
  • Headers (metadata): Content-Type: application/json, Authorization: Bearer <token>, User-Agent: ...
  • Body (payload, only on POST/PUT/PATCH): a JSON document with the data you're sending

A response has three parts:

  • Status code (the verdict): a 3-digit number telling you the outcome
  • Headers (metadata about the response)
  • Body (the data, almost always JSON)

The five HTTP verbs each map to an intent:

VerbIntentIdempotent?
GETRead a resource — retrieve dataYes
POSTCreate a new resourceNo
PUTReplace a resource entirelyYes
PATCHUpdate part of a resourceSometimes
DELETERemove a resourceYes

"Idempotent" means: doing the same operation multiple times produces the same end state. Calling GET /users/42 ten times returns the same user. Calling DELETE /users/42 ten times leaves the user equally deleted (the second call returns 404, but the system state is the same). POST /orders is not idempotent — calling it ten times creates ten orders, which is why retried requests need idempotency keys in production systems.

Status codes are a protocol with five families. A senior engineer can debug most issues from the status code alone:

FamilyRangeMeaningExamples
2xx200-299Success200 OK, 201 Created, 204 No Content
3xx300-399Redirection301 Moved Permanently, 304 Not Modified
4xx400-499Your mistake400 Bad Request, 401 Unauthorized, 404 Not Found, 429 Too Many Requests
5xx500-599Server's mistake500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable

The instinct that separates beginners from senior engineers: when a request fails, the status code tells you immediately whether the bug is on your side (4xx) or the server's side (5xx). Don't blame their server when it returned 400.

Want the full architectural story — REST vs GraphQL vs gRPC, idempotency keys, authentication patterns, OpenAPI specs, the API economy? The companion article What is an API and How Do APIs Actually Work is calibrated to extend this lesson. Read it after today's hands-on practice to lock in the architectural model.

Quick Concepts

TermSimple Meaning
APIA contract for how programs ask another program for data
EndpointA specific URL on an API (/users/42, /weather, /quotes/random)
RequestWhat your client sends — method + URL + headers + body
ResponseWhat the server sends back — status + headers + body
Status codeA 3-digit number telling you the outcome (200, 404, 500, ...)
fetch()The browser API for making HTTP requests from JavaScript
curlThe command-line tool for making HTTP requests from your terminal

What We Will Build

By the end of this lesson, you will have done these specific things:

  1. Made your first curl call to a public API in your terminal:
    bash
    curl https://api.quotable.io/random
    
    Read the JSON that comes back. Recognized the structure: content, author, tags.
  2. Inspected the headers and status by adding the -i flag:
    bash
    curl -i https://api.quotable.io/random
    
    Identified the status code (200), Content-Type: application/json, and Cloudflare's Server header.
  3. Made a different request to test status codes — call a non-existent endpoint and watch a 404 come back:
    bash
    curl -i https://api.quotable.io/this-does-not-exist
    
  4. Wrote your first browser-side API call in your Snake game using fetch():
    javascript
    async function loadQuoteOfTheDay() {
      const response = await fetch('https://api.quotable.io/random')
      if (!response.ok) {
        console.error('API failed:', response.status)
        return null
      }
      const data = await response.json()
      return data
    }
    
  5. Added a "Quote of the Day" to your loading screen by calling loadQuoteOfTheDay() and showing data.content and data.author to the player.
  6. Watched the request in DevTools' Network tab — found your call, expanded it, looked at Request Headers / Response Headers / Response body. The Network tab will be your debug surface for every API call you'll ever make.
  7. Triggered a 4xx and a 5xx on purpose to feel them: try a malformed request to a real API; turn off your wifi mid-call and observe the network failure.
  8. Added the await and try/catch around your fetch so the game doesn't crash if the API is down — defensive programming for a world that occasionally fails.

The shift from curl (terminal) to fetch (browser) is intentional. Both make the same HTTP request under the hood; switching between the two as you debug will become second nature in Module C.

Think About

Before studying, consider:

  1. The "weather app" on your phone has no idea what the weather is. It knows how to ask a weather API. The actual atmospheric measurement is happening at sensor stations around the world, processed by NOAA / IMD / WMO, surfaced through APIs, and your phone is just the last mile. How many systems do you think a single weather check passes through?
  2. If POST /orders creates an order and your network is flaky and you retry the request, you might create two orders for one click. How would you design the API to make this safe? (Hint: this is exactly what idempotency keys solve in production.)

By the End

After this lesson, you'll:

  • ✅ Have made your first curl API call from the terminal
  • ✅ Know the 4 parts of a request and 3 parts of a response
  • ✅ Recognize the 5 HTTP verbs and their intents
  • ✅ Know what each status code family means (2xx success, 4xx your fault, 5xx their fault)
  • ✅ Have called a real API from your Snake game using fetch()
  • ✅ Have watched the call land in DevTools' Network tab
  • ✅ Have wrapped the call in try/catch so a failed API doesn't crash your game

The internet is a conversation. Today you join it. 🛎️

Next lesson · 10

Milestone: Your App Is Online

Review the build, container, and deployment path, then verify the app is reachable outside your local machine.

Cloudflare next lesson iconDocker next lesson iconGitHub next lesson icon