View Source SpeedrunClient (srex v0.1.0)

Documentation for an unofficial speedrun.com REST API client.

Official REST API documentation can be found at https://github.com/speedruncomorg/api

Summary

Types

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

Functions

Perform a DELETE request.

Perform a DELETE request.

Perform a GET request.

Perform a GET request.

Perform a HEAD request.

Perform a HEAD request.

Create a new client. Can optionally provided an API key which is require by some endpoints.

Perform a OPTIONS request.

Perform a OPTIONS request.

Perform a PATCH request.

Perform a PATCH request.

Perform a POST request.

Perform a POST request.

Perform a PUT request.

Perform a PUT request.

Perform request and raise in case of error.

Perform a TRACE request.

Perform a TRACE request.

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

delete(client, url, opts)

View Source
@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)

View Source
@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"})
@spec delete_runs(Tesla.Env.client(), String.t()) :: Tesla.Env.result()

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"})
@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

get_categories(client, id, options \\ [])

View Source
@spec get_categories(Tesla.Env.client(), String.t(), List.t()) :: Tesla.Env.result()
Link to this function

get_categories_records(client, id, options \\ [])

View Source
@spec get_categories_records(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_categories_variables(client, id, options \\ [])

View Source
@spec get_categories_variables(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_developers(client, options \\ [])

View Source
@spec get_developers(Tesla.Env.client(), List.t()) :: Tesla.Env.result()
@spec get_developers(Tesla.Env.client(), String.t()) :: Tesla.Env.result()
Link to this function

get_engines(client, options \\ [])

View Source
@spec get_engines(Tesla.Env.client(), List.t()) :: Tesla.Env.result()
@spec get_engines(Tesla.Env.client(), String.t()) :: Tesla.Env.result()
Link to this function

get_games(client, id_or_options \\ [], options \\ [])

View Source
Link to this function

get_games_categories(client, id, options \\ [])

View Source
@spec get_games_categories(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_games_derived_games(client, id, options \\ [])

View Source
@spec get_games_derived_games(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_games_levels(client, id, options \\ [])

View Source
@spec get_games_levels(Tesla.Env.client(), String.t(), List.t()) :: Tesla.Env.result()
Link to this function

get_games_records(client, id, options \\ [])

View Source
@spec get_games_records(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_games_variables(client, id, options \\ [])

View Source
@spec get_games_variables(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_gametypes(client, options \\ [])

View Source
@spec get_gametypes(Tesla.Env.client(), List.t()) :: Tesla.Env.result()
@spec get_gametypes(Tesla.Env.client(), String.t()) :: Tesla.Env.result()
Link to this function

get_genres(client, options \\ [])

View Source
@spec get_genres(Tesla.Env.client(), List.t()) :: Tesla.Env.result()
@spec get_genres(Tesla.Env.client(), String.t()) :: Tesla.Env.result()
Link to this function

get_guests(client, name)

View Source
@spec get_guests(Tesla.Env.client(), String.t()) :: Tesla.Env.result()
Link to this function

get_leaderboards_category(client, game, category, options \\ [])

View Source
@spec get_leaderboards_category(Tesla.Env.client(), String.t(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_leaderboards_level(client, game, level, category, options \\ [])

View Source
@spec get_leaderboards_level(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  List.t()
) ::
  Tesla.Env.result()
Link to this function

get_levels(client, id, options \\ [])

View Source
Link to this function

get_levels_categories(client, id, options \\ [])

View Source
@spec get_levels_categories(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_levels_records(client, id, options \\ [])

View Source
@spec get_levels_records(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_levels_variables(client, id, options \\ [])

View Source
@spec get_levels_variables(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_notifications(client, options \\ [])

View Source
@spec get_notifications(Tesla.Env.client(), List.t()) :: Tesla.Env.result()
Link to this function

get_platforms(client, options \\ [])

View Source
@spec get_platforms(Tesla.Env.client(), List.t()) :: Tesla.Env.result()
@spec get_platforms(Tesla.Env.client(), String.t()) :: Tesla.Env.result()
@spec get_profile(Tesla.Env.client()) :: Tesla.Env.result()
Link to this function

get_publishers(client, options \\ [])

View Source
@spec get_publishers(Tesla.Env.client(), List.t()) :: Tesla.Env.result()
@spec get_publishers(Tesla.Env.client(), String.t()) :: Tesla.Env.result()
Link to this function

get_regions(client, options \\ [])

View Source
@spec get_regions(Tesla.Env.client(), List.t()) :: Tesla.Env.result()
@spec get_regions(Tesla.Env.client(), String.t()) :: Tesla.Env.result()
Link to this function

get_runs(client, id_or_options \\ [], options \\ [])

View Source
Link to this function

get_series(client, id_or_options \\ [], options \\ [])

View Source
Link to this function

get_series_games(client, id, options \\ [])

View Source
@spec get_series_games(Tesla.Env.client(), String.t(), List.t()) :: Tesla.Env.result()
Link to this function

get_users(client, options \\ [])

View Source
@spec get_users(Tesla.Env.client(), List.t()) :: Tesla.Env.result()
@spec get_users(Tesla.Env.client(), String.t()) :: Tesla.Env.result()
Link to this function

get_users_personal_bests(client, id, options \\ [])

View Source
@spec get_users_personal_bests(Tesla.Env.client(), String.t(), List.t()) ::
  Tesla.Env.result()
Link to this function

get_variables(client, id)

View Source
@spec get_variables(Tesla.Env.client(), String.t()) :: Tesla.Env.result()

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)

View Source
@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 new(String.t()) :: Tesla.Env.client()

Create a new client. Can optionally provided an API key which is require by some endpoints.

See Official Authentication Documentation for instructions on how to create an API key.

Examples

iex> SpeedrunClient.new() %Tesla.Client{

fun: nil,
pre: [],
post: [],
adapter: {Tesla.Adapter.Mint, :call, [[]]}
}

iex> SpeedrunClient.new("my-api-key") %Tesla.Client{

fun: nil,
pre: [{Tesla.Middleware.Headers, :call, [[{"X-API-Key", "my-api-key"}]]}],
post: [],
adapter: {Tesla.Adapter.Mint, :call, [[]]}
}
Link to this function

options(client, url, opts)

View Source
@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)

View Source
@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)

View Source

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)

View Source

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)

View Source

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)

View Source

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 post_runs(Tesla.Env.client(), Tesla.Env.body()) :: Tesla.Env.result()
Link to this function

put(client, url, body, opts)

View Source

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)

View Source

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_runs_players(client, id, body)

View Source
@spec put_runs_players(Tesla.Env.client(), String.t(), Tesla.Env.body()) ::
  Tesla.Env.result()
Link to this function

put_runs_status(client, id, body)

View Source
@spec put_runs_status(Tesla.Env.client(), String.t(), Tesla.Env.body()) ::
  Tesla.Env.result()
Link to this function

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

View Source
@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)

View Source
@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

trace(client, url, opts)

View Source

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)

View Source
@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"})