Programming with Wantzel: web and AI
The second block of the course. You build for the web: your own web server, JSON, a REST API and MCP tools that an AI assistant can call.
It builds on the basics. Every lesson ends with something you can open in a browser or connect to an AI assistant.

The lessons

Lesson 051 · JSON, the language of the web
6:29
You build a weather app that reads and writes JSON using Wantzel's schema keyword, learning how JSON powers web communication. The compiler generates type-safe readers and writers automatically, keeping your parser and formatter in sync while protecting against malformed data.

Lesson 052 · Your own web server
4:55
Build your own web server that listens for requests, tracks visitor counts, and serves responses. You'll learn how the http library handles the waiting, then write a simple counter that remembers visitors across requests. A working server in just sixteen lines.

Lesson 053 · An API in minutes
4:18
You discover that an API is a door for programs to exchange data through JSON. By declaring input and output schemas and one simple tool, the compiler automatically generates the API structure, validation, and JSON responses. You build a working temperature conversion API in just sixteen lines of code.

Lesson 054 · AI-ready: tools for an AI agent
4:52
You'll build a pizza tool that AI assistants can call using the MCP standard. Learn how assistants request your tools through JSON messages and how Wantzel's type system protects your code from errors. You'll see how a single declaration can serve both web APIs and AI assistants with the same interface.

Lesson 055 · Let an AI write Wantzel
5:27
Watch an AI learn Wantzel by making mistakes and reading error messages. Through three examples, you see how the compiler's strict, verbose feedback helps both AIs and humans fix code quickly. Then you make the same mistakes on purpose to learn how to read compiler messages.

Lesson 056 · Fetching a web page
6:39
Learn how web clients work by building an uptime checker. You'll write a program that connects to servers, sends HTTP GET requests, and reads the response status to determine whether a site is online. Discover the four steps behind every web fetch your browser performs.

Lesson 057 · Calling a real API
6:03
You build a program that calls the Open-Meteo weather API and extracts temperature, wind speed, and weather conditions from the JSON response. Learn how API calls work and how to parse JSON by finding specific fields. Using lookup, you navigate response structures without manual parsing.

Lesson 058 · Sending data
6:08
You build your first POST request to send data to an API. Learn how HTTP headers work, calculate the exact content length, and format JSON in the request body. Then parse the server's response and verify your message arrived correctly.

Lesson 059 · When the network says no
5:38
You build a program that fetches data over the network and responds to failures. Learn to check each response, retry only when failure might be temporary, and wait with increasing delays between attempts. Discover why distinguishing temporary from permanent failures matters, and how patient backoff respects busy servers.

Lesson 060 · Command-line tools that fetch
6:08
You build a command-line exchange rate converter that reads an amount from the command line and prints a formatted table of conversions. Learn to parse arguments with argc and argstr, align numbers in columns with proper padding, and use integer arithmetic to handle currency conversions without floating-point errors.

Lesson 061 · Schemas for nested data
5:37
You build schemas for nested JSON data by declaring one object inside another. Learn how the Wantzel compiler automatically parses multiple levels, then access nested values using dot and bracket notation. Through a recipe example with oven settings and ingredients, you see how paths match the JSON structure.

Lesson 062 · Writing JSON
4:55
Learn to produce JSON output from your programs. You build a to-do list as JSON objects in a buffer, handling strings safely and avoiding common mistakes like trailing commas. The lesson shows how to write formatted data that other programs can read, then save it to a file.

Lesson 063 · Validating input
5:51
You build a strict sign-up form checker that validates JSON data on three criteria: required fields, correct types, and sensible values. Learn how to check systematically, write helpful error messages, and use Wantzel's kind system instead of comparing text. The lesson shows why string comparison fails and how thorough validation helps users fix problems quickly.

Lesson 064 · Big JSON files
6:22
You build a reader for large JSON files that processes data in small chunks instead of loading everything at once. Working with step count data across years, you learn to handle numbers split across chunk boundaries and calculate statistics.

Lesson 065 · Config files
7:08
You build a game that reads its settings from a config file instead of hardcoding them. Learn how to parse JSON configuration, provide sensible defaults when values are missing, and handle missing files gracefully. This keeps your program robust even when a player misconfigures their game.

Lesson 066 · Routes
5:09
You build Puck's pie shop web server that handles three different URL paths and returns 404 for unknown requests. You learn to compare URL paths character by character, chain conditional statements to direct traffic to the right page, and understand why exact matching is essential.

Lesson 067 · Serving files
5:52
You build a server that serves static files like HTML and images from a folder. Learn how file types work, how to convert browser requests into file paths, and how to keep your files secure. Your homepage, stylesheet, and images load in the browser.

Lesson 068 · A real web server
5:32
You build a web server that listens on port 8068, handles GET requests to different paths, and serves responses in text or HTML. Learn how servers work by writing request handlers, using routes to match paths, setting status codes, and testing with curl and a browser.

Lesson 069 · Forms
6:39
Build an HTML form that sends a POST request to your Wantzel server. Read the request body using its Content-Length, decode the submitted fields, and include them in the response. You will see what the browser sends when someone fills in a form and presses the button.

Lesson 070 · Remembering things
5:38
Give your server a memory that survives a restart. Write guestbook entries to a file, read them back when the server starts, and count the saved lines. The lesson shows the difference between data held in a running program and data stored on disk.

Lesson 071 · Query parameters
5:53
You learn how query parameters work in URLs by building a search page on your own server. Extract the query string from incoming requests, decode special characters, and respond to what the visitor asked. With just the path and parameters, your page changes its answer.

Lesson 072 · Cookies and simple sessions
6:23
Teach a web server to recognize a returning visitor with cookies. Send a Set-Cookie header, let the browser keep the note, and read it on the next request. Then see why a real session uses a random identifier that points to server-side data.

Lesson 073 · Logging requests
5:33
Record each successful page request in an append-only log file. Keep the path and add each new visit without overwriting earlier lines, then use a second program to count the entries. You will also skip missing pages and see why a file is useful after a restart.

Lesson 074 · What REST is
5:48
You plan a REST API by treating each URL as a resource and each request as an action. Map a collection endpoint and an individual item endpoint for a to-do list, then print the plan before building the server. The lesson introduces the resource paths and response ideas that later routes will use.

Lesson 075 · An API from a schema
5:54
Describe a data record once in a schema, then use it to read incoming JSON and write a response. Add the schema to a web server and see how the same field names work in both directions, without hand-writing a JSON parser and writer.

Lesson 076 · Create, read, update, delete
6:17
You implement create, read, update, and delete routes for a contact card through the API. Track whether the card exists, use POST actions to change it, and return JSON or a 404 response. Then send requests with curl so you can see each operation affect the contact.

Lesson 077 · Errors in an API
6:31
You give API failures clear HTTP status codes and a short JSON detail message. Distinguish client errors from server errors, handle unknown routes with a 404, and use curl to inspect both the body and status. Programs can branch on the code while people can read the explanation.

Lesson 078 · Testing your API
6:45
Write a Wantzel program that starts an API, sends it a request, and checks the response status. Use a socket to call the running server and make the program exit with an error when the result differs from what you expected.

Lesson 079 · API keys
5:21
You add a guard to a small notes API so requests need an X-Api-Key header before they can reach the notes route. Test the difference between an unauthenticated request, a request with a key, and an unknown path, then see why checking the key before handling routes matters.

Lesson 080 · Documenting an API
6:07
Make an API understandable to other programs by serving an OpenAPI document. Describe its paths, methods, summaries, title, and version, then rename a route and update the document from the same constants that define the server.

Lesson 081 · Planning the app
5:51
Plan a small reading-list app before writing it. Sketch the pages, decide what one book contains, and map each address and HTTP method to its job. The plan gives the following lessons a clear structure for the website, data, and API.

Lesson 082 · The data layer
5:52
Build the data layer for a reading-list app: define a book record, store records in a file, and add routines to load and save them. This shared shelf becomes the source of truth for the website, API, and assistant tools in the lessons ahead.

Lesson 083 · Pages and forms
6:25
You build a browser-based reading list with forms that add and edit books in fixed slots. A route reads the title and slot number from the request, validates the slot, and writes the change. Finish with a redirect after saving so refreshing the page does not submit the same change again.

Lesson 084 · Search and sort
5:50
Add search and sorting to the reading-list data. Filter books using a query and arrange the results in a useful order, while keeping the underlying records intact. The lesson turns a basic collection into data people can find and inspect.

Lesson 085 · A JSON API next to the pages
7:09
You serve the same reading list in two formats: HTML for people and JSON for programs. A single shelf of book titles feeds both routes, with the right content type and clean errors. Add a book once and both views update, avoiding the mismatch that comes from keeping duplicate lists.

Lesson 086 · Putting it online
7:19
Put your reading-list server on your local network so a phone can open it. Bind the server to the network interface, use the right port, and restart it after changes. You will see why localhost only works on the computer running the server.

Lesson 087 · What MCP is
6:55
Meet MCP, the Model Context Protocol, and see how it lets an assistant discover and call tools exposed by a server. The lesson introduces the parts of the exchange and prepares a simple Wantzel program to offer its first tool.

Lesson 088 · Tools from declarations
6:34
Declare a tool in Wantzel and let the compiler generate the protocol details around it. Define its name, input schema, and handler, then send a tool call and inspect the response. This shows how a declaration becomes an assistant-ready capability.

Lesson 089 · Tools over your data
6:38
Expose useful information from your app as read-only MCP tools. Give each tool a clear name and arguments, connect its handler to the shared data, and call it through the server. An assistant can then look up records without changing them.

Lesson 090 · Tools that change things
5:55
Create MCP tools that change your app's data. Declare the inputs, implement handlers that add or update records, and return a clear result to the caller. You will see the difference between asking a tool for information and asking it to make a change.

Lesson 091 · Safe tools
6:28
Make assistant tools safer by designing their names, arguments, and effects clearly. Validate inputs, prefer read-only access where possible, and make changes explicit in the tool description and response. The examples show practical safeguards before an assistant acts on data.

Lesson 092 · Connecting to an assistant
7:00
Connect the MCP server to an assistant and make a real tool call. Configure the connection, let the assistant discover the available tool, and follow the request and response back to Wantzel. This lesson joins the protocol and tool declarations into a working interaction.

Lesson 093 · Many tools, one server
6:23
Put several related MCP tools behind one server. Group their names by family, describe each argument, and share schemas while keeping one connection and one port. The lesson shows how a toolbox can grow without turning into a collection of separate servers.

Lesson 094 · The plan
5:47
Plan one reading-list app with three ways in: a website for people, a JSON API for programs, and MCP tools for an assistant. Decide what each door does and put one shared store behind them, then map the next steps before implementation.

Lesson 095 · Shared data
5:42
Build one shared store that the website, API, and MCP tools can all use. Define the book data, read and write it on disk, and route each interface through the same shelf. A change made through one door will be visible through the others.

Lesson 096 · The website
7:37
Build a website on top of the shared reading-list store. Add pages to list books and forms to add or mark them as read, using GET to display and POST to change data. A redirect after submission returns the browser to the updated list.

Lesson 097 · The API
7:10
Build a REST API over the same reading-list data. Add routes to list, find, and create books, return JSON with useful status codes, and keep unknown paths at 404. Then add a count endpoint and check it with curl.

Lesson 098 · The AI tools
6:55
Expose the reading-list store through MCP tools for an assistant. Declare a tool that adds a book, connect its handler to the shared table, and inspect the generated schema and dispatch code. The assistant can use the same data as the website and API.

Lesson 099 · Testing everything
5:30
Run one program that checks the shared data routines, website, API, and MCP tool together. Start the services, send requests through each interface, and make the exit code report whether everything passed. You will see how a small regression check catches a broken door.

Lesson 100 · What's next
5:39
Review the hundred-lesson path from Wantzel programs and persistent data to a website, API, and assistant tools. Run small checks that write and read data, then look at the next block: uploading a file, sharing a secret link, and removing it afterward.
- The whole playlist on YouTube50 videos.