Skip to main content

A Python wrapper for the SocketBee.

Project description

SocketBee for Python

SocketBee is a Python client for interacting with the SocketBee API. This library allows you to easily send events to your SocketBee application.

Installation

You can install the SocketBee library via pip:

pip install socketbee

Usage

To use SocketBee in your Python application, you need to create an instance of the SocketBee class with your application credentials. Then, you can use this instance to send events to your SocketBee channels.

Example

import socketbee

# Initialize the SocketBee instance with your credentials
app_id = 'your_app_id'
secret = 'your_secret'
key = 'your_key'

# Optionally, you can provide additional configuration
config = {
    'protocol': 'https',
    'host': 'east-1.socket.socketbee.com',
    'port': 443,
}

socketbee_instance = socketbee.SocketBee(app_id, secret, key, config)

# Send an event
channel = 'my_channel'
event = 'my_event'
data = {
    'message': 'Hello, world!',
}

response = socketbee_instance.send_event(channel, event, data)

# Check the response
print(response)

Parameters

  • app_id: Your SocketBee application ID.
  • secret: Your SocketBee secret key.
  • key: Your SocketBee key.
  • config (optional): A dictionary containing the following optional configuration parameters:
    • protocol: The protocol to use (default: https).
    • host: The host of the SocketBee server (default: east-1.socket.socketbee.com).
    • port: The port of the SocketBee server (default: 443).

Methods

send_event(channel, event, data)

Sends an event to the specified channel.

  • channel: The channel to send the event to.
  • event: The name of the event.
  • data: A dictionary containing the event data.

Response

The send_event method returns a dictionary with the following keys:

  • status: The HTTP status code of the response.
  • body: The body of the response.
  • errors (optional): The error message, if an error occurred.
  • error_message (optional): The error message, if a request exception occurred.

Error Handling

If a requests.exceptions.RequestException is raised during the API call, the send_event method will return a dictionary containing the status set to 0 and an error_message describing the exception.

Links

License

This project is licensed under the MIT License. See the LICENSE file for more details.


For more information and detailed documentation, please refer to the official SocketBee documentation.

Happy coding with SocketBee!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

socketbee-0.1.4.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

socketbee-0.1.4-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file socketbee-0.1.4.tar.gz.

File metadata

  • Download URL: socketbee-0.1.4.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.6

File hashes

Hashes for socketbee-0.1.4.tar.gz
Algorithm Hash digest
SHA256 fdc713554425470168562247fdc25b53dbdb7700a15e1b3c9a7969c9ffde2af0
MD5 98538bf30d81f5d90a344e3f8007cbe9
BLAKE2b-256 33d4ec068b691fa5413ead173ac454529713e391db1d9a21962b52028bdc0551

See more details on using hashes here.

File details

Details for the file socketbee-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: socketbee-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.6

File hashes

Hashes for socketbee-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e29f298a95c377f45c8e083890f2f89cfb61c8c05f80d43e0d9f485f52771a45
MD5 d2bbf954cd3a48c9452dba24bcbb5a63
BLAKE2b-256 5a58ec28f11c39c3488d70b23ee619a4d4d1d11a74947d95fa5e082e4259a561

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page