
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
one-chat-api
Advanced tools
Python client for OneChat API: messages, files, broadcasts, locations, stickers, templates, quick replies, and image carousel.
The OneChat Python library provides an interface for sending messages, broadcasting messages to multiple users, sending location information, sending stickers, and sending files through the OneChat API.
To install the OneChat Python library, run the following command
pip install one-chat-api
To use the OneChat library, follow these steps
from one_chat import (
init,
send_message,
send_file,
broadcast_message,
send_location,
send_sticker,
send_template,
send_quickreply,
send_image_carousel,
fetch_friends_and_groups,
list_all_friends,
list_friend_ids,
list_all_groups,
list_group_ids,
)
or you can import all functions at once
from one_chat import *
Before using the functions, you need to initialize the library with your authorization token, default recipient, and bot id
init(
"YOUR_AUTHORIZATION_TOKEN", # Replace with your token
"DEFAULT_RECIPIENT_ID", # Replace with user ID or group ID
"YOUR_BOT_ID" # Replace with your bot ID
)
You can send a message to a specific user or group
response = send_message(message="Hello One!")
print("Send Message response:", response)
You can send a file to a specific user or group
response = send_file(file_path="results.csv")
print("Send File response:", response)
[!TIP] You can now send images using the send_file function, making it easier to share media files with your users!
response = send_webview(url="https://google.com/")
print("Send Webview response:", response)
[!IMPORTANT] You need to specify the Protocol (http:// or https://) in the URL
To send a message to multiple recipients
[!IMPORTANT] recipients must be a list of user IDs only !!! cannot be a group ID
response = broadcast_message(message="Hello Multi!", to=["USER_ID_1", "USER_ID_2"])
print("Send Message Multi response:", response)
To share a location
response = send_location(latitude=13.7563, longitude=100.5018, address="Bangkok, Thailand")
print("Send Location Response:", response)
To send a sticker
response = send_sticker(sticker_id="YOUR_STICKER_ID")
print("Send Sticker Response:", response)
To send a template message
response = send_template(
template=[
{
"image": "https://example.com/image.jpg",
"title": "Your Title Here",
"detail": "Your Detail Here",
"choice": [
{
"label": "Yes",
"type": "text",
"payload": "Yes"
},
# ....
],
},
]
)
print("Send Template Response:", response)
[!TIP] You can read more about template messages in the OneChat API documentation. Click here
To send a quick reply message
response = send_quickreply(
message="Hello, this is a quick reply message!",
quick_reply=[
{
"label": "Register",
"type": "text",
"message": "I need to register",
"payload": "Register",
}
],
)
print("Send Quick Reply Response:", response)
[!TIP] You can read more about quick reply messages in the OneChat API documentation. Click here
To send an image carousel message
response = send_image_carousel(
elements=[
{
"type": "text",
"image": "https://example.com/image1.jpg",
"action": "hello",
"payload": "Register",
"sign": "false",
"onechat_token": "false",
"button": "click me",
}
]
)
print("Send Image Carousel Response:", response)
[!TIP] You can read more about image carousel messages in the OneChat API documentation. Click here
Here’s a complete example of how to use the library
from one_chat import *
def main():
# Initialize OneChat with your token, recipient, and bot ID
init(
"YOUR_AUTHORIZATION_TOKEN",
"DEFAULT_RECIPIENT_ID", # Send to (One ID) or (Group ID)
"YOUR_BOT_ID" # Bot ID
)
# Send a single message
resp_msg = send_message(message="Hello One!")
print("Send Message response:", resp_msg)
# Send a file
resp_file = send_file(file_path="results.csv")
print("Send File response:", resp_file)
# Send a webview
resp_webview = send_webview(url="https://google.com/")
print("Send Webview response:", resp_webview)
# Broadcast a message to multiple users
resp_msg_multi = broadcast_message(message="Hello Multi!", to=["USER_ID_1", "USER_ID_2"])
print("Send Message Multi response:", resp_msg_multi)
# Send a location
resp_location = send_location(latitude=13.7563, longitude=100.5018, address="Bangkok, Thailand")
print("Send Location Response:", resp_location)
# Send a sticker
resp_sticker = send_sticker(sticker_id="YOUR_STICKER_ID")
print("Send Sticker Response:", resp_sticker)
# Send Template
resp_template = send_template(
template=[
{
"image": "https://example.com/image.jpg",
"title": "Your Title Here",
"detail": "Your Detail Here",
"choice": [
{
"label": "Yes",
"type": "text",
"payload": "Yes"
},
# ....
],
},
]
)
print("Send Template Response:", resp_template)
# Send Quick Reply
resp_quick_reply = send_quickreply(
message="Hello, this is a quick reply message!",
quick_reply=[
{
"label": "Register",
"type": "text",
"message": "I need to register",
"payload": "Register",
}
],
)
print("Send Quick Reply Response:", resp_quick_reply)
# Send Image Carousel
resp_image_carousel = send_image_carousel(
elements=[
{
"type": "text",
"image": "https://example.com/image1.jpg",
"action": "hello",
"payload": "Register",
"sign": "false",
"onechat_token": "false",
"button": "click me",
}
]
)
print("Send Image Carousel Response:", resp_image_carousel)
# Get a list of friends and groups
friends_and_groups = fetch_friends_and_groups() # you can use fetch_friends_and_groups("BOT_ID") to get friends and groups of another bot
print("Friends and Groups:", friends_and_groups)
# Get a list of friends
friends = list_all_friends() # you can use list_all_friends("BOT_ID") to get friends of another bot
print("Friends:", friends)
# Get the One ID of a friend
one_id = list_friend_ids() # you can use list_friend_ids("BOT_ID") to get one id of a friend of another bot
print("One ID of Friend:", one_id)
# Get a list of groups
groups = list_all_groups() # you can use list_all_groups("BOT_ID") to get groups of another bot
print("Groups:", groups)
# Get the group ID of a group
group_id = list_group_ids() # you can use list_group_ids("BOT_ID") to get group id of a group of another bot
print("Group ID of Group:", group_id)
if __name__ == "__main__":
main()
Contributions are welcome! Please see CONTRIBUTING.md and SECURITY.md. Run checks locally with:
ruff check .
black --check .
mypy one_chat
pytest
See runnable examples in examples/:
examples/quickstart.py — send a text message (uses env ONECHAT_TOKEN, ONECHAT_TO, ONECHAT_BOT_ID)examples/broadcast.py — broadcast to multiple users (uses env ONECHAT_TOKEN, ONECHAT_BOT_ID, ONECHAT_USERS)FAQs
Python client for OneChat API: messages, files, broadcasts, locations, stickers, templates, quick replies, and image carousel.
We found that one-chat-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.