Andy Morrell

Twitch Library: First Draft Done

Andy Morrell ·

I have been meaning to build a proper Twitch API library for .NET for a while. The existing options either feel abandoned, don’t cover EventSub properly, or are not structured in a way that plays nicely with dependency injection. So I sat down on Saturday and just built one.

By the end of the day I had a working first draft: 29 typed Helix API interfaces via Refit, all three OAuth flows (Client Credentials, Authorization Code, Device Code), and EventSub support for both WebSocket and Webhook transports. The Webhook side includes HMAC-SHA256 signature verification so you are not just blindly trusting incoming requests.

The Refit approach made the Helix interfaces fast to write. You define an interface, annotate the methods with the HTTP verb and path, and Refit handles the rest at runtime. No manual HttpClient management, no JSON deserialisation boilerplate. It meant I could work through the API surface at pace rather than getting bogged down in plumbing.

The OAuth flows took a bit more thought. Each one has different requirements and different token lifetimes, and the library needs to handle refresh transparently so the consumer does not have to think about it. That part is still a bit rough around the edges, but the core is there.

The plan is to split this into modular NuGet packages so you only pull in what you actually need: Core, Api, EventSub.WebSocket, EventSub.Webhook. No point pulling in WebSocket dependencies if you are only ever using Webhooks.

There is a proper write-up in the articles section if you want the full picture. This is just the “it exists and it works” post.