View on GitHub

NEH Institute materials

July 2022

Home | Call | Admin | Week 1 | Week 2 | References | Slides | App development

Verbs and nouns in the pr-app API

Preliminary

  1. The eXist-db controller is a type of API.
  2. This Institute activity focuses on human interactions with the eXist-db controller in a web browser (that is, on how the URL in the browser address bar is processed).
  3. There are other ways that users (and machines) interact with APIs:
    • Mapbox server (Gabi’s geo presentation)
    • IIIF server interactions (Jeffrey’s upcoming IIIF guest lecture)

Conclusion

  1. Think about project goals, services, and resources.
  2. Some choices are equally useful.
  3. Document your decisions—especially for your future self.

Preliminaries

CRUD

(Based partially on: https://nordicapis.com/crud-vs-rest-whats-the-difference/)

CRUD HTTP
Create Post/Put
Read Get/Post
Update Post/Put/Patch
Delete Delete

HTTP supports other interactions, e.g., Hugh used the GitHub API in the TEI repos to create a new Git branch.

pr-app requires only Read, which we implement only with Get.

Human or machine?

API guides often focus on metadata and discovery, with endpoints (URIs) to learn about the site or project structure and resources. HATEOS (Hypermedia as the Engine of Application State, a REST constraint) supplies link relations that can guide subsequent queries (example at Wikipedia). pr-app prioritizes human interaction and human-oriented modes of discovery.

Human-readable URL?

Issues

Order of components: noun first or verb first

pr-app is verb first:

Singleton and collection

pr-app omits the plurals. We do not expose subcollections, although we could (hoax_xml vs aux_xml).

Path components or parameters for resource identifiers

pr-app uses parameters:

Filtered search in pr-app:

http://localhost:8080/exist/apps/pr-app/search?term=&publishers%5B%5D=Leader%2C+The&month-years%5B%5D=1853-07

HTTP status codes

HTTP servers return a numerical code for each request, such as:

eXist-db has its own HTTP server (Jetty). When we ask for an article that doesn’t exist, Jetty returns successfully (200) and we handle the error ourselves, but from the user perspective the resource was not found (404). How much do we care?

Composite pages

With side-by-side image and transcription, each is a resource. What should the URL look like?

For more information

REST API tutorial