narc is a way to use curl(1) without killing yourself and without having to use some bloatware. It is written entirely with POSIX awk, as things ought to be. Similar to GNU Emacs's restclient-mode but without the Emacs.
Pipe a request into narc or pass a file containing the request:
$ cat | narc
POST https://api.mysite.com/foo/bar
Content-Type: application/json
Authorization: Bearer 123457890abcdefghijklmnopqrstuvwxyz
{"prop": "value"}
$ narc file.txt
Items in curly brackets are required, square brackets are optional. If you have a body, you need a Content-Type header unless you're using JSON.
# narc: verbose
#comment
# spaces required for var definitions
# use variables by prepending with $
var-name = var value
{METHOD} {URL}
[header-name]:[header-value]
[body]
{NEXT-METHOD} {NEXT-URL}
[next-header-name]:[next-header-value]
[next-body]
Two empty lines are required between requests, even if there is only one request in the file.
Set options via a comment containing "narc:" (e.g. # narc: verbose). You can also pass --verbose or -v directly.
| Methods | POST, PUT, DELETE, GET, etc. |
| Headers | Arbitrary request headers |
| Content types | JSON, x-www-form-urlencoded |
| Variables | Shell-like $var substitution |
| Multiple requests | Separated by two blank lines |
| Verbose mode | Via flag or in-file setting |
| POSIX awk | Required |
| curl(1) | Required |
| POSIX sh | Required |
narc is not only an acronym but also means someone who is a snitch, which makes sense because you're sending stuff to the API.
BSD 3-Clause.
Since the demise of NotABug narc is curently unavailable for download. Contact ktnb at NetBSD dot org if interested.
| restclient.el | Emacs REST client mode |
| curl(1) | Transfer data from or to a server |