Assignment 2: Git + API Exploration#

Course: 06-643 Scientific Software Engineering with AI Coding Agents

Topics covered: L02 (Git and Version Control), L03 (Working with APIs)

In this assignment you will practice core git workflows and use an AI coding agent to build functions that query the OpenAlex API for academic publication data. The assignment has two components: a technical component (Parts 1-3) and a reflection (Part 4).

Part 1: Git Workflow#

Create a new Git repository for a project called scholartools. Demonstrate a proper git workflow by doing the following:

  1. Initialize the repository with a README.md file (the README should briefly describe the project).

  2. Create a feature branch (e.g., feature/openalex-api).

  3. Make at least 3 meaningful commits with good commit messages following the Conventional Commits format (e.g., feat: add search_works function).

  4. Show your git log --oneline output after the commits.

Paste your terminal commands and their output in the cells below. Include the full sequence: git init, git add, git commit, git checkout -b, etc.

# Paste your git init and first commit commands/output here
# Example:
# $ mkdir scholartools && cd scholartools
# $ git init
# $ echo "# scholartools" > README.md
# $ git add README.md
# $ git commit -m "feat: initialize repo with README"
# Paste your feature branch creation and subsequent commits here
# Example:
# $ git checkout -b feature/openalex-api
# $ git add api.py
# $ git commit -m "feat: add search_works function"
# ...
# Paste your git log --oneline output here

Part 2: Working with the OpenAlex API#

Use an AI coding agent to help you build three functions that query the OpenAlex API. OpenAlex is a free, open catalog of the world’s scholarly research.

Before you start coding, practice context engineering: load the OpenAlex API documentation into your agent’s context so it understands the API structure, endpoints, and response formats. You can do this by pointing the agent at the docs URL, pasting relevant sections of the docs, or using any other technique from lecture.

Build the following functions:

  1. search_works(query, limit=10) — Search for academic papers matching query. Return a list of dictionaries, each containing the paper’s title, publication_year, and cited_by_count.

  2. get_author(name) — Look up an author by name. Return a dictionary with the author’s display_name, institution (most recent), works_count, and cited_by_count.

  3. get_citation_counts(work_ids) — Given a list of OpenAlex work IDs (e.g., ["W2741809807", "W1234567890"]), return a list of dictionaries with each work’s id, title, and cited_by_count.

Important: The OpenAlex API does not require authentication. The base URL is https://api.openalex.org/. You should add a polite email parameter to your requests (e.g., mailto=youremail@andrew.cmu.edu) as described in their documentation.

# Your code here: define the search_works function
# Your code here: demonstrate search_works with a real query
# Example: search_works("machine learning catalysis")
# Your code here: define the get_author function
# Your code here: demonstrate get_author with a real query
# Example: get_author("John Kitchin")
# Your code here: define the get_citation_counts function
# Your code here: demonstrate get_citation_counts with real work IDs
# Use work IDs you found from your search_works results above

Part 3: Commit Your Work#

Now add the API functions you wrote in Part 2 to your scholartools repository. Follow good git practices:

  1. Add each function (or logical group of changes) as a separate commit with a descriptive conventional commit message.

  2. Push to GitHub if you have an account. If not, that is fine — just show the local git log.

  3. Show the final output of git log --oneline --graph.

# Paste your commands for adding and committing the API functions here
# Example:
# $ git add scholartools.py
# $ git commit -m "feat: add search_works function for OpenAlex API"
# $ git commit -m "feat: add get_author function"
# $ git commit -m "feat: add get_citation_counts function"
# Paste your final git log --oneline --graph output here

Part 4: Reflection#

Answer the following questions in the markdown cell below. Write at least a few sentences for each.

  1. Context engineering: How did you use context engineering when working with the OpenAlex API? What information did you provide to the AI agent, and how did that affect the quality of the code it produced?

  2. Git mistakes: What git mistakes did you make (if any), and how did you fix them? If you did not make any mistakes, describe a scenario where something could go wrong and how you would recover.

  3. AI and understanding: How did the AI agent help (or hinder) your understanding of the OpenAlex API? Did you learn more or less than you would have by reading the docs yourself?

  4. What would you do differently? If you were starting this assignment over, what would you change about your approach?

Your reflection here.