Liking cljdoc? Tell your friends :D


A zero dependency HTTP library built on

Getting started

Clojars Project



The was added in Java 11. It can be used to request HTTP resources over the network.

It supports both HTTP/1.1 and HTTP/2, synchronous and asynchronous programming models, handles request and response bodies as reactive-streams, and follows the familiar builder pattern.

This library exposes the native java HTTP client via Clojure and supports both sync and async requests.

Getting started

In order to use this library you will need to be running Java 11+.

You can import the library into your projects as follows:

(ns myns
  (:require [java-http-clj.core :as http]))

Basic Usage

Requests work exactly as you'd expect.

;; Make a simple request and return the HTTP status
(-> (http/get "") :status)

;; Passing in other request options
(http/get ""
  {:headers {"Accept" "application/json" "Accept-Encoding" ["gzip" "deflate"]}
   :timeout 2000})

Alternatively you can construct a raw request yourself.

Raw requests are created as follows

(http/request {:method :get :url ""})

Query Parameters

You can add query parameters to your request using the following form:

(http/get "" {:query-parameters {:foo "bar"}})

Async Requests

There are async implementations of all core HTTP methods.

When using the async client, you can provide an optional callback and an optional error handler.

;; With callback
(http/async-get ""
  (fn [r] (println (:status r))))

;; With callback and error handler
(http/async-get ""
  (fn [r] (println (:status r)))
  (fn [e] (println e)))


Copyright © 2020 Owain Lewis

Released under the MIT License:

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close