SelectUpgrading Python Twisted V3 to V4

These docs are for version 3.9.0 of the Python-Twisted SDK. To check out the docs for the latest version Click Here.

PubNub 4.0 for Python-Twisted is our latest and greatest! Please click here for our PubNub 4.0 for Python docs and SDK.

PubNub 3.x for Python-Twisted will encounter End Of Life (EOL) July 1st, 2017. All users currently on 3.x should begin migrating to 4.x. The 3.x SDK will continue to work. We will no longer support it and if you run into an issue, we will request that you upgrade to the latest version before solving the issue.

If you have questions about the PubNub for Python SDK, please contact us at

  • V3 exposes PubnubTwisted
  • V4 exposes PubNubTwisted
 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.
  • V3 initiates via:
    pubnub = Pubnub(publish_key="demo", subscribe_key="demo")
  • V4 initiates via:
    pnconf = PNConfiguration()
    pnconf.subscribe_key = 'demo'
    pnconf.publish_key = 'demo'
    pubnub = PubNub(pnconf)
  • V3 accepts callback and error callbacks as arguments:
    def callback(result):
    def errback(error):
    pubnub.publish('ch', 'Hi', callback=callback, error=errback)
  • V4 sync way
    envelope = yield pubnub.publish().channel('ch').message('Hi').deferred()
  • V3 exposes subscribe callbacks via method params.
  • V4 exposes the functionality via listeners.
  • V4 returns a status object for each transactional request in the envelope and in the status portion of a listener or a callback.