Skip to content

zainsardar-tech/wams-python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wams Python SDK

Contributing

See CONTRIBUTING.md for guidelines.

Pure Python SDK for sending all types of WhatsApp messages via the Wams API.

Features

  • Send text messages
  • Send media (images, videos, audio, documents)
  • Send interactive messages (buttons, lists)
  • Send location
  • Send contact cards (vCard)
  • Send product messages
  • Send text to WhatsApp channels
  • Send stickers
  • Send polls

Installation

pip install requests
# or
pip install -r requirements.txt

Usage

from wams_sdk import WamsClient

client = WamsClient(api_key="YOUR_API_KEY", sender="YOUR_NUMBER")

# Send a text message
resp = client.send_text(number="RECIPIENT", message="Hello World!", footer="Sent via wams")
print(resp)

# Send an image
resp = client.send_media(number="RECIPIENT", media_type="image", url_="https://example.com/image.jpg", caption="Check this image!", footer="Sent via wams")
print(resp)

# Send a button message
buttons = [
	{"type": "reply", "displayText": "Reply Button"},
	{"type": "call", "displayText": "Call Button", "phoneNumber": "1234567890"},
	{"type": "url", "displayText": "URL Button", "url": "https://google.com"},
	{"type": "copy", "displayText": "Copy Button", "copyText": "123123"}
]
resp = client.send_button(number="RECIPIENT", message="Choose an option", button=buttons, image="https://example.com/image.jpg", footer="optional")
print(resp)

# Send a list message
sections = [
	{
		"title": "Main Options",
		"description": "Select a basic option to proceed.",
		"rows": [
			{"title": "Option 1", "rowId": "id1", "description": "Description for option 1"},
			{"title": "Option 2", "rowId": "id2", "description": "Description for option 2"}
		]
	},
	{
		"title": "Advanced Options",
		"description": "Explore advanced settings.",
		"rows": [
			{"title": "Option 3", "rowId": "id3", "description": "Description for option 3"}
		]
	}
]
resp = client.send_list(number="RECIPIENT", name="Message list", title="title list", buttontext="Menu", message="Hello, this is a list button message", sections=sections, image="https://example.com/image.jpg", footer="optional")
print(resp)

# Send location
resp = client.send_location(number="RECIPIENT", latitude="24.121231", longitude="55.1121221")
print(resp)

# Send vCard
resp = client.send_vcard(number="RECIPIENT", name="magd", phone="1234567890")
print(resp)

# Send product message
resp = client.send_product(number="RECIPIENT", url_="https://wa.me/p/12345678901234567/RECIPIENT", message="Check out this item!")
print(resp)

# Send text to channel
resp = client.send_text_channel(url_="https://whatsapp.com/channel/ABCDEF123456", message="Hello World", footer="Sent via wams")
print(resp)

# Send sticker
resp = client.send_sticker(number="RECIPIENT", url_="https://example.com/image.jpg")
print(resp)

# Send poll
resp = client.send_poll(number="RECIPIENT", name="What color do you like?", option=["red", "blue", "yellow"], countable="1")
print(resp)

API Reference

All methods return the JSON response from the Wams API.

Constructor

WamsClient(api_key: str, sender: str)

Methods

  • send_text(number, message, footer=None, msgid=None, full=None)
  • send_media(number, media_type, url_, caption=None, footer=None, msgid=None, full=None)
  • send_button(number, message, button, image, footer=None)
  • send_list(number, name, title, buttontext, message, sections, image, footer=None, msgid=None, full=None)
  • send_location(number, latitude, longitude, msgid=None, full=None)
  • send_vcard(number, name, phone, msgid=None, full=None)
  • send_product(number, url_, message=None, msgid=None, full=None)
  • send_text_channel(url_, message, footer=None, full=None)
  • send_sticker(number, url_, msgid=None, full=None)
  • send_poll(number, name, option, countable="1", msgid=None, full=None)

See wams_sdk/example.py for full working examples.

License

MIT

About

WhatsApp API Python SDK for sending text, media, buttons, lists, and interactive messages via Wams.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages