JustinLove/elm-twitch-api/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

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 an 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.