-1

So I want to create a program that will execute a certain function the moment a Twitch stream goes live in C#. Does anyone have any ideas how I can reliably get that function called the moment the stream goes live? I also want this to be a program that can call that function every single time the stream goes live without requiring a restart of the program.

1 Answers1

1

As per the Twitch API docs

Webhooks enable your application to subscribe to events that happen on Twitch. When an event to which you are subscribed occurs, Twitch notifies you. For example, you may want to know when:

  • A user has a new follower.
  • A stream has changed state.
  • A whisper is sent (future).

For the stream webhook the webhook body includes:

    {
  "data": [
    {
      "id": "0123456789",
      "user_id": "5678",
      "user_name": "wjdtkdqhs",
      "game_id": "21779",
      "community_ids": [],
      "type": "live",
      "title": "Best Stream Ever",
      "viewer_count": 417,
      "started_at": "2017-12-01T10:09:45Z",
      "language": "en",
      "thumbnail_url": "https://link/to/thumbnail.jpg"
    }
  ]
}

You are not very specific with what you mean by "program", but to receive a webhook what you need is an HTTP server, accessible on the internet, which can receive and understand a JSON payload like this one. One option could be serverless functions such as Azure Functions. You could also create a web appliction and host that in some service with a publicly accessible domain name.

Tom W
  • 5,108
  • 4
  • 30
  • 52