Maybe you were looking for the Enterprise Edition (EE) Documentation instead?

Table of Contents

Plugin Development Kit

The Plugin Development Kit (or “PDK”) is set of Lua functions and variables that can be used by plugins to implement their own logic. The PDK is a Semantically Versioned component, originally released in Kong 0.14.0. The PDK will be guaranteed to be forward-compatible from its 1.0.0 release and on.

As of this release, the PDK has not yet reached 1.0.0, but plugin authors can already depend on it for a safe and reliable way of interacting with the request, response, or the core components.

The Plugin Development Kit is accessible from the kong global variable, and various functionalities are namespaced under this table, such as kong.request, kong.log, etc…

kong.version

A human-readable string containing the version number of the currently running node.

Usage

print(kong.version) -- "0.14.0"

Back to TOC

kong.version_num

An integral number representing the version number of the currently running node, useful for comparison and feature-existence checks.

Usage

if kong.version_num < 13000 then -- 000.130.00 -> 0.13.0
  -- no support for Routes & Services
end

Back to TOC

kong.pdk_major_version

A number representing the major version of the current PDK (e.g. 1). Useful for feature-existence checks or backwards-compatible behavior as users of the PDK.

Usage

if kong.pdk_version_num < 2 then
  -- PDK is below version 2
end

Back to TOC

kong.pdk_version

A human-readable string containing the version number of the current PDK.

Usage

print(kong.pdk_version) -- "0.1.0"

Back to TOC

kong.configuration

A read-only table containing the configuration of the current Kong node, based on the configuration file and environment variables.

See kong.conf.default for details.

Comma-separated lists in that file get promoted to arrays of strings in this table.

Usage

print(kong.configuration.prefix) -- "/usr/local/kong"
-- this table is read-only; the following throws an error:
kong.configuration.custom_plugins = "foo"

Back to TOC

kong.dao

Instance of Kong’s legacy DAO. This has the same interface as the object returned by new(config, db) in the core’s kong.dao.factory module.

Back to TOC

kong.db

Instance of Kong’s DAO (the new kong.db module). Contains accessor objects to various entities.

A more thorough documentation of this DAO and new schema definitions is to be made available in the future, once this object will replace the old DAO as the standard interface with which to create custom entities in plugins.

Usage

kong.db.services:insert()
kong.db.routes:select()

Back to TOC

kong.dns

Instance of Kong’s DNS resolver, a client object from the lua-resty-dns-client module.

Note: usage of this module is currently reserved to the core or to advanced users.

Back to TOC

kong.worker_events

Instance of Kong’s IPC module for inter-workers communication from the lua-resty-worker-events module.

Note: usage of this module is currently reserved to the core or to advanced users.

Back to TOC

kong.cluster_events

Instance of Kong’s cluster events module for inter-nodes communication.

Note: usage of this module is currently reserved to the core or to advanced users.

Back to TOC

kong.cache

Instance of Kong’s database caching object, from the kong.cache module.

Note: usage of this module is currently reserved to the core or to advanced users.

Back to TOC