An extension to restclient.el for emacs that provides org-babel support.
To get started, install ob-restclient.el
and add (restclient . t)
to
org-babel-load-languages
:
(org-babel-do-load-languages
'org-babel-load-languages
'((restclient . t)))
You can then execute the query by pressing C-c C-c
on the
source-block header.
header arguments for :results raw|value|pure|table
will make a clean
result containing solely the response, and :jq PATTERN
will
post-process the response by passing the value to jq
, provided the binary
exists at a location specified by org-babel-restclient--jq-path
#+BEGIN_SRC restclient
GET http://example.com
#+END_SRC
#+RESULTS:
#+BEGIN_SRC html
<!doctype html>
<html>
<head>
...
</head>
</html>
#+END_SRC
You can pass variables into the block using :var header arguments. For example:
#+name: example_host
#+BEGIN_SRC elisp
"example.com"
#+END_SRC
#+BEGIN_SRC restclient :var host=example_host :var foo="example" :var bar=42
GET http://:host?foo=:foo&bar=:bar
#+END_SRC
See restclient.el for documentation and examples of usage.
Alf Lervåg