View Source TwitchAPI (hello_twitch_api v0.5.1)

Twitch API.

You can make requests to Twitch API endpoints.

Examples

client_id = "asdsdksdl93roi39"
access_token = "09wriujr329jd023920dk203kd0932d"

auth = TwitchAPI.Auth.new(client_id, access_token)

case TwitchAPI.get(auth, "/users") do
  {:ok, %{body: users}} ->
    IO.inspect(users, label: "Successful response body")

  {:error, resp} ->
    IO.inspect(resp, label: "We got an error")
end

Summary

Functions

Build a base Req.Request.t/0 for Twitch API requests.

Make a Twitch API DELETE request. Returns :ok or :error tuples.

Make a Twitch API DELETE request. Raises on error or unexpected HTTP status.

Make a Twitch API GET request. Returns :ok or :error tuples.

Make a Twitch API GET request. Raises on error or unexpected HTTP status.

Make a Twitch API HEAD request. Returns :ok or :error tuples.

Make a Twitch API HEAD request. Raises on error or unexpected HTTP status.

Make a Twitch API PATCH request. Returns :ok or :error tuples.

Make a Twitch API PATCH request. Raises on error or unexpected HTTP status.

Make a Twitch API POST request. Returns :ok or :error tuples.

Make a Twitch API POST request. Raises on error or unexpected HTTP status.

Make a Twitch API PUT request. Returns :ok or :error tuples.

Make a Twitch API PUT request. Raises on error or unexpected HTTP status.

Types

Functions

@spec client(auth()) :: Req.Request.t()

Build a base Req.Request.t/0 for Twitch API requests.

You can pass either this or a TwitchAPI.Auth.t/0 struct to the request functions.

NOTE: You probably only want to use this directly if you want to do something different than the default.

Link to this function

delete(auth_or_client, endpoint, opts \\ [])

View Source
@spec delete(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: {:ok, Req.Response.t()} | {:error, term()}

Make a Twitch API DELETE request. Returns :ok or :error tuples.

Link to this function

delete!(auth_or_client, endpoint, opts \\ [])

View Source
@spec delete!(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: Req.Response.t()

Make a Twitch API DELETE request. Raises on error or unexpected HTTP status.

Link to this function

get(auth_or_client, endpoint, opts \\ [])

View Source
@spec get(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: {:ok, Req.Response.t()} | {:error, term()}

Make a Twitch API GET request. Returns :ok or :error tuples.

Link to this function

get!(auth_or_client, endpoint, opts \\ [])

View Source
@spec get!(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: Req.Response.t()

Make a Twitch API GET request. Raises on error or unexpected HTTP status.

Link to this function

head(auth_or_client, endpoint, opts \\ [])

View Source
@spec head(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: {:ok, Req.Response.t()} | {:error, term()}

Make a Twitch API HEAD request. Returns :ok or :error tuples.

Link to this function

head!(auth_or_client, endpoint, opts \\ [])

View Source
@spec head!(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: Req.Response.t()

Make a Twitch API HEAD request. Raises on error or unexpected HTTP status.

Link to this function

patch(auth_or_client, endpoint, opts \\ [])

View Source
@spec patch(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: {:ok, Req.Response.t()} | {:error, term()}

Make a Twitch API PATCH request. Returns :ok or :error tuples.

Link to this function

patch!(auth_or_client, endpoint, opts \\ [])

View Source
@spec patch!(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: Req.Response.t()

Make a Twitch API PATCH request. Raises on error or unexpected HTTP status.

Link to this function

post(auth_or_client, endpoint, opts \\ [])

View Source
@spec post(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: {:ok, Req.Response.t()} | {:error, term()}

Make a Twitch API POST request. Returns :ok or :error tuples.

Link to this function

post!(auth_or_client, endpoint, opts \\ [])

View Source
@spec post!(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: Req.Response.t()

Make a Twitch API POST request. Raises on error or unexpected HTTP status.

Link to this function

put(auth_or_client, endpoint, opts \\ [])

View Source
@spec put(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: {:ok, Req.Response.t()} | {:error, term()}

Make a Twitch API PUT request. Returns :ok or :error tuples.

Link to this function

put!(auth_or_client, endpoint, opts \\ [])

View Source
@spec put!(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  opts :: keyword()
) :: Req.Response.t()

Make a Twitch API PUT request. Raises on error or unexpected HTTP status.

Link to this function

stream!(auth_or_client, endpoint, direction, opts \\ [])

View Source
@spec stream!(
  auth_or_client :: auth() | Req.Request.t(),
  endpoint :: String.t(),
  direction :: :before | :after,
  opts :: keyword()
) :: Enumerable.t()

GET pages from Twitch API as a Stream.

You can start at a cursor if you pass in :cursor as one of the opts.