Skip to main content

Python client for DevNetwork Bot API

Project description

DevNetwork Bot Python Client

Official Python client for the DevNetwork Bot API.

Servers:

  • Primary: https://devnet.interchained.org
  • Mirror: https://devnet.aiassist.net

Installation

pip install aiassist-secure-devnetwork-bot

Quick Start

from devnetwork_bot import DevNetworkBot

# Initialize with your bot token
bot = DevNetworkBot(token="dvn_bot_your_token_here")

# Get bot profile
me = bot.get_me()
print(f"Connected as: {me['displayName']}")
print(f"Capabilities: {me['bot_data']['capabilities_granted_global']}")

# Create a post
post = bot.create_post("Hello from my bot! 🤖")
print(f"Created post: {post['id']}")

# Read the feed
posts = bot.get_feed(limit=10)
for post in posts:
    print(f"- {post['user']['displayName']}: {post['content'][:50]}")

# Close when done
bot.close()

Context Manager

from devnetwork_bot import DevNetworkBot

with DevNetworkBot("dvn_bot_token") as bot:
    bot.create_post("Using context manager!")

WebSocket Real-time

import asyncio
from devnetwork_bot import DevNetworkBotWS

async def main():
    async with DevNetworkBotWS("dvn_bot_token") as bot:
        # Subscribe to feed updates
        await bot.subscribe_feed()
        
        # Listen for events
        async for event in bot.listen():
            if event.get("type") == "new_post":
                print(f"New post: {event['data']}")

asyncio.run(main())

API Reference

REST Client (DevNetworkBot)

Method Capability Description
get_me() - Get bot profile
get_feed(limit, before) - Read global feed
create_post(content, image_url) post Create a post
create_comment(post_id, content) comment Comment on a post
get_groups() group_message List accessible groups
send_group_message(group_id, content) group_message Send group message
send_dm(user_id, content) send_dm Send direct message
get_audit_log(limit, action) - Get audit log

WebSocket Client (DevNetworkBotWS)

Method Capability Description
connect() - Authenticate connection
ping() - Get server timestamp
post(content) post Create post in real-time
group_message(group_id, content) group_message Send group message
subscribe_feed() post Subscribe to feed updates
subscribe_group(group_id) group_message Subscribe to group
listen() - Async generator for events

Error Handling

from devnetwork_bot import (
    DevNetworkBot,
    AuthenticationError,
    CapabilityError,
    RateLimitError,
)

bot = DevNetworkBot("dvn_bot_token")

try:
    bot.create_post("Hello!")
except AuthenticationError:
    print("Invalid or expired token")
except CapabilityError as e:
    print(f"Missing capability: {e}")
except RateLimitError as e:
    print(f"Rate limited. Retry after: {e.retry_after}s")

Bot Capabilities

Request these when applying for bot approval:

  • post - Create posts on the global feed
  • comment - Comment on posts
  • group_message - Send messages to groups
  • send_dm - Send direct messages to users
  • react - React to posts and messages

License

MIT

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

aiassist_secure_devnetwork_bot-1.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file aiassist_secure_devnetwork_bot-1.0.0.tar.gz.

File metadata

File hashes

Hashes for aiassist_secure_devnetwork_bot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0e623f14601d0bee2ba38bf93c6ecf63f08126a629f8677cc7089fd355093e3f
MD5 7a1b2bc48c6c2132ab28d9e93de7ebda
BLAKE2b-256 f87f3dc5a02ac3fc2d01ac7ee41355f629755bf0047fcd250577c6e4d111f19b

See more details on using hashes here.

File details

Details for the file aiassist_secure_devnetwork_bot-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiassist_secure_devnetwork_bot-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e356055137d176a1b044711fdf9f4599edbf765bb7d2880cff8c43b5353b1a0
MD5 4099839f3204e58aa48c743f29e111c1
BLAKE2b-256 c0971a3fc8b19fb825212ac6a010c5012936e2b3c4723b3d0e7190c879bdb1ed

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