Customers / MUX

You should maximize the time developers spend on their product and minimize the time spent with your SDK.”

100k
SDK downloads per week

Mux upgrades its client libraries to Stainless

“The only acceptable solution to going down the auto-generation route would be if it resulted in an SDK that was much better than our current one. This was a hard line we weren’t willing to compromise on.”

Dylan Jhaveri
Director of Self Service

Mux is a video streaming API that provides developers with tools to build and manage high-quality video experiences within their applications. The API simplifies the complexities of video encoding, hosting, and delivery through a robust set of features that include automatic adjustments for streaming quality based on the viewer's bandwidth.

Before Stainless, Mux had a six-year-old Node SDK for making server-side API requests. It was originally written in JavaScript (not TypeScript) and they added types by hand over the years, laying on code as they tried to keep up with Mux's evolving platform.

Over the past few years, the mux-node SDK hadn’t been living up to their standards. It was difficult to maintain, had TypeScript inconsistencies, and lacked support for the increasingly diverse ecosystem of modern JavaScript runtimes. They needed to rethink their SDK strategy and find a solution that satisfied all of those requirements.

CODE GENERATION

“Lucky for us, we got in touch with the folks from Stainless.”

Based on their previous experience with code generation, they were skeptical that it would meet their needs, but the SDKs generated by Stainless exceeded their expectations. The latest mux-node SDK in production now is produced by Stainless. It gives them:

Automatically generated code based on their OpenAPI spec
Utilities that are not represented in the spec, like JWT generation and webhook signature verification
Support for additional JavaScript runtimes alongside Node
Real TypeScript types based on their OpenAPI spec
High-quality, idiomatic code. Unlike other solutions for generating SDKs, the code actually looks and feels like something a developer would design

And other nice quality-of-life things that they were missing before:

Retry configurations for failed requests
Automatic pagination with asynchronous iterators that support “for await” syntax
A better pattern for accessing raw responses
The ability to make custom requests to undocumented endpoints (which is useful for making requests against staging servers or when testing new functionality in beta)
Support for configuring HTTP proxies
Logging and middleware to customize the fetch client
MIGRATION SUPPORT

“Big breaking changes suck, and you should (almost) never do them.”

Mux adhered to a philosophy of avoiding significant breaking changes in its SDK. The company recognized the substantial burden such updates place on developers, requiring extensive code alterations, rigorous testing, and deployment processes—all detracting from product development time. However, the growing technical debt and maintenance challenges of the legacy SDK compelled Mux to reconsider this stance. With ~100k downloads per week, Node is their most popular server-side SDK, so they did not take the decision to make a clean break lightly.

To make for a smooth migration, Stainless helped provide a migration tool that performs a codemod to enable developers upgrade from their legacy SDK to the new SDK generated by Stainless. Running this local script modifies all existing code and updates it to the new SDK.

Hands on migration support
Minimal user disruption for a breaking change
This case study is informed by insights from the Mux blog post

Keeping up with the Node-ish ecosystem : Mux's migration to Stainless

See article

Now we feel like we’re in a place where we can scale the usage of this SDK to 1 million and 10 million weekly downloads.”

Dylan Jhaveri
Director of Self Service