SDKs

Use QPub's official SDKs to quickly integrate real-time features into your applications.

Available SDKs

JavaScript/TypeScript

npm install @qpub/sdk @qpub/rest-sdk

Python

pip install qpub-sdk

Go

go get github.com/qpub/go-sdk

Java

<dependency>
  <groupId>com.qpub</groupId>
  <artifactId>qpub-java-sdk</artifactId>
  <version>1.0.0</version>
</dependency>

JavaScript SDK

Socket SDK

import { QPubSocket } from '@qpub/sdk';

const client = new QPubSocket({
  apiKey: 'your-api-key'
});

// Subscribe to channel
client.subscribe('my-channel', (message) => {
  console.log('Received:', message);
});

// Publish message
client.publish('my-channel', {
  text: 'Hello, World!'
});

REST SDK

import { QPubREST } from '@qpub/rest-sdk';

const client = new QPubREST({
  apiKey: 'your-api-key'
});

// Create channel
const channel = await client.createChannel({
  name: 'my-channel'
});

// Send message
await client.publish('my-channel', {
  text: 'Hello, World!'
});

Python SDK

from qpub import QPubSocket

client = QPubSocket(api_key='your-api-key')

# Subscribe to channel
def on_message(message):
    print(f"Received: {message}")

client.subscribe('my-channel', on_message)

# Publish message
client.publish('my-channel', {
    'text': 'Hello, World!'
})

Go SDK

package main

import (
    "github.com/qpub/go-sdk"
)

func main() {
    client := qpub.NewSocketClient("your-api-key")
    
    // Subscribe to channel
    client.Subscribe("my-channel", func(message qpub.Message) {
        fmt.Printf("Received: %v\n", message)
    })
    
    // Publish message
    client.Publish("my-channel", map[string]interface{}{
        "text": "Hello, World!",
    })
}

SDK Features

  • Automatic Reconnection: Handle connection failures gracefully
  • Message Queuing: Queue messages when offline
  • Type Safety: Full TypeScript support for JavaScript SDK
  • Error Handling: Comprehensive error handling and reporting
  • Documentation: Extensive documentation and examples

This page is under construction. SDK documentation will be expanded soon.