• Stars
    star
    254
  • Rank 160,264 (Top 4 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created almost 10 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

make http request within org-mode babel

ob-http

http://melpa.org/packages/ob-http-badge.svg http://stable.melpa.org/packages/ob-http-badge.svg

http request in org-mode babel, requires curl

#+BEGIN_SRC http :pretty
GET https://api.github.com/repos/zweifisch/ob-http/languages
Accept: application/vnd.github.moondragon+json
#+END_SRC

#+RESULTS:
: {
:   "Emacs Lisp": 8170
: }

setup

To use ob-http in an org-babel source block, the http language must be enabled in the custom org-babel-load-languages alist. Alternatively, running the following snippet during initialization will enable the mode.

(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (http . t)))

options

optioncurlexample
:proxy-x:proxy localhost:8118
:noproxy--noproxy *N/A
:cookie-jar--cookie-jar:cookie-jar username
:cookie--cookie:cookie username
:max-time--max-timedefault is 10
:user--user:user admin:passwd
:prettyN/A:pretty use Content-Type, to overwrite :pretty json
:selectN/A:select path path will be passed to jq for json or pup for html or xmlstarlet for xml
:get-headerN/A:get-header X-Subject-Token
:curlN/A:curl --insecure --compressed additional arguments for curl
:resolve--resolve:resolve example.com:80:127.0.0.1,example.com:443:127.0.0.1

examples

set arbitrary header

#+BEGIN_SRC http :pretty
GET http://httpbin.org/user-agent
User-Agent: ob-http
#+END_SRC

#+RESULTS:
: {
:   "user-agent": "ob-http"
: }

json

#+BEGIN_SRC http :pretty
POST http://httpbin.org/post
Content-Type: application/json

{
  "key": "value"
}
#+END_SRC

#+RESULTS:
#+begin_example
{
  "url": "http://httpbin.org/post",
  "json": {
    "key": "value"
  },
  "headers": {
    "User-Agent": "curl/7.35.0",
    "Host": "httpbin.org",
    "Content-Type": "application/json",
    "Content-Length": "18",
    "Accept": "*/*"
  },
  "form": {},
  "files": {},
  "data": "{  \"key\": \"value\"}",
  "args": {}
}
#+end_example

form submit

#+BEGIN_SRC http :pretty
PATCH http://httpbin.org/patch

key=value&foo=value
#+END_SRC

#+RESULTS:
#+begin_example
{
  "url": "http://httpbin.org/patch",
  "origin": "116.227.144.38",
  "json": null,
  "headers": {
    "User-Agent": "curl/7.35.0",
    "Host": "httpbin.org",
    "Content-Type": "application/x-www-form-urlencoded",
    "Content-Length": "19",
    "Accept": "*/*"
  },
  "form": {
    "key": "value",
    "foo": "value"
  },
  "files": {},
  "data": "",
  "args": {}
}
#+end_example

variable

#+HEADER: :var name="ob-http"
#+HEADER: :var password="secret"
#+BEGIN_SRC http :select .json
POST http://httpbin.org/post
Content-Type: application/json

{
    "auth": {
        "name": "${name}",
        "password": "${password}"
    }
}
#+END_SRC

#+RESULTS:
: {
:   "auth": {
:     "password": "secret",
:     "name": "ob-http"
:   }
: }

use properties

supported headers:

  • pretty
  • proxy
  • noproxy
  • cookie
  • schema
  • host
  • port
  • user
  • max-time
* api test
:PROPERTIES:
:header-args: :var token="secret" :host httpbin.org :pretty
:END:

#+BEGIN_SRC http
POST /post
Content-Type: application/json
X-Auth-Token: ${token}
#+END_SRC

#+RESULTS:
#+begin_example
{
  "url": "http://httpbin.org/post",
  "json": null,
  "headers": {
    "X-Auth-Token": "secret",
    "User-Agent": "curl/7.35.0",
    "Host": "httpbin.org",
    "Content-Type": "application/json",
    "Accept": "*/*"
  },
  "form": {},
  "files": {},
  "data": "",
  "args": {}
}
#+end_example

files

#+BEGIN_SRC http :file zweifisch.jpeg
GET https://avatars.githubusercontent.com/u/447862?v=3
#+END_SRC
#+RESULTS:
[[file:zweifisch.jpeg]]

More Repositories

1

kontur

a little DSL that outputs JSON schema
JavaScript
78
star
2

pipe2eval

REPL inside vim
Shell
72
star
3

ollama

ollama client for Emacs
Emacs Lisp
47
star
4

enlive

query html document with css selectors in elisp
Emacs Lisp
45
star
5

nginx-sites

manage nginx vhost configs
Python
39
star
6

zf

a micro php framework/router for both web and cli
PHP
34
star
7

ob-ansible

ansible ad-hoc commands in org-mode babel(or better devops with org-mode)
Emacs Lisp
34
star
8

ob-elixir

org-babel functions for elixir evaluation
Emacs Lisp
26
star
9

ob-cypher

query neo4j using cypher in org-mode blocks
Emacs Lisp
22
star
10

vimwiki-assets

basic styles and code hightlight for vimwiki exported markup
CSS
21
star
11

ob-swift

org-babel functions for swift evaluation
Emacs Lisp
12
star
12

ob-rust

org-babel functions for rust evaluation
Emacs Lisp
11
star
13

ob-javascript

Emacs Lisp
10
star
14

dotfiles

personal dotfiles
Shell
10
star
15

php-pattern-matching

pattern matching for php
PHP
9
star
16

table

ascii tables for cli
Elixir
9
star
17

ppa-collection

8
star
18

ob-kotlin

org-babel functions for kotlin evaluation
Emacs Lisp
8
star
19

foreman-mode

Manage Procfile-based applications in Emacs
Emacs Lisp
8
star
20

eno

Lightweight SQL toolkit for Elixir
Elixir
7
star
21

openstack.ex

openstack client for elixir
Elixir
7
star
22

node-pdf

pdf generation using mustache and xelatex
CoffeeScript
6
star
23

sieve

a simple yet efficient cache
TypeScript
6
star
24

ob-lfe

org-babel functions for lfe(list flavored erlang) evaluation
Emacs Lisp
5
star
25

google-search-cli

google search on the commandline
Python
4
star
26

simple-require

nodejs like require/exports for browser
JavaScript
4
star
27

reverflow

reversible flow for building robust application with javascript
JavaScript
4
star
28

doklein

a documentation generator
CSS
4
star
29

invoker

A CoffeeScript library for Client/Server interaction
JavaScript
4
star
30

yaddle-py

data format description language translates to json-schema
Python
3
star
31

lezer-ast-explorer

TypeScript
3
star
32

mongo-tools

cli utility for mongodb
Python
3
star
33

clostack

openstack client for clojure
Clojure
3
star
34

einbahn

Server-Sent Events with Namespaces and Channels
TypeScript
3
star
35

maybe

Utils to deal with errors
Elixir
3
star
36

rusty

captcha for nodejs
JavaScript
2
star
37

ob-groovy

org-babel functions for groovy evaluation
Emacs Lisp
2
star
38

klar

a micro web framework built for fun
Python
2
star
39

openstack.js

JavaScript
2
star
40

ob-fsharp

org-babel functions for fsharp evaluation
Emacs Lisp
2
star
41

re-select

selectize for reagent
Clojure
2
star
42

ahk-scripts

AutoHotkey
2
star
43

vimwiki-tools

tools for vimwiki
Python
2
star
44

drop-me-the-file

utils allowing others to send you files
CoffeeScript
1
star
45

rqlite-client

nodejs client for rqlite with cluster support
TypeScript
1
star
46

f

functional building blocks for php
PHP
1
star
47

jenkins-cli

JavaScript
1
star
48

onion

http middleware for chicken scheme
Scheme
1
star
49

qdump

dump amqp queue
Go
1
star
50

knockout-morris

morris handler for knockoutjs
CoffeeScript
1
star
51

msgpack-tool

a cli utility for msgpack/json conversion
Python
1
star
52

qrcode

qrcode generator
JavaScript
1
star
53

cliui

utils for command line user iteraction
Python
1
star
54

attached

send file as attachment from commandline
Go
1
star
55

share

sharing code snippets with teammates
Go
1
star
56

ob-coffee

org-babel functions for coffee-script evaluation
Emacs Lisp
1
star
57

thek

Python
1
star
58

ccjs

client-side common js
JavaScript
1
star
59

checktable

jquery table plugin
JavaScript
1
star
60

phonegap-android-jquerymobile-boilerplate

phonegap-android-jquerymobile-boilerplate
JavaScript
1
star
61

schlagzeile

headlines on console
Python
1
star
62

glance

Shell
1
star
63

invoker-php

php backend for invoker
JavaScript
1
star
64

wsgi-supervisor

reload wsgi application when code changed
Python
1
star
65

knockout-select2

select2 handler for knockoutjs
CoffeeScript
1
star
66

replit.vim

repl in tmux
Vim Script
1
star
67

js-app-boilerplate

js app boilerplate
JavaScript
1
star
68

cadena

cadena helps you to write safer sql
JavaScript
1
star