Over a million developers have joined DZone.

Ocelot: The API Gateway Framework for .NET

DZone's Guide to

Ocelot: The API Gateway Framework for .NET

When building a large and complex system using the microservices architecture with multiple client apps, a good approach to consider is API Gateway Pattern.

· Integration Zone ·
Free Resource

WSO2 is the only open source vendor to be named a leader in The Forrester Wave™: API Management Solutions, Q4 2018 Report. Download the report now or try out our product for free.

First of All, What Is an API Gateway?

An API Gateway is basically an interface in which it receives calls and redirects to internal services. Basically, it is used for the following purposes:

  • Filtering
  • Traffic Routing
  • Security Mechanism
  • Expose only one endpoint

API Gateway Pattern

When building a large and complex system using the microservices architecture with multiple client apps, a good approach to consider is API Gateway Pattern.

This pattern provides a single entry-point for group(s) of microservices. A variation of the API Gateway pattern is also known as the “backend for frontend” (BFF) because you might create multiple API Gateways depending on the different needs from each client app.

Therefore, the API Gateway sits between the client apps and the microservices. It acts as a reverse proxy, routing requests from clients to services.

It can also provide additional cross-cutting features such as authentication, SSL termination, and cache.


Now, let's talk our main subject, Ocelot:

Ocelot is an API Gateway for .NET platform. This project is intended for people using .NET/Core running a micro service/service oriented architecture that needs a unified entry point on their system. However, it will work with anything that uses HTTP and runs on any platform supported by ASP.NET Core.

In my POC with Ocelot I've been very successful in different scenarios, I have been testing Load Balancing, Caching, Routing, Authentication (with JWT) and Service Discovery with very powerful tool (Consul.io).

If you are looking for an API Gateway solution I recommend take a look into Ocelot, I added in this article links to Ocelot documentation and POC that I've created with .NET Core 2.1

It's good to mention that Ocelot is an OpenSource project, I am part of the Three Mammals team, contributing to the tool/platform with bugfixes, and improvements, so if you're a contributor, feel free to create some PR's, I will be happy to check it out!

Ocelot Features:

  • Routing
  • Request Aggregation
  • Service Discovery with Consul & Eureka
  • Service Fabric
  • WebSockets
  • Authentication
  • Authorization
  • Rate Limiting
  • Caching
  • Retry policies/QoS
  • Load Balancing
  • Logging/Tracing/Correlation
  • Headers/Query String/Claims Transformation
  • Custom Middleware/Delegating Handlers
  • Configuration/Administration REST API
  • Platform/Cloud Agnostic

More information can be found here:


API Gateway with Ocelot POC


Ocelot GitHub Repo:


IAM is now more than a security project. It’s an enabler for an integration agile enterprise. If you’re currently evaluating an identity solution or exploring IAM, join this webinar.

microservices ,api ,gateway ,service discovery ,consul ,rest api ,ocelot ,integration ,api gateway pattern ,.net

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}