LuaLua Configuration API Reference for Realtime Apps

Lua complete API reference for building Realtime Applications on PubNub, including basic usage and sample code

require "pubnub"
This function is used for initializing the PubNub Client API context. This function must be called before attempting to utilize any API functionality in order to establish account level credentials such as publish_key and subscribe_key.
To Initialize Pubnub you can use the following method(s) in the Lua SDK:
  1. ParameterTypeRequiredDescription
    configurationtableYesTable of initialization parameters (a kind of prototype to construct the PubNub object from). See Configuration Parameters for more details.
    publish_keystringOptional (required only for publish)noneThe PubNub publish key.
    subscribe_keystringYesnoneThe PubNub subscribe key.
    secret_keystringOptionalnoneThe secret key.
    auth_keystringOptionalnoneThe auth key to access channels.
    sslbooleanOptionalfalseWhether to use SSL to connect to PubNub.
    originstringOptionalps.pndsn.comThe domain name to use to connect to PubNub.
    uuidstringYesauto generated

    UUID to use. You should set a unique UUID to identify the user or the device that connects to PubNub.

    Allowing the SDK to generate a random UUID can result in significant billing impacts, particularly on an MAU pricing plan.

 Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. Not setting the UUID can significantly impact your billing if your account uses the Monthly Active Users (MAUs) based pricing model, and can also lead to unexpected behavior if you have Presence enabled.
require "pubnub"

local pubnub_obj ={
    publish_key = "demo",
    subscribe_key = "demo",
    secret_key = "demo",
    ssl = false,
    origin = ""
It returns the Pubnub instance for invoking PubNub APIs like publish(), subscribe(), history(), here_now(), etc.