JustinLove/elm-twitch-api/7.0.0

Twitch.Helix.Video

JSON Decoders for Helix Video responses

Use these pieces to pull out the parts your application needs.

import Twitch.Helix.Video as Video
import Json.Decode exposing (..)


events : Decoder (List Event)
events =
  Video.response video
    |> map (List.filterMap (\(videoType, ev) -> if videoType == Video.Archive then Just ev else Nothing))


video : Decoder (Video.VideoType, Event)
video =
  map2 Tuple.pair
    Video.videoType
    event


event : Decoder Event
event =
  map2 Event
    Video.createdAt
    Video.duration

Field decoders

id : Decoder VideoId

Id of the video

userId : Decoder UserId

Id of the channel the video is from

userLogin : Decoder String

Login of the channel the video is from

userName : Decoder String

Name of the channel the video is from

title : Decoder String

Title of the video

description : Decoder String

Description of the video

createdAt : Decoder Posix

Time the video was created

publishedAt : Decoder Posix

Time the video was published

url : Decoder String

Url to view the video

thumbnailUrl : Decoder String

Thumbnail

language : Decoder String

Language code

= Public
| Private

Enumerted type for the viewable status

viewable : Decoder Viewable

Whether the video is public or private

viewCount : Decoder Int

Number of views on the video

Type of the video

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

duration : Decoder Int

Number of milliseconds, with second accuracy

Response decoder

response : Decoder a -> Decoder (List a)

Decode individual records from the api response using the specified decoder

Sample Data

sampleVideo : String

Sample response for a video