Due: Tuesday, 11/3/26, before class.
For this assignment, you'll get data from an API and then do something interesting with it using a front-end library. What "interesting" means is up to you: a chart that compares things in a way that tells you something, a p5.js sketch where the data becomes the characters, sizes, and colors of a drawing, an animation, even a small game.
The main thing I'm looking for is that the library is working with the data you fetched, so that the data is what decides what shows up on the page. For example, a chart built from numbers you typed in yourself, or a p5.js sketch that sits next to some text from an API without using it, would miss the point of the assignment.
You can pick any one of these. They're all free and don't need an API key or sign-up, and each name links to that API's documentation. Before you start writing code, it helps to open the URL in a browser tab and look at the JSON it sends back.
https://pokeapi.co/api/v2/pokemon/pikachudata.height, data.weight, and data.stats, an
array of six stats (hp, attack, defense, ...). Each one looks like
{ base_stat: 35, stat: { name: "hp" } }. Image:
data.sprites.front_default.https://ghibliapi.vercel.app/filmsrelease_date, running_time, rt_score (Rotten
Tomatoes score). Also title, director, and image.https://swapi.dev/api/people/ (all, in data.results) or
https://swapi.dev/api/people/1/ (just one)height (cm), mass (kg). Also name,
eye_color, hair_color.https://dogapi.dog/api/v2/breedsdata.data, with everything inside attributes:
attributes.name, attributes.life.max,
attributes.male_weight.max, and 1–5 scores like
attributes.traits.energy and attributes.traits.barking.https://hp-api.onrender.com/api/charactersname, house, yearOfBirth, image.
Not many numbers, so you'll count things yourself.If you'd like to use a different API, check with me first. It needs to work without a key, and some APIs block requests from web pages, so it's worth making sure it'll work before you build on it.
p5.js and Chart.js are the recommended ones, and they're what we use in class.
<script> tag and it's the part that makes your use of the
data interesting (for example, Leaflet for maps or
Tone.js for sound). A library that only adds decoration
wouldn't be enough on its own.
<script> tag, before your own script.js. For p5.js
and Chart.js, use these exact versions so your code matches the docs and the class demos:
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.5.1/dist/chart.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5@2.3.4/lib/p5.min.js"></script>
fetch with async/await to get data from one of the
APIs in Data Sources above.
<select>, buttons, a text box) that makes a new
request and updates the visualization without reloading the page. For example: a different
Pokémon, a different character, the next page of dog breeds.
console.log(data) and expanding it in DevTools, saves a lot of time. Most bugs here
come from a wrong guess at the path to a value (data.name when it's really data.data[0].attributes.name).
"height": "172". You'll need Number() before doing math with them.
await only works inside an async function. Outside
one, you'll get "SyntaxError: await is only valid in async functions" and none of your script
will run.
preload(), which doesn't exist in version 2. In p5.js 2, you can make
setup an async function and await your data inside it
instead. p5 waits for
setup to finish before it starts calling draw.
draw(). draw() runs about 60 times a
second, so a fetch in there sends 60 requests a second. Fetching in setup, or when a
control is used, avoids that.
new Chart(...), and then when new data arrives, change
chart.data and call chart.update().
Same rules as before: folder and file names must match exactly. Your files go in a new
06-api-visualization folder:
csc336-fall2026/
└── assignments/
└── 06-api-visualization/
├── index.html
├── style.css
└── script.js
Once pushed, your assignment will be visible at:
https://<your-username>.github.io/csc336-fall2026/assignments/06-api-visualization/
Do not use ChatGPT, Copilot, Claude, or any other generative AI tool to write any part of this assignment. Whatever you do, remember that your goal should be to understand 100% of the code that you turn in.
Nothing to submit directly. Your assignment should be publicly available at the address in File and Folder Setup above once you've committed and pushed.