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"]))
# Upload and send a reusable attachment
res = sender.upload_attachment("image", url="https://example.com/image.jpg")
attachment_id = res["attachment_id"]
# Send reusable attachment by attachment_id
sender.send("USER_ID", Attachment("image", attachment_id=attachment_id))
# or using ReusableAttachment:
# sender.send("USER_ID", ReusableAttachment("image", attachment_id))
# Mark as seen
sender.send("USER_ID", action="mark_seen")
Supported Message Types
Text: Simple text messages.Attachment: Images, files, audio, video (supports URL,attachment_id, oris_reusable).ReusableAttachment: Reusable attachment referencing an existingattachment_id.Images: Multiple images grouped together in a single message (supports URLs orattachment_ids).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.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymes_api-0.2.7.tar.gz | 8.5 kB | Without provenance | Details for pymes_api-0.2.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pymes_api-0.2.7-py3-none-any.whl | Python 3 | none | any | Details for pymes_api-0.2.7-py3-none-any.whl |
Total release size: 15.8 kB
Release files / pymes_api-0.2.7.tar.gz
| Download URL | pymes_api-0.2.7.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac76158a4f2c9d363fa6ba2a24c0550d3b0c66165930611345822d46a3be2571
|
|
BLAKE2b-256 checksum How to use checksums |
5f3fd63467676080ee68d7d30c51fa7c798966377bdcb16c1d3ce70b005e1d2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / pymes_api-0.2.7-py3-none-any.whl
| Download URL | pymes_api-0.2.7-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb4e961aff026a9fc9033b2decaaa7e3bdfdb7e961efe56075cea31b1009ec05
|
|
BLAKE2b-256 checksum How to use checksums |
a6304c0205ebc90deaa7ddc386c252f9b1f63b7f3fc4df004b8ef0740b67657c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for pymes-api 0.2.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.