Bash + jq for API development & testing

Acknowledgements

Big shout out to Dandre for putting me onto this.

Examples

#! /bin/bash

curl -X POST https://openapi.guidefari.dev.goosebumps.fm/spotify/playlist \
  -H "Content-Type: application/json" \
  -d '{"id": "1QWp1dZFkp1FR9e4w0THxW"}' | jq .

Testing input/output at a glance

So far, this is the main thing I’m using this workflow for. Rapid validation of input & output of endpoints as I develop.

Why not any of the GUI clients?

I also use

  • Postman
  • Insomnia
  • Thunder client in VSC*de ⌘ + shift + R

Shortcomings of the GUI apps : GUI’s come with lots of noise, visual clutter, distractions, things that slow me down because I have to learn the tool. What happens when I spend a week or two mostly on client side work? I kind of forget how to quickly move around these tools.

  • I don’t have that feeling with bash.
  • I like the portability & version controlled nature of bash scripts
  • It’s very quick for me to open my terminal and hop around to the correct window. option + / takes me into the terminal.

What to learn next

I want to figure out how to do assertions and eventually, actual test runs.