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.
GET pages from Twitch API as a Stream
.
Types
@type auth() :: TwitchAPI.Auth.t() | TwitchAPI.AuthStore.name() | pid()
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.
@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.
@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.
@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.
@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.
@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.
@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.
@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.
@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.
@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.
@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.
@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.
@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.
@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
.