Skip to content

Files

Latest commit

bac2b59 · Mar 10, 2025

History

History
68 lines (47 loc) · 2.55 KB

lab_04.md

File metadata and controls

68 lines (47 loc) · 2.55 KB

Lab 4

Objective: Better understand APIs by building one


The task

You will build an API using Flask. Example APIs:

We will be practicing pair programming and documentation-driven development. You'll get as far as you can during the Lab session, then continue the rest outside.


Steps

Setup

  1. Pair up with someone who isn't on your project team.
    • This will be known as your "Lab group". Subsequent Labs will use the same people, repository, and dataset.
  2. Pick a dataset that has unique identifiers for each row.
    • You can use a dataset from one of your projects, or pick a different one.
    • You'll use a CSV as the data source to power your API.
    • Don't spend too long on this step.
  3. Create a public repository in the advanced-computing organization.
    • Call it something like [name1]-[name2]-api.
    • Make sure to grant collaborator access to your partner.
  4. Create a README that will describe how to use your forthcoming API.

Build

For each step, you will:

  1. Document the functionality. Include:
    • Options, if applicable
    • Sample output
  2. Build it.
  3. Test it.

The documentation is a starting place; you can add/modify as you go.

For inspiration, check out the example.


Suggested order

Allow the user to:

  1. List records
    • You can start with CSV or JSON output; you will implement the other later.
    • Hints
      • See to_csv() and to_json().
      • "If [the path is] None, the result is returned as a string."
  2. Filter the data based on a particular column, such as age=30
  3. Specify a limit and offset
  4. Retrieve a single record by identifier
  5. Specify the output format (CSV or JSON)

Submit via CourseWorks.