pymes
A simple, lightweight Python wrapper for the Facebook Messenger API.
Installation
No installation command is available yet as this package is not yet published to PyPI. Once published, you will be able to install it via pip:
pip install pymes-api
Usage
Basic Example
from pymes import MessengerClient, Text, Attachment, Images
# Initialize the client
sender = MessengerClient(page_access_token="YOUR_PAGE_ACCESS_TOKEN")
# Send a text message
sender.send(recipient_id="USER_ID", message=Text("Hello, world!"))
# Send an attachment (Image)
sender.send("USER_ID", Attachment("image", "https://example.com/image.jpg"))
# Send multiple images grouped together
sender.send("USER_ID", Images(["https://example.com/image1.jpg", "https://example.com/image2.jpg"]))
# Mark as seen
sender.send("USER_ID", action="mark_seen")
Supported Message Types
Text: Simple text messages.Attachment: Images, files, audio, video.Images: Multiple images grouped together in a single message.QuickReply: Messages with quick reply buttons.GenericTemplate: Carousel-like templates with images and buttons.
Django Support (New)
You can easily handle incoming messages using the MessengerView.
# views.py
from pymes.adapter.django import MessengerView
class BotView(MessengerView):
verify_token = "YOUR_VERIFY_TOKEN"
app_id = "YOUR_PAGE_ID" # Optional verification
def handle_message(self, metadata):
sender_id = metadata['sender_id']
message = metadata['payload']
print(f"Message from {sender_id}: {message}")
# handle any event defining a method with the event name like handle_{event name}
# urls.py
from django.urls import path
from .views import BotView
urlpatterns = [
path("webhook/", BotView.as_view()),
]
Requirements
- Python 3.10+
requestslibrary
License
MIT License
Metadata
Release files for pymes-api 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymes_api-0.2.6.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymes_api-0.2.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / pymes_api-0.2.6.tar.gz
| Download URL | pymes_api-0.2.6.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b16e1c2d6a0176ef5baafb94e308eb422084757ff8a5f80c3f635a3ff4a542f4
|
|
BLAKE2b-256 checksum How to use checksums |
73a8fef1df86a33672c877f23a4089ad2854b874193dd066bc5bbc1b6609ee1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / pymes_api-0.2.6-py3-none-any.whl
| Download URL | pymes_api-0.2.6-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87bcbe3004c15c86990ad2790c58111fc48a8c7af6dc5caf5ac1671292287b43
|
|
BLAKE2b-256 checksum How to use checksums |
5d883d2c2042f6a9e00d974de9a37f136aa1a4e6dd4470af4244ff1a27d3bc85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|