Liking cljdoc? Tell your friends :D

VistarMedia API client for Clojure

Clojure client implementation for VistarMedia DSP API, including the DSP Reporting API.


Clojars Project cljdoc badge

Requirements

  • Java 25+
  • Clojure 1.12.8+

Quick start

Include the library to your project

See the clojars page for the latest version.

Add require

(require '[com.adgoji.vistarmedia :as vistarmedia])

Create a new client

(def client
  (vistarmedia/new-client
   {::vistarmedia/credential {:email "your@email.com" :password "your-password"}}))

Explore

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.

Reporting

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:

OperationRequest
::vistarmedia/reports-listGET /reports
::vistarmedia/report-runPOST /report
::vistarmedia/report-create-and-savePOST /reports
::vistarmedia/report-update-and-savePUT /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"})

Design decisions

The library is very minimal and basically a small wrapper on top of hato HTTP client. The following features are out of scope:

  • request/response validation - it's a caller's responsibility to provide valid payloads and validate responses.
  • pagination - paginated endpoints include total-size key, which can be used to calculate total list of pages to provide proper page query parameter.
  • resilience - the new-client and invoke functions accept an optional wrap-request function, which can be used to wrap requests into resilience-providing functions.

License

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

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close