JustinLove/elm-twitch-api/5.0.0

NOTE: the latest version is 7.0.0

Twitch.Helix

Helpers for sending Http requests to the Twitch Helix ("new Twitch API") endpoints.

Send a Request

{ clientId : String
, auth : Maybe String
, decoder : Decoder a
, tagger : Result Error a -> msg
, url : String
}
-> Cmd msg

Send a basic request to the Twitch Helix ("new Twitch API") endpoints. Lightweight wrapper around Http, so you can go back to basics if something else is needed. Auth is a token received from an oauth loop.

fetchUserByNameUrl : String -> String
fetchUserByNameUrl login =
  "https://api.twitch.tv/helix/users?login=" ++ login


fetchUserByName : String -> Cmd Msg
fetchUserByName login =
  Twitch.Helix.send <|
    { clientId = TwitchId.clientId
    , auth = Nothing
    , decoder = Twitch.Helix.Decode.users
    , tagger = User
    , url = (fetchUserByNameUrl login)
    }

Header Helpers

Useful if you need to make your own Http call with additional headers.

twitchHeaders : String -> Maybe String -> List Header

Creates the client-id and outh headers.

Twitch.Helix.twitchHeaders clientId auth
authHeaders : Maybe String -> List Header

Creates the oauth header, given an oauth token.