jonathonmcmurray / reQ

HTTP requests library in kdb+/q
http://jmcmurray.co.uk/reQ/
MIT License
38 stars 9 forks source link
http http-client kdb rest-client

reQ

Anaconda-Server Badge Anaconda-Server Badge Build Status

HTTP requests library in kdb+/q

kdb+ has built in functions for HTTP requests such as .Q.hg (GET) and .Q.hp(POST). However, these functions are somewhat limited by several factors. For example, using these functions you cannot supply custom HTTP headers within the requests (for example, authorization tokens that are required by many APIs, a user agent etc.). In addition, in case of an HTTP redirect response, .Q.hg/.Q.hp will fail.

reQ is a library designed to overcome these limitations for basic HTTP queries. The main features are:

For more details on features & usage, please see the docs

Getting started

Standalone .q script

The simplest way for most people to get started with reQ will be via the standalone .q file available from the Releases tab of this repo. Download the .q script from the latest release & this can be loaded directly with \l when placed in project directory or QHOME etc.

q)\l req_0.1.3.q
q).req.g"https://httpbin.org/get"
args   | (`symbol$())!()
headers| `Accept`Host`User-Agent`X-Amzn-Trace-Id!("*/*";"httpbin.org";"kdb+/3..
origin | "90.249.33.209"
url    | "https://httpbin.org/get"

qutil package via Anaconda

Alternatively, reQ can be installed as a qutil via Anaconda/Miniconda

Assuming conda is installed, installation command is:

$ conda install -c jmcmurray req

And package will then be available in q via:

q).utl.require"req"

Standalone qutil package

If you want to use qutil package, but not via Anaconda, you can also download the package as a .tar.gz from the Releases tab & extract to your QPATH directory.

Updating documentation with qDoc

Using qDoc from Kx (included with Kx Developer)

$ # -norecurse so as not to go into ext/ dir
$ q $DEVELOPER_HOME/ws/qdoc.q_ -src req/ -out docs/api/ -norecurse
..
$ mkdocs serve # to preview locally
..
$ mkdocs gh-deploy # to deploy to github

Linting with qlint

Uses qlint.q_ from Kx (included with Kx Developer). Assumes DEVELOPER_HOME env var is set

$ q lint.q

Loads package & lints .req & related namespaces. Some errors/warnings excluded. Adding an additional arg on cmd line will halt process to inspect output table t.

Building releases

To build a release, build.sh is used. The script creates the unified, standalone .q script & the .tar.gz of qutil package.

Argument is version number e.g.

$ ./build.sh 0.1.3