News KrakenD CE v2.8 released with improved Lua and OpenTelemetry

Document updated on Nov 26, 2024

Introduction to Request and Response Manipulation

Introduction to Request and Response Manipulation

One of KrakenD’s standout features is its powerful capability to manipulate requests and responses, allowing you to shape data flows to meet your application’s needs. With KrakenD, you can transform incoming requests and outgoing responses on the fly, ensuring your APIs are efficient and perfectly aligned with your business logic. Whether you need to filter sensitive information, restructure payloads, enrich responses, or enforce specific rules, KrakenD provides a robust toolkit to get the job done.

Before you start digging into manipulation, identify which part of the request or response needs modification and define the transformation logic. Then, choose the right components from the range of declarative configurations to suit different manipulation tasks. There are several components at your disposal that we could group as follows:

  • Request and response transformation: Functionality to rewrite paths, filter parameters, or inject new data based on specific logic, adjust responses before they reach the client, add or remove fields, aggregate data, or change formats to match client expectations.
  • Protocol mapping and performance: Translate and reformat payload structures, ensuring automatic encoding conversion from APIs with differing formats. Employ cache or gzipped responses to increase delivery speed.
  • Request and response validation: Although not a manipulation itself, it allows you to abort requests or responses that do not have compliant data.

Data transformation and aggregation

KrakenD dynamically reshapes, filters, and transforms requests and responses, ensuring compatibility between clients and backends. This simplifies payloads, improves performance, and customizes data delivery to fit client needs. The components available to transform data are:

In addition, the Enterprise edition allows you to set complex logic:

Protocol mapping and performance

KrakenD transparently converts data from one format to another and even transforms protocols. It ensures smooth integration with various systems and optimizes payload sizes for better efficiency. Some functionalities covering this are:

On Enterprise :

  • SOAP: Craft the body and XML content you will send to a SOAP service and treat it back as XML or JSON automatically.
  • Gzip Compression: Optimize payload size with Gzip compression
  • Static server: Use the gateway as a static web server

Request and response validation

In addition to transforming data and protocols, you can also validate requests and responses against JSON Schema definitions or enforce size restrictions to maintain data integrity. These features ensure data compliance, protect against oversized payloads and enhance system reliability.

Plus on the Enterprise :

Why manipulate requests and responses?

Modern APIs must often adapt to varying client requirements, integrate with legacy systems, or comply with stringent data security and performance standards. In addition, most of the time, implementors of these APIs do not have control over the origin of the data. Request and response manipulation allows you to:

  • Optimize payloads: Remove unnecessary data or transform structures to enhance performance. Sending fewer bytes through the network increases the user experience and conversion rates.
  • Enforce data standards: Standardize payload formats, validate fields, or inject default values.
  • Enhance security: Mask or strip sensitive information before delivering it to clients or backends.
  • Support dynamic use cases: Apply custom transformations tailored to different user roles or device types.

Contribute to KrakenD Documentation. Improve this page »

Scarf

Unresolved issues?

The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.

See all support channels