JustinLove/elm-twitch-api/5.0.1

NOTE: the latest version is 7.0.0

Twitch.Helix.Decode

Decoders for the Helix API.

Users

type alias User =
{ id : String
, login : String
, displayName : String
, userType : String
, broadcasterType : String
, description : String
, profileImageUrl : String
, offlineImageUrl : String
, viewCount : Int
, email : Maybe String
}

Record for decoded users.

users : Decoder (List User)

Json Decoder for users

Follows

type alias Follow =
{ fromId : String
, fromName : String
, toId : String
, toName : String
, followedAt : Posix
}

Record for a decoded follow

follows : Decoder (List Follow)

Json Decoder for follows

Streams

type alias Stream =
{ channelId : String
, userId : String
, userName : String
, gameId : String
, title : String
, viewerCount : Int
, startedAt : Posix
, language : String
, thumbnailUrl : String
, tagIds : List String
}

Record for decoded Streams data

streams : Decoder (List Stream)

Json Decoder from streams

Games

type alias Game =
{ id : String
, name : String
, boxArtUrl : String
}

Record for decoded Game

games : Decoder (List Game)

Json Decoder for games

Videos

type alias Video =
{ id : String
, userId : String
, title : String
, description : String
, createdAt : Posix
, publishedAt : Posix
, url : String
, thumbnailUrl : String
, viewable : Viewable
, viewCount : Int
, language : String
, videoType : VideoType
, duration : Int
}

Record for decoded videos. viewable, video_type, and duration are lightly interpreted.

= Upload
| Archive
| Highlight
| Other String

Enumerated type for video_type attribute, does include an escape hatch in case other types are added in the future.

= Public
| Private

Enumerted type for the viewable status

videos : Decoder (List Video)

Json Decoder for videos

Clips

type alias Clip =
{ id : String
, url : String
, embedUrl : String
, broadcasterId : String
, creatorId : String
, videoId : String
, gameId : String
, language : String
, title : String
, viewCount : Int
, createdAt : Posix
, thumbnailUrl : String
}

Record for a decoded clip.

clips : Decoder (List Clip)

Json Decoder for clips.

Bits Leaderboard

type alias BitsLeader =
{ userId : String
, userName : String
, rank : Int
, score : Int
}

Record for a decoded bits leader.

bitsLeaderboard : Decoder (List BitsLeader)

Json Decoder for bits leaderboard.

Subscriptions

type alias Subscription =
{ broadcasterId : String
, broadcasterName : String
, isGift : Bool
, tier : String
, planName : String
, userId : String
, userName : String
}

Record for a decoded subscription.

subscriptions : Decoder (List Subscription)

Json Decoder for subscriptions

OAuth tokens

type alias Token =
{ sub : String
, iss : String
, aud : String
, exp : Int
, iat : Int
}

Record for decoded OAuth tokens

token : Decoder Token

Json Decoder for OAuth tokens.

userId = token
  |> Maybe.andThen (Result.toMaybe << Jwt.decodeToken Twitch.Helix.Decode.token)
  |> Maybe.map .sub

Sample data

sampleToken : String

Sample OAuth token.

sampleUser : String

Sample data for a user

sampleStream : String

Sample data for streams

sampleGame : String

Sample data for games

sampleFollow : String

Sample data for follows

sampleVideo : String

Sample data for a video

sampleClip : String

Sample data for a clip.

Sample data for bits leaderboard.

Sample data for subscriptions