Liking cljdoc? Tell your friends :D

midas.client

MIDAS API client.

Spec-driven HTTP client built on Martian. The OpenAPI spec bundled in resources/midas-spec/openapi.yaml is the single source of truth for endpoint definitions and parameter validation.

Authentication flow:

  1. Call (get-token username password) to obtain a 10-minute bearer token
  2. Call (create-client token) to create an authenticated Martian client
  3. Use the client with API functions (rin-list, rate-values, etc.)
MIDAS API client.

Spec-driven HTTP client built on Martian. The OpenAPI spec bundled in
resources/midas-spec/openapi.yaml is the single source of truth for
endpoint definitions and parameter validation.

Authentication flow:
  1. Call (get-token username password) to obtain a 10-minute bearer token
  2. Call (create-client token) to create an authenticated Martian client
  3. Use the client with API functions (rin-list, rate-values, etc.)
raw docstring

api-urlclj

source

bodyclj

(body response)

Extract the parsed body from an HTTP response.

Extract the parsed body from an HTTP response.
sourceraw docstring

create-auto-clientclj

(create-auto-client username password)
(create-auto-client username
                    password
                    {:keys [url spec-path]
                     :or {url api-url spec-path default-spec-path}})

Create a MIDAS client that automatically refreshes its bearer token.

Acquires an initial token using the provided credentials and transparently refreshes it before any request where the token is expired or about to expire (within 30 seconds).

Options: :url - API base URL (default: production) :spec-path - path to OpenAPI YAML on classpath (default: bundled spec)

Create a MIDAS client that automatically refreshes its bearer token.

Acquires an initial token using the provided credentials and transparently
refreshes it before any request where the token is expired or about to
expire (within 30 seconds).

Options:
  :url       - API base URL (default: production)
  :spec-path - path to OpenAPI YAML on classpath (default: bundled spec)
sourceraw docstring

create-clientclj

(create-client token)
(create-client token
               {:keys [url spec-path]
                :or {url api-url spec-path default-spec-path}})

Create an authenticated MIDAS API client from the bundled OpenAPI spec.

token can be either a raw token string or a token-info map from get-token.

Options: :url - API base URL (default: production) :spec-path - path to OpenAPI YAML on classpath (default: bundled spec)

Create an authenticated MIDAS API client from the bundled OpenAPI spec.

token can be either a raw token string or a token-info map from get-token.

Options:
  :url       - API base URL (default: production)
  :spec-path - path to OpenAPI YAML on classpath (default: bundled spec)
sourceraw docstring

default-spec-pathclj

source

get-historical-dataclj

(get-historical-data client rin startdate enddate)

Fetch archived rate data for a RIN within a date range. Dates are ISO 8601 strings (e.g. "2023-01-01").

Fetch archived rate data for a RIN within a date range.
Dates are ISO 8601 strings (e.g. "2023-01-01").
sourceraw docstring

get-historical-listclj

(get-historical-list client distribution-code energy-code)

Fetch list of RINs with historical data for a provider pair.

Fetch list of RINs with historical data for a provider pair.
sourceraw docstring

get-holidaysclj

(get-holidays client)

Fetch all utility holidays.

Fetch all utility holidays.
sourceraw docstring

get-lookup-tableclj

(get-lookup-table client table-name)

Fetch a MIDAS lookup/reference table. table-name: Country, Daytype, Distribution, Enduse, Energy, Location, Ratetype, Sector, State, or Unit.

Fetch a MIDAS lookup/reference table.
table-name: Country, Daytype, Distribution, Enduse, Energy, Location,
            Ratetype, Sector, State, or Unit.
sourceraw docstring

get-rate-valuesclj

(get-rate-values client rin query-type)

Fetch rate/price values for a specific RIN. query-type: "alldata" or "realtime".

Fetch rate/price values for a specific RIN.
query-type: "alldata" or "realtime".
sourceraw docstring

get-rin-listclj

(get-rin-list client signal-type)

Fetch list of available RINs by signal type. signal-type: 0=All, 1=Rates, 2=GHG, 3=Flex Alert.

Fetch list of available RINs by signal type.
signal-type: 0=All, 1=Rates, 2=GHG, 3=Flex Alert.
sourceraw docstring

get-tokenclj

(get-token username password)
(get-token username password {:keys [url] :or {url api-url}})

Authenticate with MIDAS using HTTP Basic auth and return a bearer token.

The token is returned in the Token response header and is valid for 10 minutes. Returns the token string on success, nil on failure.

Options: :url - API base URL (default: production)

Authenticate with MIDAS using HTTP Basic auth and return a bearer token.

The token is returned in the `Token` response header and is valid for
10 minutes. Returns the token string on success, nil on failure.

Options:
  :url - API base URL (default: production)
sourceraw docstring

registerclj

(register {:keys [fullname username password email organization]})
(register {:keys [fullname username password email organization]}
          {:keys [url] :or {url api-url}})

Register a new MIDAS API user account.

All string fields are automatically base64-encoded as required by the API. Returns the raw HTTP response. organization is optional.

Options: :url - API base URL (default: production)

Register a new MIDAS API user account.

All string fields are automatically base64-encoded as required by the API.
Returns the raw HTTP response. organization is optional.

Options:
  :url - API base URL (default: production)
sourceraw docstring

routesclj

(routes client)

List all available route names for the client.

List all available route names for the client.
sourceraw docstring

success?clj

(success? response)

True if the HTTP response has a 2xx status.

True if the HTTP response has a 2xx status.
sourceraw docstring

token-expired?clj

(token-expired? token-info)
(token-expired? token-info buffer-seconds)

True if a token-info map is expired or will expire within buffer-seconds (default 30).

True if a token-info map is expired or will expire within buffer-seconds (default 30).
sourceraw docstring

token-infoclj

(token-info client)

Get the current token-info from a client (works with both client types).

Get the current token-info from a client (works with both client types).
sourceraw docstring

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