Is there a reliable way to find VOD id of a live stream?

So I’m using the twitch API to get views for a live stream and logging them along side chat messages. I also want to log VOD clips and their data. But there is no real way to make a relation between the current live stream and the VOD these clips are related to. Someone might have created the clip from previous VOD and so the “created_at” parameter is not a reliable way to find the stream it could be related to.

What do you mean? What kind of relation are you looking for?

When someone streams his/her stream turns into a VOD after he finishes the stream. I’m collecting data right now during the streams (viewer counts and chat logs) and some data after the stream (clips data). I want to know that my clips data is related to which of my stream data.

Hopefully that explains it a bit better.

The clip object returned from the API has the associated VOD ID in it. (json.vod.id)

I know about that. Let’s say the clip had vod.id of 12345. But as I collect viewers and chat logs from multiple live streams, How do I know that a particular live stream (for which I was collecting data) has now turned into VOD.ID 12345?

Assuming you’re starting with an active stream, if you make a call to:
https://api.twitch.tv/kraken/channels/{channelId}/videos

using the channel id provided (broadcast_type = archive) in the get stream request of the stream your following, you’ll get a list of the recent VODs of the channel. The ID you’re looking for would be the most recent VOD, which would be the stream your tracking up to the current time (or shortly before).

As you’re doing it continuously, you can find the VOD matching the current stream by checking which VOD has "status": "recording" using the videos endpoint in the post above.

This is exactly the kind of thing I was looking for! Thanks!

PS: Just to add to swiftyspiffy’s post. You’ll have to add “broadcast=true” parameter to the url so it returns past broadcasts instead of highlights.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.