Welcome to WebWhatsAPI’s documentation!¶
This package is used to provide a python interface for interacting with WhatsAPP Web to send and recieve Whatsapp messages.
Driver¶
WebWhatsAPI module
-
class
webwhatsapi.
WhatsAPIDriver
(client='firefox', username='API', proxy=None, command_executor=None, loadstyles=False, profile=None, headless=False, autoconnect=True, logger=None, extra_params=None, chrome_options=None)[source]¶ - This is our main driver objects.
Note
Runs its own instance of selenium
-
chat_send_seen
(chat_id)[source]¶ Send a seen to a chat given its ID
Parameters: chat_id (str) – Chat ID
-
contact_get_common_groups
(contact_id)[source]¶ Returns groups common between a user and the contact with given id.
Returns: Contact or Error Return type: Contact
-
get_all_message_ids_in_chat
(chat, include_me=False, include_notifications=False)[source]¶ Fetches message ids in chat
Parameters: Returns: List of message ids in chat
Return type:
-
get_all_messages_in_chat
(chat, include_me=False, include_notifications=False)[source]¶ Fetches messages in chat
Parameters: Returns: List of messages in chat
Return type:
-
get_chat_from_id
(chat_id)[source]¶ Fetches a chat given its ID
Parameters: chat_id (str) – Chat ID Returns: Chat or Error Return type: Chat
-
get_chat_from_phone_number
(number)[source]¶ Gets chat by phone number Number format should be as it appears in Whatsapp ID For example, for the number: +972-51-234-5678 This function would receive: 972512345678
Parameters: number – Phone number Returns: Chat Return type: Chat
-
get_contact_from_id
(contact_id)[source]¶ Fetches a contact given its ID
Parameters: contact_id (str) – Contact ID Returns: Contact or Error Return type: Contact
-
get_contacts
()[source]¶ Fetches list of all contacts This will return chats with people from the address book only Use get_all_chats for all chats
Returns: List of contacts Return type: list[Contact]
-
get_message_by_id
(message_id)[source]¶ Fetch a message
Parameters: message_id (str) – Message ID Returns: Message or False Return type: Message
-
get_my_contacts
()[source]¶ Fetches list of added contacts
Returns: List of contacts Return type: list[Contact]
-
get_unread
(include_me=False, include_notifications=False, use_unread_count=False)[source]¶ Fetches unread messages
Parameters: Returns: List of unread messages grouped by chats
Return type:
-
get_unread_messages_in_chat
(id, include_me=False, include_notifications=False)[source]¶ I fetch unread messages from an asked chat.
Parameters: Returns: list of unread messages from asked chat
Return type:
-
is_logged_in
()[source]¶ Returns if user is logged. Can be used if non-block needed for wait_for_login
-
mark_default_unread_messages
()[source]¶ Look for the latest unreplied messages received and mark them as unread.
-
save_firefox_profile
(remove_old=False)[source]¶ Function to save the firefox profile to the permanant one
Objects¶
-
class
webwhatsapi.objects.contact.
Contact
(js_obj, driver=None)[source]¶ Class which represents a Contact on user’s phone
-
get_chat
(*args)¶
-
get_common_groups
(*args)¶
-
-
class
webwhatsapi.objects.chat.
Chat
(js_obj, driver=None)[source]¶ -
-
get_unread_messages
(include_me=False, include_notifications=False)[source]¶ I fetch unread messages.
Parameters: Returns: list of unread messages
Return type:
-
load_earlier_messages_till
(last)[source]¶ Triggers loading of messages till a specific point in time
Parameters: last (datetime) – Datetime object for the last message to be loaded Returns: Nothing Return type: None
-
send_message
(*args)¶
-
send_seen
(*args)¶
-
-
class
webwhatsapi.objects.chat.
GroupChat
(js_obj, driver=None)[source]¶ -
get_admins
(*args)¶
-
get_participants
(*args)¶
-
get_participants_ids
(*args)¶
-
-
webwhatsapi.objects.chat.
factory_chat
(js_obj, driver=None)[source]¶ Factory function for creating appropriate object given selenium JS object
-
class
webwhatsapi.objects.message.
MMSMessage
(js_obj, driver=None)[source]¶ Represents MMS messages
Example of an MMS message: “ptt” (push to talk), voice memo
-
class
webwhatsapi.objects.message.
MediaMessage
(js_obj, driver=None)[source]¶ -
crypt_keys
= {'document': '576861747341707020446f63756d656e74204b657973', 'image': '576861747341707020496d616765204b657973', 'ptt': '576861747341707020417564696f204b657973', 'video': '576861747341707020566964656f204b657973'}¶
-