Clojure client implementation for VistarMedia DSP API, including the DSP Reporting API.
See the clojars page for the latest version.
(require '[com.adgoji.vistarmedia :as vistarmedia])
(def client
(vistarmedia/new-client
{::vistarmedia/credential {:email "your@email.com" :password "your-password"}}))
The main entry point is vistarmedia/invoke function, which takes a
client instance and a parameters map, which should have at least
::vistarmedia/op key with a supported operation.
To see the list of available operations, inspect vistarmedia/ops
map.
Example:
(vistarmedia/invoke (client)
{::vistarmedia/op ::vistarmedia/advertiser-get
::vistarmedia/payload
{:id "123456"}})
;; => {:id "123456", :name "adgoji"}
See also documentation for vistarmedia/invoke for additional usage
information.
The DSP Reporting API is served from a separate host
(https://trafficking.vistarmedia.com by default). Reporting
operations are invoked the same way as any other operation, the
client routes them to the reporting host and handles authentication
there:
| Operation | Request |
|---|---|
::vistarmedia/reports-list | GET /reports |
::vistarmedia/report-run | POST /report |
::vistarmedia/report-create-and-save | POST /reports |
::vistarmedia/report-update-and-save | PUT /reports |
(vistarmedia/invoke client
{::vistarmedia/op ::vistarmedia/report-run
::vistarmedia/payload
{:body {:report-type "exchange"
:filters {:advertiser ["123456"]}
:groups ["date" "campaign"]
:metrics ["impressions" "media_cost"]
:local-start "2026-03-22T00:00:00"
:local-end "2026-03-28T23:59:59"
:timezone "Europe/Copenhagen"}}})
Body keys are converted to snake_case, but values are sent as is, so
group and metric names must be given in their API form
(e.g. "media_cost").
To use another environment, pass ::vistarmedia/reporting-url (and
::vistarmedia/base-url for the DSP API) to new-client:
(vistarmedia/new-client
{::vistarmedia/credential {:email "your@email.com" :password "your-password"}
::vistarmedia/reporting-url "https://staging.vistarmedia.com"})
new-client and invoke accept an optional
::vistarmedia/wrap-request function. It receives a no-arg thunk
that performs the HTTP call and returns the full hato response map
(status, headers, decoded body), before any status checks. The
thunk's metadata describes the request:
| Key | Value |
|---|---|
::vistarmedia/op | operation keyword, or ::vistarmedia/login |
::vistarmedia/method | :get, :post, :put, :patch |
::vistarmedia/path | path with parameters filled in |
::vistarmedia/url-key | ::vistarmedia/base-url or ::vistarmedia/reporting-url |
The metadata never includes the payload or credentials.
Example: retry server errors, but only for idempotent GET requests:
(defn retry-get-5xx
[thunk]
(let [{::vistarmedia/keys [method]} (meta thunk)]
(loop [attempt 1]
(let [resp (thunk)]
(if (and (= :get method)
(<= 500 (:status resp))
(< attempt 3))
(do (Thread/sleep (* 500 attempt))
(recur (inc attempt)))
resp)))))
(def client
(vistarmedia/new-client
{::vistarmedia/credential {:email "your@email.com" :password "your-password"}
::vistarmedia/wrap-request retry-get-5xx}))
The client's wrapper also wraps login calls (::vistarmedia/op is
::vistarmedia/login). A wrapper passed to invoke replaces the
client's one for that operation only and never wraps login.
The library is very minimal and basically a small wrapper on top of hato HTTP client. The following features are out of scope:
total-size key, which can
be used to calculate total list of pages to provide proper page
query parameter.wrap-request option, see Wrapping requests.Released under the MIT license: https://opensource.org/license/mit
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |