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:
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.)
(body response)Extract the parsed body from an HTTP response.
Extract the parsed body from an HTTP response.
(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)
(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)
(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").
(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.
(get-holidays client)Fetch all utility holidays.
Fetch all utility holidays.
(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.(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".
(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.
(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)
(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)
(routes client)List all available route names for the client.
List all available route names for the client.
(success? response)True if the HTTP response has a 2xx status.
True if the HTTP response has a 2xx status.
(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).
(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).
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 |