HTTP & REST APIs for App Developers

Requests, methods, status codes, headers, JSON and REST conventions, seen from the client side of a mobile app.

Beginner · about 5 hours · difficulty 2/5

Learn first: Async Code & the Main Thread

Nearly every app talks to a backend over HTTP. You do not need to build servers, but you must read API docs fluently and debug failed requests.

The essentials

  • A request has a method (GET read, POST create, PUT/PATCH update, DELETE remove), a URL, headers and an optional body.
  • Responses carry a status code: 2xx success, 3xx redirect, 4xx client error (401 not authenticated, 403 forbidden, 404 not found, 422 validation), 5xx server error.
  • JSON is the usual body format; set Content-Type: application/json.
  • Authorization headers carry tokens: Authorization: Bearer <token>.

REST conventions

Resources as nouns (/users/42/orders), query parameters for filtering and pagination (?page=2&limit=20 or cursor-based ?after=abc).

Mobile specifics

  • HTTPS only: iOS App Transport Security and Android's network security config block cleartext by default.
  • Networks are slow and flaky: always set timeouts, handle "no connection", and retry idempotent requests with backoff.
  • Test APIs with a tool like Bruno, Insomnia or curl before wiring them into the app.

Good enough to move on: you can read an API reference, reproduce a call with curl, and explain what a 401 vs 403 vs 500 means for your UI.

Key concepts

  • HTTP methods
  • Status codes
  • Headers and JSON bodies
  • REST resource design
  • Pagination styles
  • HTTPS and cleartext restrictions
  • API testing tools

Mini project

Pick a public API (for example a weather or movies API), document three endpoints you need, and reproduce each with curl including one error case.

Check yourself

Your app gets a 401 on a request that worked yesterday. What does that suggest, and what should the app do?

Free resources