Bala's Blog

Emacs as REST client

May 29 2017
103 words, ~1 min. read
emacs,  REST 

Emacs could be an effective REST client, using restclient-mode.

Steps

  1. Install restclient, using emacs package manager
  2. Enable restclient, using M-x restclient-mode
  3. Type REST API, HTTP header and body, as appropriate
  4. Execute by pressing C-c C-c

Note

  1. You may format JSON requests, by selecting the JSON text, typing and executing M-x json-pretty-print
  2. You may use variables of the form :variable
  3. # is used for comments and a comment separates an API from others

Example

:host = localhost
:port = 8443
:api = :host::port

# create a contact
POST https://:api/v1/contacts
Content-Type: application/json
Authorization: Bearer 0b79bab50daca910b000d4f1a2b675d604257e42
{
  "name": "Bala"
}

# list all contacts
GET https://:api/v1/contacts