In previous blog posts, both here and on the AquaQ blog, I have
mentioned the reQ HTTP library that I’ve been working on. And the time has come
for an “official” release! reQ has reached a point where I think it can be
quite useful, particularly for interacting with web APIs from q. You may be
wondering what’s wrong with
.Q.hp, the built in HTTP request
functions in q; reQ has a few nice additional features over these…
Automatically parse JSON responses
When your HTTP request returns JSON, reQ will allow parsing it automatically:
Adding custom HTTP headers
Some APIs etc. require custom headers (for example, authentication tokens, or
requiring requests to have a
User-Agent, which they do not with
.Q.hp). reQ allows for adding custom headers in a simple fashion using a kdb+
dictionary. For example:
reQ will automatically follow HTTP redirects (3XX status codes)
reQ will store received cookies & automatically send them with future HTTP requests where applicable.
(It’s also possible to read & write cookiejar files in the cURL/Netscape format)
More details about all these features can be found on the documentation site
Finally, and this is the one I recommend, you can install the package using Anaconda. Assuming Anaconda is installed (and regardless of platform), you can install quite simply like so:
Note that due to the dependency system in Anaconda, by installing
qutil setup, as well as the
json package to provide JSON support
below version 3.1, and the
qhttps package, which enables HTTPS support in q,
using a set of certificates provided as an Anaconda package.
I intentionally did not make the package dependent on kx’s kdb package, so you can use this no matter how you installed q; it will work with or without the kx kdb conda package.
Hopefully you can find this library useful, feedback is very welcome! Let me know what you’re using it for, and feel free to open an issue on GitHub for any bugs or problems you encounter!