Matias Insaurralde

Integrating API Management into your organisation: an introduction to Tyk Plugins

A common requirement for enterprise API Management is integration. It’s rare that Tyk is installed into a complete green-field (wouldn’t that be nice). Instead, our users typically need to deploy Tyk into a busy and complex mesh of existing platforms and services.

Tyk has a whole array of functionality out of the box to make this simple, but sometimes you just have to authenticate against Lotus Notes, or pipe some custom log data into an excel model. Fun times ahead!

We can’t kick Lotus Notes out of your org (though we’d be happy to help – just ask) but we do have you covered with Tyk Plugins to make your life easier.

What are Tyk Plugins?

Tyk Plugins make it simple to extend Tyk and integrate as you require, without forking the gateway. The flexibility Plugins allow mean you can get started immediately, and with no need to wait for changes elsewhere. Instead, you can simply hook Tyk into what you have right now.

OK but really. What are Tyk Plugins?

Tyk Plugins provide a way of modifying the Tyk Gateway behaviour using your favourite languages. A Tyk Plugin contains your own implementation of a HTTP middleware.

Typical use cases for plugins include implementing your own authentication mechanisms instead of using the default ones, integrating with legacy systems or performing additional operations like injecting a header before the request reaches your upstream API.

What type of Plugins do we support?

Tyk supports two types of plugins: gRPC-based plugins and native/built-in ones.

gRPC-based plugins

gRPC is a very powerful RPC protocol created by Google. In simple terms it allows you to perform calls between different programs by using a common protocol called Protocol Buffers, even if these two programs are written in different languages.

The way this fits into the Tyk Infrastructure is that with Tyk gRPC plugins you can implement a gRPC server containing your middleware logic and configure the Tyk Gateway to call it every time a request is proxied. In this scenario, the gRPC server receives the request, runs the middleware code and sends the request back to Tyk where it gets proxied upstream.

This communication occurs over a TCP socket and the user has the flexibility of deploying it in different ways, e.g. using multiple gRPC servers with a load balancer.

To see a list of supported gRPC languages see the official page:

Native/built-in plugins

Native plugins run as part of the Tyk Gateway process. Tyk supports JavaScript plugins by default.

We also provide alternative Tyk builds with Python and Lua support, so now you can get your API Management with Python, or if you prefer, you can manage your API with Lua.

The way this works is by using embedded interpreters. The middleware code contained in your Tyk Plugin is loaded by the interpreter and Tyk performs the appropriate calls to your code when the requests are proxied through the system.

The performance is limited by each language runtime, at the time of writing, we support Python 3.4 and LuaJIT5.1.

JavaScript support is limited to vanilla JavaScript which doesn’t provide the same capabilities as NodeJS. However, if you’re interested in NodeJS API management it’s possible to create a gRPC-based plugin using it.

Building Infrastructure with Tyk

Tyk Plugins are already being taken advantage of by many different teams, used for a whole host of integrations ranging in type and complexity. Two recent examples:

  • A global media brand writing middleware that delivers a bespoke logging function to couple API transactions with a legacy billing platform
  • An Enterprise organisation using custom middleware to transform XML to REST.

If you’d like to discuss your own integration requirements, our consulting engineers are ready and waiting to help – just drop us a message via our Enterprise page. We’ll be happy to discuss your unique requirements and advise on the most appropriate way forward.

A few guides for getting started with Tyk Plugins:

And, if you’re ready to get started now, a good place to begin is with one of our examples: