Geminex.API.Public (geminex v0.0.1)

Public API endpoints for Gemini.

Summary

Types

Options that may be passed to a request function. See request/2 for detailed descriptions.

Functions

Retrieves time-intervaled data for the provided symbol.

Retrieves the current order book for the specified trading pair symbol.

Perform a DELETE request.

Perform a DELETE request.

Retrieves time-intervaled data for the provided perpetual swap symbol.

Retrieves symbols that currently have fee promos.

Retrieves the funding amount details for the specified symbol.

Retrieves the funding amount report file.

Perform a GET request.

Perform a GET request.

Perform a HEAD request.

Perform a HEAD request.

Retrieves the associated network for a requested token.

Perform a OPTIONS request.

Perform a OPTIONS request.

Perform a PATCH request.

Perform a PATCH request.

Perform a POST request.

Perform a POST request.

Retrieves the price feed for all trading pairs.

Perform a PUT request.

Perform a PUT request.

Perform request and raise in case of error.

Retrieves extra detail on a supported symbol.

Retrieves all available symbols for trading.

Retrieves information about recent trading activity for the symbol.

Retrieves information about recent trading activity for the provided symbol (V2).

Perform a TRACE request.

Perform a TRACE request.

Retrieves the trade history for the specified trading pair symbol.

Types

@type option() ::
  {:method, Tesla.Env.method()}
  | {:url, Tesla.Env.url()}
  | {:query, Tesla.Env.query()}
  | {:headers, Tesla.Env.headers()}
  | {:body, Tesla.Env.body()}
  | {:opts, Tesla.Env.opts()}

Options that may be passed to a request function. See request/2 for detailed descriptions.

Functions

Link to this function

candles(symbol, time_frame)

@spec candles(symbol :: String.t(), time_frame :: String.t()) ::
  {:ok, [[any()]]} | {:error, any()}

Retrieves time-intervaled data for the provided symbol.

Parameters

  • symbol: Trading pair symbol (e.g., "btcusd").
  • time_frame: Time range for each candle (e.g., "1m", "5m").
Link to this function

current_order_book(symbol, opts \\ [])

@spec current_order_book(
  symbol :: String.t(),
  opts :: [limit_bids: non_neg_integer(), limit_asks: non_neg_integer()]
) :: {:ok, map()} | {:error, any()}

Retrieves the current order book for the specified trading pair symbol.

Parameters

  • symbol (String.t()): The trading pair symbol (e.g., "btcusd").
  • opts (keyword list, optional): A list of query parameters to customize the order book data.
    • :limit_bids (non_neg_integer()): The maximum number of bid orders to retrieve.
    • :limit_asks (non_neg_integer()): The maximum number of ask orders to retrieve.

Returns

  • on success, containing the order book data as a map.
  • on failure, with an error reason.
Link to this function

delete(client, url, opts)

@spec delete(Tesla.Env.client(), Tesla.Env.url(), [option()]) :: Tesla.Env.result()

Perform a DELETE request.

See request/1 or request/2 for options definition.

delete("/users")
delete("/users", query: [scope: "admin"])
delete(client, "/users")
delete(client, "/users", query: [scope: "admin"])
delete(client, "/users", body: %{name: "Jon"})
Link to this function

delete!(client, url, opts)

@spec delete!(Tesla.Env.client(), Tesla.Env.url(), [option()]) ::
  Tesla.Env.t() | no_return()

Perform a DELETE request.

See request!/1 or request!/2 for options definition.

delete!("/users")
delete!("/users", query: [scope: "admin"])
delete!(client, "/users")
delete!(client, "/users", query: [scope: "admin"])
delete!(client, "/users", body: %{name: "Jon"})
Link to this function

derivatives_candles(symbol, time_frame)

@spec derivatives_candles(symbol :: String.t(), time_frame :: String.t()) ::
  {:ok, [[any()]]} | {:error, any()}

Retrieves time-intervaled data for the provided perpetual swap symbol.

Parameters

  • symbol: Perpetual swap symbol (e.g., "BTCGUSDPERP").
  • time_frame: Time range for each candle (e.g., "1m").
@spec fee_promos() :: {:ok, map()} | {:error, any()}

Retrieves symbols that currently have fee promos.

Link to this function

funding_amount(symbol)

@spec funding_amount(symbol :: String.t()) :: {:ok, map()} | {:error, any()}

Retrieves the funding amount details for the specified symbol.

Parameters

  • symbol: Trading pair symbol (e.g., "btcgusdperp").
Link to this function

funding_amount_report(opts \\ [])

@spec funding_amount_report(
  opts :: [
    fromDate: non_neg_integer(),
    toDate: non_neg_integer(),
    numRows: non_neg_integer()
  ]
) :: {:ok, binary()} | {:error, any()}

Retrieves the funding amount report file.

Parameters

  • opts (keyword list, optional): A list of query parameters to customize the report.
    • :fromDate (non_neg_integer()): The start date for the report, represented as a Unix timestamp.
    • :toDate (non_neg_integer()): The end date for the report, represented as a Unix timestamp.
    • :numRows (non_neg_integer()): The maximum number of rows to retrieve in the report.

Returns

  • on success, containing the binary content of the report file.
  • on failure, with an error reason.
Link to this function

get(client, url, opts)

Perform a GET request.

See request/1 or request/2 for options definition.

get("/users")
get("/users", query: [scope: "admin"])
get(client, "/users")
get(client, "/users", query: [scope: "admin"])
get(client, "/users", body: %{name: "Jon"})
Link to this function

get!(client, url, opts)

@spec get!(Tesla.Env.client(), Tesla.Env.url(), [option()]) ::
  Tesla.Env.t() | no_return()

Perform a GET request.

See request!/1 or request!/2 for options definition.

get!("/users")
get!("/users", query: [scope: "admin"])
get!(client, "/users")
get!(client, "/users", query: [scope: "admin"])
get!(client, "/users", body: %{name: "Jon"})
Link to this function

head(client, url, opts)

Perform a HEAD request.

See request/1 or request/2 for options definition.

head("/users")
head("/users", query: [scope: "admin"])
head(client, "/users")
head(client, "/users", query: [scope: "admin"])
head(client, "/users", body: %{name: "Jon"})
Link to this function

head!(client, url, opts)

@spec head!(Tesla.Env.client(), Tesla.Env.url(), [option()]) ::
  Tesla.Env.t() | no_return()

Perform a HEAD request.

See request!/1 or request!/2 for options definition.

head!("/users")
head!("/users", query: [scope: "admin"])
head!(client, "/users")
head!(client, "/users", query: [scope: "admin"])
head!(client, "/users", body: %{name: "Jon"})
@spec network(token :: String.t()) :: {:ok, map()} | {:error, any()}

Retrieves the associated network for a requested token.

Parameters

  • token: Token identifier (e.g., "eth").
Link to this function

options(client, url, opts)

@spec options(Tesla.Env.client(), Tesla.Env.url(), [option()]) :: Tesla.Env.result()

Perform a OPTIONS request.

See request/1 or request/2 for options definition.

options("/users")
options("/users", query: [scope: "admin"])
options(client, "/users")
options(client, "/users", query: [scope: "admin"])
options(client, "/users", body: %{name: "Jon"})
Link to this function

options!(client, url, opts)

@spec options!(Tesla.Env.client(), Tesla.Env.url(), [option()]) ::
  Tesla.Env.t() | no_return()

Perform a OPTIONS request.

See request!/1 or request!/2 for options definition.

options!("/users")
options!("/users", query: [scope: "admin"])
options!(client, "/users")
options!(client, "/users", query: [scope: "admin"])
options!(client, "/users", body: %{name: "Jon"})
Link to this function

patch(client, url, body, opts)

Perform a PATCH request.

See request/1 or request/2 for options definition.

patch("/users", %{name: "Jon"})
patch("/users", %{name: "Jon"}, query: [scope: "admin"])
patch(client, "/users", %{name: "Jon"})
patch(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function

patch!(client, url, body, opts)

Perform a PATCH request.

See request!/1 or request!/2 for options definition.

patch!("/users", %{name: "Jon"})
patch!("/users", %{name: "Jon"}, query: [scope: "admin"])
patch!(client, "/users", %{name: "Jon"})
patch!(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function

post(client, url, body, opts)

Perform a POST request.

See request/1 or request/2 for options definition.

post("/users", %{name: "Jon"})
post("/users", %{name: "Jon"}, query: [scope: "admin"])
post(client, "/users", %{name: "Jon"})
post(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function

post!(client, url, body, opts)

Perform a POST request.

See request!/1 or request!/2 for options definition.

post!("/users", %{name: "Jon"})
post!("/users", %{name: "Jon"}, query: [scope: "admin"])
post!(client, "/users", %{name: "Jon"})
post!(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
@spec price_feed() :: {:ok, [map()]} | {:error, any()}

Retrieves the price feed for all trading pairs.

Link to this function

put(client, url, body, opts)

Perform a PUT request.

See request/1 or request/2 for options definition.

put("/users", %{name: "Jon"})
put("/users", %{name: "Jon"}, query: [scope: "admin"])
put(client, "/users", %{name: "Jon"})
put(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function

put!(client, url, body, opts)

Perform a PUT request.

See request!/1 or request!/2 for options definition.

put!("/users", %{name: "Jon"})
put!("/users", %{name: "Jon"}, query: [scope: "admin"])
put!(client, "/users", %{name: "Jon"})
put!(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function

request(client \\ %Tesla.Client{}, options)

@spec request(Tesla.Env.client(), [option()]) :: Tesla.Env.result()

Perform a request.

Options

  • :method - the request method, one of [:head, :get, :delete, :trace, :options, :post, :put, :patch]
  • :url - either full url e.g. "http://example.com/some/path" or just "/some/path" if using Tesla.Middleware.BaseUrl
  • :query - a keyword list of query params, e.g. [page: 1, per_page: 100]
  • :headers - a keyworld list of headers, e.g. [{"content-type", "text/plain"}]
  • :body - depends on used middleware:
    • by default it can be a binary
    • if using e.g. JSON encoding middleware it can be a nested map
    • if adapter supports it it can be a Stream with any of the above
  • :opts - custom, per-request middleware or adapter options

Examples

ExampleApi.request(method: :get, url: "/users/path")

# use shortcut methods
ExampleApi.get("/users/1")
ExampleApi.post(client, "/users", %{name: "Jon"})
Link to this function

request!(client \\ %Tesla.Client{}, options)

@spec request!(Tesla.Env.client(), [option()]) :: Tesla.Env.t() | no_return()

Perform request and raise in case of error.

This is similar to request/2 behaviour from Tesla 0.x

See request/2 for list of available options.

Link to this function

symbol_details(symbol)

@spec symbol_details(symbol :: String.t()) :: {:ok, map()} | {:error, any()}

Retrieves extra detail on a supported symbol.

Parameters

  • symbol: Trading pair symbol (e.g., "btcusd").
@spec symbols() :: {:ok, [String.t()]} | {:error, any()}

Retrieves all available symbols for trading.

@spec ticker(symbol :: String.t()) :: {:ok, map()} | {:error, any()}

Retrieves information about recent trading activity for the symbol.

Parameters

  • symbol: Trading pair symbol (e.g., "btcusd").
Link to this function

ticker_v2(symbol)

@spec ticker_v2(symbol :: String.t()) :: {:ok, map()} | {:error, any()}

Retrieves information about recent trading activity for the provided symbol (V2).

Parameters

  • symbol: Trading pair symbol (e.g., "btcusd").
Link to this function

trace(client, url, opts)

Perform a TRACE request.

See request/1 or request/2 for options definition.

trace("/users")
trace("/users", query: [scope: "admin"])
trace(client, "/users")
trace(client, "/users", query: [scope: "admin"])
trace(client, "/users", body: %{name: "Jon"})
Link to this function

trace!(client, url, opts)

@spec trace!(Tesla.Env.client(), Tesla.Env.url(), [option()]) ::
  Tesla.Env.t() | no_return()

Perform a TRACE request.

See request!/1 or request!/2 for options definition.

trace!("/users")
trace!("/users", query: [scope: "admin"])
trace!(client, "/users")
trace!(client, "/users", query: [scope: "admin"])
trace!(client, "/users", body: %{name: "Jon"})
Link to this function

trade_history(symbol, opts \\ [])

@spec trade_history(
  symbol :: String.t(),
  opts :: [
    timestamp: non_neg_integer(),
    since_tid: non_neg_integer(),
    limit_trades: non_neg_integer(),
    include_breaks: boolean()
  ]
) :: {:ok, [map()]} | {:error, any()}

Retrieves the trade history for the specified trading pair symbol.

Parameters

  • symbol (String.t()): The trading pair symbol (e.g., "btcusd").
  • opts (keyword list, optional): A list of options to customize the query.
    • :timestamp (non_neg_integer()): The starting timestamp for the trade history.
    • :since_tid (non_neg_integer()): The trade ID from which to start fetching trades.
    • :limit_trades (non_neg_integer()): The maximum number of trades to retrieve.
    • :include_breaks (boolean()): Whether to include breaks between trades. Defaults to false.

Returns

  • on success, containing the trade history as a list of maps.
  • on failure, with an error reason.