AI Learning Hub › AI Tutorials › Understanding APIs
Building and prototyping · Seven-module course
Understanding APIs
An API is how one piece of software asks another for something and gets an answer back. Seven recorded modules take that from the first request to a system you can test and monitor — with the lab snippets, a status-code reference, and a JSON primer kept on this page so you are not hunting for them while a video plays.
- Format
- Seven recorded modules, each with the code and configuration used in it
- Length
- About 90 minutes end to end; each module stands alone
- Written for
- Anyone who has to work alongside software without writing it for a living — no coding background assumed
- What you need
- A browser. Modules four onward are easier to follow with a free API-testing tool such as Postman
About the code on this page. The snippets are teaching illustrations, written to be read rather than run. Some name a service that does not exist outside the lab, so treat them as the shape of a request or a configuration file, not as a working integration. Every real API you use will have its own documentation, and that documentation wins.
Part one
The seven modules
Watch in order the first time. Each module opens with what it covers, carries its recording, and ends with the handful of things you should be able to explain afterwards.
Module one · Core concepts
What are APIs?
How software systems talk to each other. Why an API is often described as the waiter of the web — you do not go into the kitchen, you place an order and something comes back — and where those connections already sit inside legal work you do every day.
The request and response activity
The video asks you to read this object aloud and say what each line is telling you.
{
"student_id": "sls_2026",
"name": "Jane Doe",
"courses": ["Law & Tech", "Prototyping 101"],
"active": true
}
You should be able to explain
- What an API is, in one sentence, without using the word API
- The request and response cycle — who asks, who answers
- Why JSON is the format almost everything answers in
- Two places an API is already doing work in a legal workflow
Module two · Intermediate
Authentication and data flow
Building on module one, this goes a layer down into the plumbing: how a service knows it is you, what a key is and how badly it matters, and how to read an error rather than guess at it.
Lab snippets
The two halves of the authentication segment: what you send, and what comes back when it is wrong.
Authorization: Bearer sk_live_51M7…
{
"error": {
"code": "unauthorized",
"message": "Invalid API Key provided."
}
}
A key is a credential. Anything holding a live key can spend money and read data as you. Never paste one into a page, a chat, a screenshot, or a public repository — and if you think one has leaked, revoke it rather than hoping.
You should be able to explain
- What an
Authorizationheader is doing - The difference between a key and an OAuth flow, in outline
- How to trace a value from your request to the response that used it
- Why a
401is a question about you and a500is not
Module three · Advanced
System architecture
One API is rarely the whole story. This module puts a single connection back into the system around it — several services, each with a job, each depending on others — which is the shape most legal technology actually arrives in.
The microservices exercise
Read this the way the video does: two services, one of which cannot start until the other is up. The indentation is the whole meaning, which is why a stray space breaks a file like this.
services:
- name: "case-management"
port: 8080
dependencies: ["auth-service", "database"]
- name: "client-portal"
port: 3000
dependencies: ["case-management"]
You should be able to explain
- What makes a system distributed, and what that costs
- Microservices against a monolith — the trade, not the winner
- Where a system breaks first when demand grows
- What an API gateway sits in front of, and why
Module four · Practical lab
Writing your first integration
The hands-on module. You script a small legal automation end to end: connect, ask for a document, have something judge it, and return an answer a person can act on. The recording calls this the “Vibe Protocol”; the pattern underneath it is the same one every integration follows.
Setting up the environment
Connections carry settings, and two of them are worth arguing about before you write anything else: where the data is allowed to sit, and which rules apply to it.
// Open the connection with its constraints declared up front.
client.connect({
mode: "secure",
region: "us-west-1",
compliance: ["GDPR", "CCPA"]
});
One step of the workflow
Fetch, assess, decide. Note that the decision is a threshold you chose, not something the model handed you — and that a flag routes the document to a person rather than closing the matter.
// Define one action in a review workflow.
async function reviewContract(docId) {
const doc = await client.docs.get(docId);
const risk = await client.ai.analyzeRisk(doc);
return risk.score > 80 ? "FLAGGED" : "APPROVED";
}
You should be able to do
- Set up a working environment and confirm it connects
- Write a script that makes one request and uses the answer
- Handle a response that is not the one you hoped for
- Read an error message far enough to know what to change
Module five · Expert
Autonomous agents
What changes when the thing calling the API decides for itself which call to make next. How agents are given an objective, a boundary, and a budget — and why the boundary is the part you should spend your time on.
Configuring an agent
Everything in this file is a limit. permissions says what it may touch;
max_steps says when it must stop even if it has not finished.
{
"agent_name": "legal_research_assistant_v1",
"permissions": ["read_case_files", "web_access"],
"model": "<your model here>",
"max_steps": 10
}
Giving it a task
A usable objective is narrow, and the constraint is doing as much work as the objective. Compare what this asks for against “research IP theft cases”.
const task = await agent.createTask({
objective: "Summarize recent precedents for IP theft in virtual worlds.",
constraints: "Focus on Ninth Circuit decisions after 2024.",
output_format: "memo"
});
await agent.execute(task);
An agent’s output is a draft. A research memo assembled without supervision can be fluent and wrong, and citations are exactly where that shows up. Verify every authority in a real source before any of it leaves your desk.
You should be able to explain
- The levels of autonomy, and which one a given task warrants
- How an agent plans a multi-step job and where the plan goes wrong
- What granting a tool or an API actually grants
- Where a person has to sit in the loop, and what they check
Module six · Expert
Testing and observability
Shipping is the start, not the finish. How to write a test for something that answers differently every time, and how to notice a system degrading before the person relying on it does.
A test with a fixed input
The trick with a non-deterministic system is to test a claim rather than a string: this contract is risky, and indemnification is one of the reasons.
describe('Contract review', () => {
it('should flag high-risk clauses', async () => {
const doc = await loadFixture('risky_contract.pdf');
const result = await agent.analyze(doc);
expect(result.riskScore).toBeGreaterThan(80);
expect(result.flags).toContain('Indemnification');
});
});
What to watch once it is running
Two numbers and a place to send them. Alerting nobody reads is not observability.
{
"alerting": {
"latency_threshold_ms": 1500,
"error_rate_threshold": 0.05,
"channels": ["slack-ops", "email-admin"],
"log_level": "DEBUG"
}
}
You should be able to explain
- How to unit test a prompt without asserting on exact wording
- What a regression test protects you from as the model changes
- Which latency figure matters — and it is not the average
- What an error budget is, and what spending it means
Module seven · Closing
Ethics, and what comes next
The last module steps back from the code. What it means to be accountable for something that acts on your behalf, which commitments are worth writing down before you need them, and where to take this after the course ends.
Commitments, written down
A policy in a configuration file is a policy someone can check. These four are a starting point, not a complete list — and each one has to mean something you would actually enforce.
{
"ethics_policy": {
"human_in_the_loop": true,
"transparency": "maximum",
"bias_mitigation": "active",
"data_privacy": "strict"
}
}
The improvement loop
Reflect, adjust, review. The third line is the one that keeps this a tool rather than a process running without you.
// The loop of continuous improvement.
async function improve() {
const insights = await agent.reflect();
await agent.optimize(insights);
await human.review(); // not optional
}
If the system disappeared tomorrow, would you still be able to do the work and defend the answer? That question does not stop being relevant once the integration works.
Where to go from here
- Build one small thing end to end and document it
- Publish it — the GitHub portfolio guide covers how
- Re-read your own policy every time the tooling changes
- Find people doing the same thing; the reference list below is a start
Part two
Where to practise
Reading about a request is not the same as making one. These APIs are open, free, and need no account, so you can send a real request in the next five minutes and see what comes back.
Open APIs
Practise on these first
No key, no sign-up, no way to break anything. Paste a URL in a browser and read the JSON.
Learning hubs
When you want the long version
Documentation and courses that go deeper than 90 minutes can, from the people who build the tools.
Communities
When you are stuck
Somebody has almost certainly hit your error before and written down what it was.
Part three
Quick reference
The three things you will look up constantly for the first month: what a number in a response means, what a common error is really telling you, and whether your JSON is valid.
Status codes
Every response carries one. The first digit is the summary: 2xx worked, 4xx is something about your request, 5xx is something about their server.
| Code | Meaning | What to do |
|---|---|---|
200 | Success | Nothing. It worked. |
201 | Created | Your POST worked and something new exists. |
204 | No content | It worked; there is simply nothing to send back. |
400 | Bad request | Check your parameters — usually a typo or a missing field. |
401 | Unauthorized | Check your key. It is missing, wrong, or expired. |
403 | Forbidden | The key is fine; the account is not allowed to do this. |
404 | Not found | Check the endpoint URL against the documentation. |
429 | Too many requests | You hit a rate limit. Slow down and retry after a wait. |
500 | Server error | Not your fault. Retry, then report it if it persists. |
503 | Service unavailable | Their server is overwhelmed or down. Wait. |
Common errors, and what they usually mean
| Error | Usual fix |
|---|---|
| Invalid API key | Regenerate it and copy it whole — a truncated key looks like a wrong one. |
| Rate limit exceeded | Wait, then send fewer requests. Batch them if the API allows it. |
| Malformed JSON | Check brackets, commas, and quotes. A trailing comma is the usual culprit. |
| Endpoint not found | Read the documentation. Endpoints move between API versions. |
| Missing required parameter | The documentation lists what is required; add the one it names. |
| CORS error | A browser restriction, not an API fault. Use an API client such as Postman instead. |
JSON in one screen
Almost every API answers in JSON, and almost every JSON problem is punctuation. Here is every type you will meet, in one object.
{
"string": "text in quotes",
"number": 42,
"decimal": 3.14,
"boolean": true,
"null_value": null,
"array": [1, 2, 3],
"nested_object": {
"inner_key": "inner_value"
}
}
Four rules and a checker.
- Every key is in double quotes.
- Every string value is in double quotes.
- Numbers,
true,false, andnulltake no quotes. - No trailing comma after the last item — this is the error you will make most.
- When in doubt, paste it into jsonlint.com (opens in a new tab) rather than staring at it.
After the course
Put the work somewhere people can see it
A finished integration nobody can find does nothing for you. The GitHub portfolio guide is the companion to this course: eighteen short parts, no coding, from creating an account to a thirty-day plan for a profile worth linking to.
Robert Crown Law Library · last reviewed August 2026.