ob-restclient.el icon indicating copy to clipboard operation
ob-restclient.el copied to clipboard

An org-mode extension to restclient.el

  • ob-restclient.el [[https://melpa.org/#/ob-restclient][file:https://melpa.org/packages/ob-restclient-badge.svg]]

    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=:

    #+BEGIN_SRC emacs-lisp (org-babel-do-load-languages 'org-babel-load-languages '((restclient . t))) #+END_SRC

    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 org ,#+BEGIN_SRC restclient GET http://example.com ,#+END_SRC

    ,#+RESULTS:
    ,#+BEGIN_SRC html
    <!doctype html>
    <html>
    <head>
      ...
    </head>
    </html>
    ,#+END_SRC
    

    #+END_SRC

    You can pass variables into the block using :var header arguments. For example:

    #+BEGIN_SRC org ,#+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
    

    #+END_SRC

    See [[https://github.com/pashky/restclient.el][restclient.el]] for documentation and examples of usage.

  • Author

Alf Lervåg