Skip to main content

Ascender LiveAPI Protocol - for live API communication.

Project description

Ascender LiveAPI Protocol (ALP)

Ascender LiveAPI Protocol (ALP) is a structured, Socket.IO-based event system for real-time communication between clients and backend services. It is simple and easy-to-use implementation of SocketIO into Ascender Framework with framework's architecture and DI support.


Getting Started

Prerequisites

Ensure you have the following dependencies installed:

  • Python 3.11 or higher
  • Ascender Framework 2.0 or higher
  • Poetry (for dependency management)
  • pip (Python's package manager)

Installation

  1. Initiate Ascender Framework Project (if not already):

    ascender new --name example-alp
    ...
    cd example-alp
    
  2. Add ALP as a package to the project:

    poetry add ascender-alp
    
  3. Add provider in bootstrap: In src/bootstrap.py add

    # src/bootstrap.py
    from alp import provideALP
    from ascender.core.types import IBootstrap
    
    appBootstrap: IBootstrap = {
       "providers": [
          provideALP()
       ]
    }
    
  4. Add an ALPReceiver in your controller: To handle incoming events/messages, use decorator @ALPReceiver in your controller.

    from alp import ALPReceiver
    
    @Controller(
       standalone=True,
    )
    class ChatGateway:
    
       @ALPReceiver("connect", namespace="/chats")
       async def handle_connect(self, sid: str):
          print(f"[ALP] Client connected: {sid}")
    
       @ALPReceiver("chat-toggle", namespace="/chats")
       async def toggle_chat(self, sid: str, data: UUID):
          print(f"[ALP] Chat toggled: {data}")
          return {"status": "ok"}
    
  5. Emit event / Send message via Transmitter: If you need to send message or emit any event, you can use ALP's TransmitterModule and Transmitter object. To use Transmitter object, you should import TransmitterModule in your AscModule or Controller if one is standalone specifying namespace if required.

    from alp import TransmitterModule, ALPReceiver, Transmitter
    from ascender.common import BaseDTO
    
    class MessageDTO(BaseDTO):
       sender_id: str
       message: str
    
    
    @Controller(
       standalone=True,
       imports=[
          TransmitterModule.with_namespace("/chats")
       ]
    )
    class ChatGateway:
    
       def __init__(self, transmitter: Transmitter):
          self.transmitter = transmitter
    
       @ALPReceiver("connect", namespace="/chats")
       async def handle_connect(self, sid: str):
          await self.transmitter.emit("message", MessageDTO(sender_id=sid, message=f"User {sid} joined the chat."), room="cool_convo", namespace="/chat")
    
          await self.transmitter.enter_room(sid, "cool_convo", namespace="/chat")
          print(f"[ALP] Client connected: {sid}")
    
       @ALPReceiver("message", namespace="/chats")
       async def handle_message(self, sid: str, data: MessageDTO):
          await self.transmitter.emit("message", data, room="cool_convo", namespace="/chat")
          return {"status": "ok"}
    

If everything works, you're done!

Roadmap

  • Typescript ALP Client
  • CLI generator for ALP based controllers
  • Built-in reconnection helpers
  • Websocket testing utils
  • Native websocket support
  • Additional transportation protocols support

License

MIT © 2025 Ascender Projects

Get Involved

Have feedback? Submit issues, PRs, or ideas - let’s make real-time Ascender-native and beautiful. Don’t forget to star ⭐ the repo if you like it.

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

ascender_alp-0.0.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

ascender_alp-0.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file ascender_alp-0.0.1.tar.gz.

File metadata

  • Download URL: ascender_alp-0.0.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Linux/6.14.8-asahi-1-1-ARCH

File hashes

Hashes for ascender_alp-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fc6aad3c15ef7703ff619013a30d3d2851bc1e683475c5ef0f2d14b9ab2f5e00
MD5 ad22ba2644e529b9a04b5f48d8c09ed6
BLAKE2b-256 26c8205ec8ae51016dc87fd7c5d8809159e8c3c8bb369ce4b32c14ce4c29fb9c

See more details on using hashes here.

File details

Details for the file ascender_alp-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ascender_alp-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Linux/6.14.8-asahi-1-1-ARCH

File hashes

Hashes for ascender_alp-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1203f4c62ee7c478ec79f3233aa3bb38d1cdfbb78e684221d5f3617fb7d0f216
MD5 ea8f110a5013b03e9f83ddd6dc6ebb53
BLAKE2b-256 8750d438855a30d43eec24ae6d3d541083aeabd6a7958fcee3902364bcc28f2f

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