News for hackers. Stuff that matters.
Re:Dealing with APIs, JSON and databases in org-mode by kreetx on Friday January 14, 2022 @05:48AM (#29932892)
I've mostly used bash source blocks (with curl, jq, awk etc) for this. OPs way is definitely more aesthetic but a bash cli seems more flexible.

Other than that, org-mode can also be your postman, but mixes well with your other notes. :)

Re:Dealing with APIs, JSON and databases in org-mode by xtiansimon on Friday January 14, 2022 @08:58AM (#29934445)
I’m a complete noob at api work. I could use the 20,000ft view. What are these components for a bash solution you describe? I know curl makes http requests, but what is this workflow? I’m frequently using tmux, vim and zsh, so your comment grabbed my attention, and I need to do this for a project that has something called OData.
Re:Dealing with APIs, JSON and databases in org-mode by michael-ax on Friday January 14, 2022 @09:07AM (#29934533)
he's likely doing the same thing with a few more lines of boilerplate than the OP with his admirably (kicks me in the behind) well specialized 'dsl' extensions.

it's got nothing to do with tmux/vim/zsh, instead, it's an example of emacs's org's polylingualness showing just how sweet it can be when extended to support one of 'any' console tool you care about, in whatever workflow.

you make these documents with notes, and run them or any part of them from org or tangled/driven from the commandline. its nice. plus the editor ...

Re:Dealing with APIs, JSON and databases in org-mode by kreetx on Saturday January 15, 2022 @04:59AM (#29945209)
Exactly. So instead of the first example I'd have the following in some .org file, where C-c C-c on the bash block generates the result block:

  #+begin_src bash :results verbatim
  curl https://jsonplaceholder.typicode.com/todos/1 
  #+end_src

  #+RESULTS:
  : {
  :   "userId": 1,
  :   "id": 1,
  :   "title": "delectus aut autem",
  :   "completed": false
  : }