HW3: Explore an API

CMU 15-113: Effective Coding with AI

Due Date: Sat. 2/7 at 8:00 PM
Time Estimate: 2–3 hours
Deliverables: Code, README, and key prompts uploaded to GitHub + brief form response

Assignment Overview

Goal: Use AI tools to explore and integrate a public API of your choice into a small but interesting app, or you may add an API-related feature on your portfolio website. The goal is hands-on experience with how APIs work, how to call them from code, and how to read and discuss the resulting code.

Why This Matters: APIs are how many external data sources and services are accessed. This assignment teaches you to find a suitable API, design a small integration, and use AI to help implement and understand the code.

Examples of APIs you might use: weather, stock prices, random quotes, public transport schedules, open datasets, and other public endpoints.

Requirements & Scoring

What You Must Submit

Privacy note: Do not commit API keys, credentials, or other secrets to GitHub. If the API requires a key, use environment variables or a local text file or config file excluded via .gitignore, and explain in the README how to provide the key locally. See the Tips section below for advice on how to set up a .gitignore file. Security is important, and you will receive a zero if your repository contains a private key that should not be exposed. (Ask on Ed if you aren't sure if something is a private key or not!)



Grading

Prioritize a thoughtful implementation that does something interesting and more complex than just getting and printing data, and make your supporting documents clear and explanatory. The assignment is intentionally open-ended.

As with Crossy Road, by default we will expect that you'll post the result on your portfolio, though you may request to be exempt from this requirement if you email Mike with a good reason before the deadline. Be creative! You may wish to use this as a start to a larger project. Regardless, first focus on a working, clean implementation of the API and then wrap an experience around it.

Detailed Instructions

  1. Choose a public API you find interesting (preferably free or with a free tier).
  2. Decide on a small scope: fetch and display current data (e.g., current weather for a city), or fetch and show a list (e.g., latest quotes), or perhaps a plot (e.g. for stock data or recent temperatures), or add a small dynamic widget to your portfolio. You should choose something that can do more than just return the same data every time, e.g. you should fetch recent data, or you should allow the user to specify some parameters for the information they wish to retrieve.
  3. Use AI tools to help learn how the API works and to generate some code. As always, be explicit in your prompts so that you get results that align with your goals.
  4. Implement the code and test it locally. Remember, keep API keys and other secrets out of the repo — use environment variables or a local text file or config file excluded from version control. See below for instructions on setting up a .gitignore if needed. (This is only relevant if your API requires authentication or a secret key.)
  5. Write a short README and prompt log as described above and include these in your repo.
  6. Push your code to a public GitHub repo.
  7. Fill out the Google form before the deadline (Form to be posted soon!)

What is an API?

An API (Application Programming Interface) is a set of rules that lets programs talk to each other. Many web APIs provide data over the network via HTTP requests. You may also find and use Python modules that provide helper functions for specific APIs.Below are a few short definitions you may find useful as you work on this assignment.

When you use AI to generate API code, ask the model to show sample requests and explain each field in the response so you can verify you understand how the API works.

Tips

Questions? Ask on Ed, attend office hours, or email the instructor. Consult the course AI usage and collaboration policies on the course homepage.