A course on digital libraries and building digital collections.
View the Project on GitHub jawalsh/z652-Digital-Libraries-FA25
In this activity, you’ll:
An API (Application Programming Interface) lets one program request information or perform an action on another system.
When you use a web API, you:
Example:
https://api.open-meteo.com/v1/forecast
?latitude=39.1653
&longitude=-86.5264
&hourly=temperature_2m
Part | Meaning |
---|---|
Base URL | https://api.open-meteo.com/v1/forecast (the main API endpoint) |
Query Parameters | latitude , longitude , hourly (control the output) |
Response | JSON data showing forecast values |
Base: https://en.wikipedia.org/api/rest_v1/page/summary/
Try these URLs in your browser or with curl
:
Version | URL | What Changed? | What Did You Notice? |
---|---|---|---|
Original | https://en.wikipedia.org/api/rest_v1/page/summary/International_Image_Interoperability_Framework | ||
Variation 1 | https://en.wikipedia.org/api/rest_v1/page/summary/Albert_Camus | Changed article name | |
Variation 2 | https://en.wikipedia.org/api/rest_v1/page/html/Albert_Camus | Changed endpoint from “summary” to “html” | |
Variation 3 | https://en.wikipedia.org/api/rest_v1/page/summary/ThisArticleDoesNotExist | Invalid title |
Reflection:
Base: https://api.open-meteo.com/v1/forecast
Try each variation and observe the differences:
Version | URL | Parameters Added or Changed | Result or Observation |
---|---|---|---|
Original | https://api.open-meteo.com/v1/forecast?latitude=39.1653&longitude=-86.5264&hourly=temperature_2m | baseline | |
Variation 1 | https://api.open-meteo.com/v1/forecast?latitude=39.1653&longitude=-86.5264&hourly=temperature_2m,relative_humidity_2m | add second variable | |
Variation 2 | https://api.open-meteo.com/v1/forecast?latitude=48.8566&longitude=2.3522&hourly=temperature_2m | change location to Paris | |
Variation 3 | https://api.open-meteo.com/v1/forecast?latitude=39.1653&longitude=-86.5264&hourly=temperature_2m&timezone=America/New_York | add timezone |
Reflection:
Base: https://api.github.com/repos/UniversalViewer/universalviewer/releases
Version | URL | Parameter(s) | What Changed? |
---|---|---|---|
Original | https://api.github.com/repos/UniversalViewer/universalviewer/releases?per_page=3 | per_page=3 |
|
Variation 1 | https://api.github.com/repos/UniversalViewer/universalviewer/releases?per_page=5 | per_page=5 |
|
Variation 2 | https://api.github.com/repos/UniversalViewer/universalviewer/releases?per_page=3&page=2 | add page=2 |
|
Variation 3 | https://api.github.com/repos/IIIF/api/releases?per_page=3 | change repository |
Reflection:
per_page
and page
control how much data you see?Base: https://jsonplaceholder.typicode.com/todos
Version | Method | Example | Parameter Type | Observation |
---|---|---|---|---|
GET single record | Browser | https://jsonplaceholder.typicode.com/todos/1 | path | |
Filtered list | Browser | https://jsonplaceholder.typicode.com/todos?userId=2 | query | |
POST new record | Terminal | curl -s -X POST https://jsonplaceholder.typicode.com/posts -H "Content-Type: application/json" -d '{"title":"hello api","body":"this is a demo","userId":1}' |
body |
Reflection:
Base: https://api.nasa.gov/planetary/apod
This API returns information about NASA’s “Astronomy Picture of the Day.”
It’s free to use for small-scale demos — just include the public key api_key=DEMO_KEY
.
Version | URL | Parameters Used | What You Notice |
---|---|---|---|
JSON (default) | https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY | api_key=DEMO_KEY |
|
XML format | https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&format=xml | add format=xml |
|
JSON for a specific date | https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&date=2020-01-01 | add date=2020-01-01 |
|
XML for a specific date | https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&format=xml&date=2020-01-01 | add format=xml + date=2020-01-01 |
# JSON (default)
curl -s "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY"
# XML version
curl -s "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&format=xml"
# Specific date (e.g., Jan 1, 2020)
curl -s "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&format=xml&date=2020-01-01"
Format | What Does the Data Look Like? | How Are Fields Marked? |
---|---|---|
JSON | { "title": "...", "date": "...", "url": "..." } |
key:value pairs |
XML | <title>...</title> |
nested tags |
✅ Goal: Recognize that APIs can offer the same content in multiple data formats through parameters.
You’ve now seen JSON (structured for JavaScript and modern apps) and XML (widely used for metadata and archival interchange).
—
Base: https://www.loc.gov/
The Library of Congress exposes its collections and metadata through a public API—no key required!
Version | URL | Parameters Used | What You Notice |
---|---|---|---|
JSON (default) | https://www.loc.gov/collections/?q=comic+books&fo=json | q=comic+books , fo=json |
|
XML | https://www.loc.gov/collections/?q=comic+books&fo=xml | change fo to xml |
|
Limit results | https://www.loc.gov/collections/?q=comic+books&fo=json&c=3 | add c=3 |
|
Filter to photographs | https://www.loc.gov/collections/?q=indiana&fa=original-format:photograph&fo=json | add fa=original-format:photograph |
# JSON response
curl -s "https://www.loc.gov/collections/?q=comic+books&fo=json"
# XML response
curl -s "https://www.loc.gov/collections/?q=comic+books&fo=xml"
Format | What Does the Data Look Like? | How Are Fields Marked? |
---|---|---|
JSON | "title": "..." , "date": "..." |
key:value pairs |
XML | <title>...</title> |
nested tags |
✅ Goal: See how a real library API exposes collection metadata in both JSON and XML—perfect for connecting technical skills to digital-library practice.