Phase 01 · Absolute foundations Core

HTTP, APIs & JSON

The way programs talk to each other over the internet - and the way you will talk to every AI model.

In plain terms

An API is a restaurant menu for software: you send a written order (a request) and get a dish back (a response). When you use ChatGPT, an app sends your text over HTTP to a server, and JSON - a simple text format like {"answer": "hello"} - carries the reply back.

Why it matters

The best AI models run on someone else's giant computers. You can't download GPT or Claude to your laptop - you rent them per request. APIs are the doorway, so an AI engineer who is fuzzy on HTTP is fuzzy on everything.

How it works

A request has a URL (where), a method (POST = send data), headers (your API key lives here), and a body (your prompt, as JSON). The response has a status code (200 ok, 429 slow down, 500 server broke) and a JSON body with the model's answer.

When you use it

Every time you call a model, a vector database, or any external service - which is to say, in every project in this roadmap.

In code

import requests, os

r = requests.get("https://api.github.com/users/octocat")
print(r.status_code)        # 200 = success
data = r.json()             # JSON text -> Python dict
print(data["public_repos"]) # pick one field out

Common mistakes

  • Hardcoding API keys in code and pushing them to GitHub (bots steal them within minutes - use environment variables).
  • Ignoring status codes and assuming every call succeeded.
  • Not reading the response JSON structure carefully - most 'bugs' are just grabbing the wrong field.

Best practices

  • Keep secrets in a .env file, load them with python-dotenv, and add .env to .gitignore.
  • Print the raw response the first time you call any new API.
  • Learn curl or an API client (Bruno/Postman) to test endpoints before writing code.

Try it yourself

Use Python's requests library to call the free https://api.github.com/users/YOUR_NAME endpoint, print the status code, and extract one field from the JSON.

Resources