Skip to content
Kong Logo | Kong Docs Logo
search
  • Docs
    • Explore the API Specs
      View all API Specs View all API Specs View all API Specs arrow image
    • Documentation
      API Specs
      Kong Gateway
      Lightweight, fast, and flexible cloud-native API gateway
      Kong Konnect
      Single platform for SaaS end-to-end connectivity
      Kong Mesh
      Enterprise service mesh based on Kuma and Envoy
      decK
      Helps manage Kong’s configuration in a declarative fashion
      Kong Ingress Controller
      Works inside a Kubernetes cluster and configures Kong to proxy traffic
      Kong Gateway Operator
      Manage your Kong deployments on Kubernetes using YAML Manifests
      Insomnia
      Collaborative API development platform
      Kuma
      Open-source distributed control plane with a bundled Envoy Proxy integration
  • Plugin Hub
    • Explore the Plugin Hub
      View all plugins View all plugins View all plugins arrow image
    • Functionality View all View all arrow image
      View all plugins
      Authentication's icon
      Authentication
      Protect your services with an authentication layer
      Security's icon
      Security
      Protect your services with additional security layer
      Traffic Control's icon
      Traffic Control
      Manage, throttle and restrict inbound and outbound API traffic
      Serverless's icon
      Serverless
      Invoke serverless functions in combination with other plugins
      Analytics & Monitoring's icon
      Analytics & Monitoring
      Visualize, inspect and monitor APIs and microservices traffic
      Transformations's icon
      Transformations
      Transform request and responses on the fly on Kong
      Logging's icon
      Logging
      Log request and response data using the best transport for your infrastructure
  • Support
  • Community
  • Kong Academy
Get a Demo Start Free Trial
Kong Gateway
2.8.x
  • Home icon
  • Kong Gateway
  • PDK
github-edit-pageEdit this page
report-issueReport an issue
  • Kong Gateway
  • Kong Konnect
  • Kong Mesh
  • Plugin Hub
  • decK
  • Kong Ingress Controller
  • Kong Gateway Operator
  • Insomnia
  • Kuma

  • Docs contribution guidelines
  • 3.5.x (latest)
  • 3.4.x
  • 3.3.x
  • 3.2.x
  • 3.1.x
  • 3.0.x
  • 2.8.x
  • 2.7.x
  • 2.6.x
  • Archive (pre-2.6)
enterprise-switcher-icon Switch to OSS
On this pageOn this page
  • kong.version
  • kong.version_num
  • kong.pdk_major_version
  • kong.pdk_version
  • kong.configuration
  • kong.db
  • kong.dns
  • kong.worker_events
  • kong.cluster_events
  • kong.cache
You are browsing documentation for an outdated version. See the latest documentation here.

PDK

The Plugin Development Kit (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 is guaranteed to be forward-compatible from its 1.0.0 release and onward.

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) -- "2.0.0"

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

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_major_version < 2 then
  -- PDK is below version 2
end

kong.pdk_version

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

Usage

print(kong.pdk_version) -- "1.0.0"

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 the kong.conf 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.prefix = "foo"

kong.db

Instance of Kong’s DAO (the 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.

Usage

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

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.

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.

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.

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.

Thank you for your feedback.
Was this page useful?
Too much on your plate? close cta icon
More features, less infrastructure with Kong Konnect. 1M requests per month for free.
Try it for Free
  • Kong
    Powering the API world

    Increase developer productivity, security, and performance at scale with the unified platform for API management, service mesh, and ingress controller.

    • Products
      • Kong Konnect
      • Kong Gateway Enterprise
      • Kong Gateway
      • Kong Mesh
      • Kong Ingress Controller
      • Kong Insomnia
      • Product Updates
      • Get Started
    • Documentation
      • Kong Konnect Docs
      • Kong Gateway Docs
      • Kong Gateway Enterprise Docs
      • Kong Mesh Docs
      • Kong Insomnia Docs
      • Kong Konnect Plugin Hub
    • Open Source
      • Kong Gateway
      • Kuma
      • Insomnia
      • Kong Community
    • Company
      • About Kong
      • Customers
      • Careers
      • Press
      • Events
      • Contact
  • Terms• Privacy• Trust and Compliance
© Kong Inc. 2023