Due Date: Sat. 9/19 at 8:00 PM
Time Estimate: up to about 6 hours
Deliverables: Code, README, and key prompts uploaded to GitHub + short video + 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
- GitHub repository: Place the following items in either a new Github repo or (if adding a feature to your website) update the repo for your website to include the code and necessary information.
- Code: A python script, game, small web app, or an added feature to your portfolio website that fetches data from the chosen API and does something interesting or interactive with it. We recommend making a python app, but you may use javascript or another language if you wish. (Information can be displayed as console output, simple app or HTML page, or embedded widget on your website).
- README: In the repo README, include 3–5 sentences that explain (at a high level) how the API is called (for example, what modules are used if any, what key parameters are provided, and what format / data types are returned). If your code requires an API key or other authentication, provide information on how to obtain and use that API key (WITHOUT exposing the key itself in the repo). Also include brief instructions for running your code: what to install, and what command or file to run.
- Prompt log: A short note (in README or a separate file like prompt_log.md) listing which AI model(s)/tool(s) you used and the key prompts that shaped the implementation (not the necessarily the entire chat dump, just the prompts you found most important).
- Portfolio: Add your project to your portfolio. (Note: If you have a good reason to not want your submission on your portfolio, email Mike before the deadline, but we hope you will make something cool.)
- Video: Make a short video that shows what you've created. This can be very short, but it should contain enough information for us to grade your work if we can't easily run it ourselves. You should submit a link to this video (either a Youtube link or a Google Drive link, with permissions set so that anyone with the link can view it) to the form below. Note: We aren't looking for top production quality here (though of course if you're proud of your video, you might find it useful for your portfolio).
- Google form: Fill out this google form, which asks for some basic information on how to find your project, along with a link to your video (make sure we can view it by testing your Youtube or Google Drive link in an incognito window). Be sure to fill this out by the due date!
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!) One trap to avoid: if your API requires a key, don't call it directly from JavaScript running in the browser. Any key in front-end code is visible to every visitor who opens the developer tools, no matter how you store it. Use Python for a keyed API, or choose a keyless API if you want the project running live on your portfolio. (Doing this properly requires a backend, which we'll explore in a later assignment.) If you do accidentally commit a key, deleting it in a later commit is not enough, because it's still in your repository's history. Go to whoever issued the key, revoke or regenerate it immediately, and then let us know. Doing that promptly is the right professional response and won't be held against you.
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.
- For full points (100/100) we're looking to see evidence of about 5 to 6 hours of thoughtful and exploratory effort, with the requisite components listed above. We'll expect some interactivity and creativity here.
- For a passing C grade (70/100) we would expect a simple script that makes an API call and displays the information in a simple, non-interactive way.
- On Wednesday 9/16 we'll create a small app in class, and we'll let you know what grade this would receive as an additional gauge for your progress.
- If you're approaching 6 hours without something working, scale down or pivot rather than pushing on. Get one simple call working, share in your README what you were attempting and where it broke, and submit that.
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
- Choose a public API you find interesting (preferably free or with a free tier).
- 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.
- 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.
- 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.)
- Try to break it. Test a misspelled or empty input, a search that returns no results, and a request that fails (turn your wifi off for a moment). Your app should say something useful rather than crashing with a traceback.
- Write a short README and prompt log as described above and include these in your repo.
- Push your code to a public GitHub repo.
- Make your video and upload it, and fill out the Google submission form before the deadline
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.
- Endpoint: A specific URL you request to get or send data (for example, /weather).
- Request: The HTTP call your code makes (includes method like GET/POST, headers, and parameters).
- Response: The data the API returns (often JSON) and an HTTP status code.
- Status code: A number describing what happened. 200 means success, 401 usually means your key is missing or wrong, 404 means the thing you asked for doesn't exist, and 429 means you've hit the rate limit.
- JSON: A common text format for API responses (JavaScript Object Notation). The JSON format looks a little like a nested dictionary, with keys and values.
- Authentication / API key: A secret token (e.g. a string of letters and numbers) some APIs require to identify you. Never commit keys to a public repo.
- Rate limit: A limit on how many requests you can make in a time period.
- Query parameter: Extra data appended to a URL to modify the request (for example, ?city=Pittsburgh).
- REST: A common API style that uses HTTP verbs and endpoints to operate on resources.
- Wrappers: Helper functions and classes that implement the HTTP requests behind the scenes, and allow you to use the APIs more easily. These can be very convenient!
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
- Start small: Fetch one endpoint and display a few fields; you can extend if time allows.
- Look at the raw response first: Before you build anything around the data, make one successful call and print the entire response. Most confusion about API code comes from guessing at the shape of the data instead of looking at it.
- Check rate limits: Use APIs with reasonable limits for development or use sample/demo keys if provided. Also, make sure your code does not make more calls than it needs to! For example, if you have a loop in Python that constantly calls the API, you can hit your rate limit almost instantly. Or, for paid APIs, you might accidentally rack up a very large bill... for this reason, we strongly recommend not using APIs that you have to pay for in this assignment.
- Hide keys: Put keys in environment variables or a file named config.local (and add it to .gitignore). In README show how to set the env var. See GitHub's guide on ignoring files: https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
- Find cool APIs here: See these curated lists of public APIs and Python wrappers:
- Ask AI to explain: After getting code from an AI model, ask it to annotate or explain each function or request so you can demonstrate understanding.
- Verify that the endpoint actually exists: AI models will sometimes invent plausible-looking endpoints or parameters for a real API. The code looks perfectly reasonable, and then the request comes back 404. When something doesn't work, check the real documentation before asking the model to try again.
- Use the documentation: APIs typically have extensive documentation online. This documentation can be dense, but we strongly recommend you read the basics, even if AI seems to be giving you something that "just works." Also, many API docs include sample requests. Use them as a starting point when prompting the model.
- You may wish to use some supporting modules and libraries (like pygame or matplotlib if you're making your submission in python). This is a-ok! Note that pygame and matplotlib and most other modules are not APIs, but they can be helpful in adding visualization and interactivity to your app. Ask us if you need help finding resources and documentation for these modules.
Questions? Ask on Ed, attend office hours, or email the instructor. Consult the course AI usage and collaboration policies on the course homepage.