You need A terminal with curl, and Node 22.13 or later (Node 24 LTS recommended).
Check your tools, and curl on Windows
Run curl --version and node --version. macOS and Linux include curl; Windows 10 and 11 do too, as curl.exe. Node comes from nodejs.org; if node --version prints something older than v22.13.0, install the current LTS. Lesson 2.3.5 needs the same version.
In Windows PowerShell, curl on its own can run PowerShell's Invoke-WebRequest instead of the real curl, so type curl.exe everywhere this lesson says curl. Where quoting differs too, the step has a Windows tab.
Call a public API
GitHub's API describes any public repository, no key needed:
curl https://api.github.com/repos/computesphere-samples/learnFind
private,visibilityanddefault_branchin the response too. Without a key, GitHub allows 60 calls an hour from your address, which is plenty here.You should seea JSON object, including "full_name": "computesphere-samples/learn" and "description": "Lab apps and starter code for ComputeSphere Learn."
Read the status line and headers
curl -I https://api.github.com/repos/computesphere-samples/learnx-ratelimit-remainingcounts down with each call.You should seeHTTP/2 200, content-type: application/json; charset=utf-8, and x-ratelimit-limit: 60.
Get the notes API and start it
git clone https://github.com/computesphere-samples/learn.git cd learn/labs/local-api node server.jsIt's one file with no dependencies. Leave this terminal running and open a second one for the next steps.
No git? Other ports?
Download https://github.com/computesphere-samples/learn/archive/refs/heads/main.zip instead, unzip it, and open
learn-main/labs/local-apiin a terminal.If port 3000 is taken, start it with
PORT=3001 node server.js(PowerShell:$env:PORT=3001; node server.js) and use 3001 below.You should seeNotes API on http://localhost:3000
List the notes
curl -i http://localhost:3000/notes-iprints the status line and headers above the body.You should seeHTTP/1.1 200 OK, Content-Type: application/json, and [{"id":1,"text":"Buy milk"}] after the headers.
Create a note
-Hadds a header and-dsends a body, which also makes the request a POST.curl -i http://localhost:3000/notes -H "Content-Type: application/json" -d '{"text":"Call the bank"}'PowerShell can strip the double quotes inside JSON on the way to curl, so put the body in a file and send the file:
Set-Content note.json '{"text":"Call the bank"}' curl.exe -i http://localhost:3000/notes -H "Content-Type: application/json" -d "@note.json"Run step 4 again and both notes are there.
You should seeHTTP/1.1 201 Created and {"id":2,"text":"Call the bank"}
Get two errors on purpose
Send a note with no text, then ask for a note that doesn't exist:
curl -i http://localhost:3000/notes -H "Content-Type: application/json" -d "{}" curl -i http://localhost:3000/notes/99Check yourself
You should seeHTTP/1.1 400 Bad Request with {"error":"A note needs a non-empty \"text\" field"}, then HTTP/1.1 404 Not Found with {"error":"No note with that id"}.
Stop the server
Press Ctrl+C in the first terminal. The notes live in memory, so the next start begins with just "Buy milk" again.
You should seeyour prompt again in the first terminal.