Using YARP to manage your APIs

Using YARP to manage your APIs

Managing APIs is a complex task. When we’re looking at Microsoft and Azure, then Azure API Management comes to mind. A very powerful tool, but a very costly one. And sometimes, it’s just plain overkill for your use-case.

That’s where YARP comes in. Although not as feature-rich as Azure API management, maybe it’s more than enough for your use cases.

In this article I wanted to share some features of YARP, and an example project to help you get started.

What is YARP?

Reverse proxy example

YARP (Yet Another Reverse Proxy), as the name implies, is first and foremost a reverse proxy. But over time, more and more features have been added that make it a possible alternative to use for managing your APIs.

Some cool features include:

  • Load balancing
  • Transforms
  • gRPC
  • Websockets
  • Authentication and authorization
  • Header routing
  • Health checks
  • Rate limiting
  • ….

Take a look at the documentation for the entire list of features: https://microsoft.github.io/reverse-proxy/articles/index.html

To get started with YARP, check out their Getting Started article: https://microsoft.github.io/reverse-proxy/articles/getting-started.html

Flexible and customizable

I set up YARP for a project I’m currently working on, and it was incredibly easy. However, the true power of YARP is in its customization and flexibility. It’s built on top of ASP.NET and .NET 6+. Customizability is also a core feature of YARP.

To quote the documentation:

YARP is designed with customizability as a primary scenario rather than requiring you to break out to script or rebuild the library from source.

This means we can just write any missing feature ourselves using our knowledge of ASP.NET and C#!

Sample project

I created a sample project that has authentication, authorization, transforms, and load balancing included. You can find it here:

https://github.com/nstubbe/YarpExample