Build a response from multiple APIsv3.10+

Configure the Request Callout plugin to call multiple APIs and build a response with elements from different responses.

In this example, we’ll get a UUID from http://httpbin.org/uuid and an origin URL from http://httpbin.org/anything.

Set up the plugin

Add this section to your declarative configuration file:

_format_version: "3.0"
plugins:
  - name: request-callout
    config:
      callouts:
      - name: c1
        request:
          url: http://httpbin.org/uuid
          method: GET
        response:
          body:
            decode: true
      - name: c2
        request:
          url: http://httpbin.org/anything
          method: GET
        response:
          body:
            decode: true
      upstream:
        by_lua: kong.response.exit(200, { uuid = kong.ctx.shared.callouts.c1.response.body.uuid,
          origin = kong.ctx.shared.callouts.c2.response.body.url})
Copied to clipboard!

Did this doc help?

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!