Need help with JuliaWebAPI.jl?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

160 Stars 28 Forks Other 178 Commits 6 Opened issues


Julia package for deploying APIs

Services available


Need anything else?

Contributors list


Build Status Coverage Status

Facilitates wrapping Julia functions into a remote callable API via message queues (e.g. ZMQ, RabbitMQ) and HTTP.

It can plug in to a different messaging infrastructure through an implementation of transport (

) and message format (
). Multiple instances of the front (HTTP API) and back (Julia methods) end can help scale an application. Bundled with the package are implementations for: - ZMQTransport: use ZMQ for transport - InProcTransport: use Julia
for transport within the same process - JSONMsgFormat: JSON as message format - SerializedMsgFormat: Julia serialization as message format - DictMsgFormat: Julia
as message format, for use within the same process

Combined with a HTTP/Messaging frontend (like JuliaBox), it helps deploy Julia packages and code snippets as hosted, auto-scaling HTTP APIs.

Some amount of basic request filtering and pre-processing is possible by registering a pre-processor with the HTTP frontend. The pre-processor is run at the HTTP server side, where it has access to the complete request. It can examine headers and data and take decision whether to allow calling the service or respond directly and immediately. It can also rewrite the request before passing it on to the service.

A pre-processor can be used to implement features like authentication, request rewriting and such. See example below.

Example Usage

Create a file

with the following code
# Load required packages
using JuliaWebAPI

Define functions testfn1 and testfn2 that we shall expose

function testfn1(arg1, arg2; narg1="1", narg2="2") return (parse(Int, arg1) * parse(Int, narg1)) + (parse(Int, arg2) * parse(Int, narg2)) end

testfn2(arg1, arg2; narg1="1", narg2="2") = testfn1(arg1, arg2; narg1=narg1, narg2=narg2)

Expose testfn1 and testfn2 via a ZMQ listener

process( JuliaWebAPI.create_responder([ (testfn1, true), (testfn2, false) ], "tcp://", true, "") )

Start the server process in the background. This process will run the ZMQ listener.

julia srvr.jl &

Then, on a Julia REPL, run the following code ```julia using JuliaWebAPI #Load package

Create the ZMQ client that talks to the ZMQ listener above

const apiclnt = APIInvoker("tcp://");

Start the HTTP server in current process (Ctrl+C to interrupt)

run_http(apiclnt, 8888) ```

Then, on your browser, navigate to


This will return the following JSON response to your browser, which is the result of running the

function defined above:

Example of an authentication filter implemented using a pre-processor:

function auth_preproc(req::HTTP.Request)
    if !validate(req)
        return HTTP.Response(401)
    return nothing
run_http(apiclnt, 8888, auth_preproc)

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.