Skip to content

Instantly share code, notes, and snippets.

@kalisjoshua
Last active May 29, 2018 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalisjoshua/1c8d0faf0b02e30f874241789d5090d4 to your computer and use it in GitHub Desktop.
Save kalisjoshua/1c8d0faf0b02e30f874241789d5090d4 to your computer and use it in GitHub Desktop.
Hypermedia Adventure

Hypermedia Adventure

This will be an adventure in navigating a Hypermedia API. This API will illustrate API standards that should be followed in all APIs.

  1. Where to begin?
    • GET /
    • (non-authenticated)
    • Perform a simple GET request to get a list of available API resources.
    • This resource will always be available - authenticated or not - and will always return a resource. The resource returned will also optionally include links to resources that are available. Following links is what the web is ALL about. There are different types of links: resources, informational (status), meta (schema), etc.
    • [Next Step]
      • Create a session token to make authenticated requests:
      • POST /session-tokens
  2. Start a session.
    • POST /session-tokens
    • (non-authenticated)
    • Now that you have a session token you will be able to make authenticated requests to the API which means more resources will be available to you.
    • [Next Step]
      • Make your original request; using HTTP Basic Authorization (header)
      • GET /
        • Authorization: Basic <session-token>
  3. A new beginning.
    • GET /
    • Great! You've made your first authenticated request to this API. HTTP Basic auth is hardly the most secure but it will suffice for our needs. Continue supplying this HTTP header for all requests going forward.
    • A new link is available to you now, identified by the link relation (rel) "collection". Don't worry about the URL, it's randomized so it is only available to you and will only be usable once.
    • [Next Step]
      • Follow the link for the the "collection".
  4. What's available now?
    • GET /<adjective>-<noun>s
    • RESTful APIs have two types of resources and the first of those is the collection type; which is what this is. Collections are groups of like resources. Collections have some meta-functionality to make them more accessible, such functionality are: paging and filtering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment