{"id":18872408,"url":"https://github.com/defcon-007/py-whatsapp","last_synced_at":"2026-02-15T21:30:16.619Z","repository":{"id":97212200,"uuid":"363471279","full_name":"DefCon-007/py-whatsapp","owner":"DefCon-007","description":"Unofficial python wrapper chat-api.com ","archived":false,"fork":false,"pushed_at":"2021-06-20T20:34:46.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-31T00:24:33.088Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DefCon-007.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-01T17:42:18.000Z","updated_at":"2023-02-18T16:39:26.000Z","dependencies_parsed_at":"2023-03-24T12:17:55.783Z","dependency_job_id":null,"html_url":"https://github.com/DefCon-007/py-whatsapp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefCon-007%2Fpy-whatsapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefCon-007%2Fpy-whatsapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefCon-007%2Fpy-whatsapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefCon-007%2Fpy-whatsapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DefCon-007","download_url":"https://codeload.github.com/DefCon-007/py-whatsapp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239824987,"owners_count":19703199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T05:29:48.809Z","updated_at":"2026-02-15T21:30:16.563Z","avatar_url":"https://github.com/DefCon-007.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Py-WhatsApp: Unofficial python package for [chat-api.com](https://chat-api.com)\n\n### Chat-API\n\nIt is a multifunctional rest api for WhatsApp accounts working on top of WhatsApp web. They offer a 3-day free trial to allow you to use the service before buying and this python package allows you to interface with most of its services directly.\n\n### Installing\n\nYou can use the command `pip install whatsapp-api` to install the latest stable version from PyPi.\n\n### Usage\n\nBefore using any of the available functions below you need to create an instance of the `Whatsapp` class object and needs to supply your `instanceId` and `token` which you can get from your [chat-api.com](https://chat-api.com) account. \n\n```python\nfrom whatsapp import WhatsApp\n\ntoken = \"xxxxxxx\"\ninstance_id = \"instancexxx\"\n\nobject = WhatsApp(token, instance_id)\n```\n\nFollowing are the currently supported functions with examples. We will use this `object` directly for the rest of the examples. \n\n1. **Send a text message**\nTo send a message the mobile number must me in the international format with approriate country code. For eg. if you want to send a message to an Indian mobile number (country code - +91) with number 1234512345 you need to use `911234512345` as phone number in the argument.\nDefault whatsapp message formatting will work as usual. Like \\_This text will be in italics_. \n\n    ```python\n    phone_number = \"911234512345\"\n    message = \"This is a sample text message. *This will be bold*\"\n    response = object.send_message(phone_number, message)\n    ```\n\n2. **Send a file**\nYou can either send a file from a URL or in base64 encoded format. You can also optionally add a caption to the file which will be added below the message.\n\n    ```python\n    phone_number = \"911234512345\"\n    file_data = \"\"\"\n                HTTP link https://upload.wikimedia.org/wikipedia/ru/3/33/NatureCover2001.jpg\n                Or base64-encoded file with mime data, for example data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...\n                File in form-data input field\n                \"\"\"\n    file_name = \"Name of the file\"\n    caption = \"This is a file caption\" # Optional\n    response = object.send_file(phone, file_data, file_name, caption)\n    ```\n\n3. **Get current status**\nReturns the current overall status as a dictionary.\n\n    ```python\n    status = object.get_status()\n    ```\n\n4. **Logout**\nLogs you out of the whatsapp web instance and `object.get_status()` will now return with the QR code data which you can scan to log in to another whatsapp account.\n\n    ```python\n    response = object.logout()\n    ```\n\n5. **Get waiting message queue**\nSometimes there is a delay in sending message mostly due to limited connectivity on the mobile phone running the whatsapp application. During this time, the messages are queued and retried at a later time. This function returns the list of all waiting messages in queue as python object. \n**Note: Atmost 400 messages can be present in a queue at a time, post that message sending will fail.**\n\n    ```python\n    queue = object.get_message_queue()\n    ```\n\n6. **Reboot**\nReboots the chat-api instance.\n\n    ```python\n    response = object.reboot()\n    ```\n\n7. **Takeover instance**\nAs you might be aware that currently whatsapp web can only be active on a single browser. Hence, you should not use whatsapp web anywhere else if you are using chat-api. But if opened it somewhere else, you can use the  takeover function to make chat-api instance active again.\n\n    ```python\n    response = object.takeover()\n    ```\n\n### Building\n\n- Clone the repository `git clone https://github.com/DefCon-007/py-whatsapp`\n- Create a new python3 virtual environment in the newly created directory. `cd py-whatsapp` and then `python3 -m venv`\n- To create a new distribution package, increase the `VERSION` in `setup.py` file and then run `python setup.py sdist bdist_wheel`. This will create a new distribution package for the new version in dist directory.\n\n- **Installing newly crated distribution package in a local python environment**\n\n  - Use the command `pip install whatsapp-api --no-index --find-links file://\u003cpath_to_py-whatsapp_directory\u003e/dist  --no-cache-dir` to install the newly generated distribution.\n\n### TODOs\n\n- [ ] Parse the HTTP responses into custom objects for better usability. \n- [ ] Add remaining API functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefcon-007%2Fpy-whatsapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefcon-007%2Fpy-whatsapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefcon-007%2Fpy-whatsapp/lists"}