JustinLove / elm-twitch-api / 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 : Json.Decode.Decoder Twitch.Helix.VideoId

Id of the video

userId : Json.Decode.Decoder Twitch.Helix.UserId

Id of the channel the video is from

userLogin : Json.Decode.Decoder String

Login of the channel the video is from

userName : Json.Decode.Decoder String

Name of the channel the video is from

title : Json.Decode.Decoder String

Title of the video

description : Json.Decode.Decoder String

Description of the video

createdAt : Json.Decode.Decoder Time.Posix

Time the video was created

publishedAt : Json.Decode.Decoder Time.Posix

Time the video was published

url : Json.Decode.Decoder String

Url to view the video

thumbnailUrl : Json.Decode.Decoder String

Thumbnail

language : Json.Decode.Decoder String

Language code


type Viewable
    = Public
    | Private

Enumerted type for the viewable status

viewable : Json.Decode.Decoder Viewable

Whether the video is public or private

viewCount : Json.Decode.Decoder Basics.Int

Number of views on the video

videoType : Json.Decode.Decoder VideoType

Type of the video


type VideoType
    = 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 : Json.Decode.Decoder Basics.Int

Number of milliseconds, with second accuracy

Response decoder

response : Json.Decode.Decoder a -> Json.Decode.Decoder (List a)

Decode individual records from the api response using the specified decoder

Sample Data

sampleVideo : String

Sample response for a video