pify/api_version

The Shopify API version a client uses.

Shopify releases a stable version on the first day of each quarter (2026-01, 2026-04, 2026-07, 2026-10) and keeps it accessible for twelve months, until about day 16 of the same month one year later. A request for a retired version falls forward to the oldest accessible one, so a response can be serialized by a version the consumer did not ask for. execute.run_served reports the version that served each response.

The library holds no clock. Every date question takes a Day that the caller supplies.

Types

pub opaque type ApiVersion
pub type ApiVersionError {
  ApiVersionErrorMalformed(raw: String)
  ApiVersionErrorNotQuarterly(raw: String)
  ApiVersionErrorUnstable
}

Constructors

  • ApiVersionErrorMalformed(raw: String)

    The text is not YYYY-MM.

  • ApiVersionErrorNotQuarterly(raw: String)

    The month is not a quarter start (01, 04, 07, 10).

  • ApiVersionErrorUnstable

    unstable changes without notice and is never accepted.

A calendar day in UTC.

pub type Day {
  Day(year: Int, month: Int, day: Int)
}

Constructors

  • Day(year: Int, month: Int, day: Int)

Values

pub fn accessible_on(version: ApiVersion, today: Day) -> Bool

Shopify retires a version at 15:00 UTC on day 16 of the same month one year later. That day counts as closed.

pub fn at_least(version: ApiVersion, since: ApiVersion) -> Bool

True when version is since or newer. Request shapes that changed between versions branch on this, never on the handle text.

pub fn compare(
  left: ApiVersion,
  right: ApiVersion,
) -> order.Order
pub fn days_until_retired(version: ApiVersion, today: Day) -> Int

Days from today to retired_on(version). Zero or less means the version is retired, so a request for it falls forward.

pub fn default() -> ApiVersion

The version a new connection starts on.

pub fn parse(text: String) -> Result(ApiVersion, ApiVersionError)
pub fn released_on(version: ApiVersion, today: Day) -> Bool

A version is stable from the first day of its month. Before that day it is a release candidate.

pub fn retired_on(version: ApiVersion) -> Day

Day 16 of the same month one year later, the first day the version is closed.

pub fn to_string(version: ApiVersion) -> String

The handle Shopify uses in URLs and headers, such as 2026-07.

pub const v2026_01: ApiVersion
pub const v2026_04: ApiVersion
pub const v2026_07: ApiVersion
pub const v2026_10: ApiVersion
✨ Search Document