Polymarket.Schemas.Event (Polymarket v0.1.1)

Copy Markdown View Source

An event returned by the Gamma REST API (e.g. GET /events/keyset).

An event groups one or more Polymarket.Schemas.Markets under a single question/title (e.g. an NBA game with its various betting markets). The Gamma API delivers its keys in camelCase; from_attrs/1 normalises them to the snake_case fields below.

The markets, series, tags, and event_metadata relations are always returned by the keyset endpoint and are parsed into their respective schemas. Every scalar field in the Gamma Event OpenAPI schema is mapped (covering both the keyset and single-event endpoints). The nested relational objects in that spec (bestLines, collections, eventCreators, externalPartners, internalUsers, sport, teams, templates, the *Optimized image objects, ...) are intentionally omitted; only markets, series, tags, and eventMetadata are modelled as embedded relations.

Summary

Functions

Builds an Event from the raw (JSON-decoded) Gamma attributes. Keys may be in camelCase (atom or string); they are normalised to the snake_case fields and each value is coerced to its field type. Returns {:error, {:missing_fields, fields}} when a required field is absent.

Types

t()

@type t() :: %Polymarket.Schemas.Event{
  active: boolean() | nil,
  archived: boolean() | nil,
  automatically_active: boolean() | nil,
  automatically_resolved: boolean() | nil,
  cant_estimate: boolean() | nil,
  carousel_map: String.t() | nil,
  category: String.t() | nil,
  closed: boolean() | nil,
  closed_time: DateTime.t() | nil,
  color: String.t() | nil,
  comment_count: integer() | nil,
  comments_enabled: boolean() | nil,
  competitive: float() | nil,
  country_name: String.t() | nil,
  created_at: DateTime.t() | nil,
  created_by: String.t() | nil,
  creation_date: DateTime.t() | nil,
  cumulative_markets: boolean() | nil,
  cyom: boolean() | nil,
  deploying: boolean() | nil,
  deploying_timestamp: DateTime.t() | nil,
  description: String.t() | nil,
  disqus_thread: String.t() | nil,
  elapsed: String.t() | nil,
  election_type: String.t() | nil,
  enable_neg_risk: boolean() | nil,
  enable_order_book: boolean() | nil,
  end_date: DateTime.t() | nil,
  ended: boolean() | nil,
  estimate_value: boolean() | nil,
  estimated_value: String.t() | nil,
  event_date: Date.t() | nil,
  event_metadata: Polymarket.Schemas.EventMetadata.t() | nil,
  event_week: integer() | nil,
  featured: boolean() | nil,
  featured_image: String.t() | nil,
  featured_order: integer() | nil,
  finished_timestamp: DateTime.t() | nil,
  game_id: integer() | nil,
  gmp_chart_mode: String.t() | nil,
  icon: String.t() | nil,
  id: String.t() | nil,
  image: String.t() | nil,
  is_template: boolean() | nil,
  last_highlight: String.t() | nil,
  last_highlight_at: DateTime.t() | nil,
  last_highlight_type: String.t() | nil,
  liquidity: float() | nil,
  liquidity_amm: float() | nil,
  liquidity_clob: float() | nil,
  live: boolean() | nil,
  markets: [Polymarket.Schemas.Market.t()],
  neg_risk: boolean() | nil,
  neg_risk_augmented: boolean() | nil,
  neg_risk_fee_bips: integer() | nil,
  neg_risk_market_id: String.t() | nil,
  new: boolean() | nil,
  open_interest: float() | nil,
  parent_event_id: integer() | nil,
  pending_deployment: boolean() | nil,
  period: String.t() | nil,
  published_at: DateTime.t() | nil,
  requires_translation: boolean() | nil,
  rescheduled_from_game_id: integer() | nil,
  resolution_source: String.t() | nil,
  restricted: boolean() | nil,
  scheduled_deployment_timestamp: DateTime.t() | nil,
  score: String.t() | nil,
  series: [Polymarket.Schemas.Series.t()],
  series_slug: String.t() | nil,
  show_all_outcomes: boolean() | nil,
  show_market_images: boolean() | nil,
  slug: String.t() | nil,
  sort_by: String.t() | nil,
  spreads_main_line: float() | nil,
  start_date: DateTime.t() | nil,
  start_time: DateTime.t() | nil,
  sub_events: [String.t()] | nil,
  subcategory: String.t() | nil,
  subtitle: String.t() | nil,
  tag_labels: [String.t()] | nil,
  tag_slugs: [String.t()] | nil,
  tags: [Polymarket.Schemas.Tag.t()],
  template_variables: String.t() | nil,
  ticker: String.t() | nil,
  title: String.t() | nil,
  totals_main_line: float() | nil,
  turn_provider_id: String.t() | nil,
  tweet_count: integer() | nil,
  updated_at: DateTime.t() | nil,
  updated_by: String.t() | nil,
  volume: float() | nil,
  volume1mo: float() | nil,
  volume1wk: float() | nil,
  volume1yr: float() | nil,
  volume24hr: float() | nil
}

Functions

from_attrs(attrs)

@spec from_attrs(map()) :: {:ok, t()} | {:error, {:missing_fields, [atom()]}}

Builds an Event from the raw (JSON-decoded) Gamma attributes. Keys may be in camelCase (atom or string); they are normalised to the snake_case fields and each value is coerced to its field type. Returns {:error, {:missing_fields, fields}} when a required field is absent.