Get your API key

Lesson 2 of 5

Build a Pincode finder that calls a public API

Read the API docs first, make the agent show the raw response, build a page with loading, found, not-found and error screens, and keep keyed APIs behind your server.

8 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson you will have a working Pincode finder page that calls a real API, shows a clear screen for every outcome, and you will know where a keyed API call must live.

You need: your coding agent (set up in Web MVP lesson 1), a browser, an empty folder · Time: 8 minutes

  1. Every API has a docs page: the instruction sheet that says what you may ask and what comes back. Agents often write API code from memory, and memory is old. Five minutes with the docs saves an hour of "why is it empty?".

    Look for six things:

    1. Base URL: the start of every address, e.g. https://api.postalpincode.in.
    2. Endpoints: the paths you can call, e.g. /pincode/{PINCODE} and /postoffice/{NAME}.
    3. Parameters: what you put in the path or after ?, and their format (6 digits, a city name…).
    4. Auth: does it need a key? Where does the key go?
    5. Limits and terms: how many calls per minute or day, and whether business use is allowed.
    6. Errors: what a "not found" or a failure looks like.

    The pincode API's docs page (on postalpincode.in, under API Doc) lists the two endpoints and an example answer. It needs no key and publishes no rate limit, so be polite: one call per search, not one per key press.

    Do it now

    Do it now, for the API you want to use

    Why?

    You will paste these six facts into your prompt. An agent that is told "the answer has a Status field that can be Error" writes the right check; an agent that guesses writes a page that shows nothing.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Make the agent show you the raw answer first
  2. Build the page with all four screens
  3. Test it like a suspicious user
  4. APIs with a key: call them from your server
  5. Recap