Productivity

pywhatkit Alternative: Send WhatsApp Messages from Python Without Automating a Browser

pywhatkit needs no API key because it opens WhatsApp Web and presses Enter for you. That is also why it needs a screen. A Python HTTP call to the Blueticks API does the same job with no browser window.

Daniel Roth6 min read

pywhatkit Alternative: Send WhatsApp Messages from Python Without Automating a Browser
On this page

pywhatkit sends a WhatsApp message without an API key because it never talks to an API. It opens WhatsApp Web in your browser, clicks the page, and presses Enter. If you want to send from Python without a browser window in the loop, the alternative is an HTTP call to an API that sends from your own WhatsApp number. This post shows both, side by side, and where each one fits.

A note on sources. We read the source of pywhatkit 5.4, the latest release on PyPI at the time of writing, to describe how it works. We did not run it for this post. The Blueticks side comes from the API schema in our backend and the API docs.

How does pywhatkit send a WhatsApp message?

In pywhatkit 5.4, sendwhatmsg_instantly opens https://web.whatsapp.com/send?phone=<number>&text=<message> in your default browser, waits, clicks the middle of the screen with pyautogui, and presses Enter. That is the whole mechanism. There is no WhatsApp API call and no key, which is why it is popular for quick scripts.

Python
import pywhatkit
 
# Opens WhatsApp Web in your browser, then sends after wait_time seconds
pywhatkit.sendwhatmsg_instantly("+15551234567", "Hello from pywhatkit", wait_time=15)

The scheduling version, sendwhatmsg, takes a clock hour and minute (time_hour, time_min) and sleeps your Python process until then, then does the same browser dance. It raises an error if the target time is less than wait_time seconds away. The function signatures also include tab_close and close_time to close the tab afterwards, and there are variants for groups and images.

Two details from the source worth knowing:

  • The phone number must contain a + or an underscore, or the library raises a country-code error. It does not otherwise validate the number.
  • The function returns None. It appends a line to a local PyWhatKit_DB.txt file after it presses the keys, but it does not check whether WhatsApp accepted or delivered the message.

Where does pywhatkit break down?

Because it types into a real browser window, pywhatkit depends on things a server does not have. Each of these follows from how the code works:

  • It needs a screen and a logged-in browser. It opens a tab and uses pyautogui to click and press a key, so it needs a desktop session, and WhatsApp Web must already be linked in that browser. The script does nothing about login.
  • It borrows your mouse and keyboard. The click targets the middle of the screen at the moment the page should have loaded. If the page loads slowly, or you move another window in front, the Enter goes somewhere else.
  • It blocks. The default wait_time is 15 seconds per message, and the scheduled variant sleeps the whole process. One script, one message at a time.
  • No delivery information. You get no message id and no status back.

For a one-off message from your own laptop, that is fine. For anything that has to run unattended, it is the wrong shape.

What is the alternative without a browser window?

An HTTP call. You send a JSON body to an API, and a WhatsApp engine already connected to your number does the sending. With Blueticks that engine is either your own browser extension session or a cloud-hosted Gateway, and your Python code never touches a browser.

The trade is real, so here it is plainly: pywhatkit needs no key, and the Blueticks API does. You create a bt_live_ key at dev.blueticks.co, and you link a WhatsApp number to your Blueticks account once.

How do you send the same message from Python with the Blueticks API?

POST {type, text} to https://api.blueticks.co/v1/scheduled-messages/{recipient} with a bearer key. The recipient goes in the URL path in E.164 format. Omit sendAt and the message is sent immediately.

Python
import requests
 
API_KEY = "bt_live_YOUR_KEY_HERE"
TO = "+15551234567"  # recipient, E.164, goes in the URL path
 
resp = requests.post(
    f"https://api.blueticks.co/v1/scheduled-messages/{TO}",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"type": "text", "text": "Hello from Python"},
    timeout=30,
)
resp.raise_for_status()
msg = resp.json()["data"]  # success responses are wrapped in {"success": true, "data": {...}}
print(msg["id"], msg["status"])

What the API schema requires, checked against our backend:

  • type is required and must be text, media or poll. A bare {"text": "..."} is rejected.
  • text is required for text messages and is capped at 4,096 characters.
  • The response gives you a message id you can use later to look up status.

To confirm your key and your linked number before the first send, call GET https://api.blueticks.co/v1/ping. It returns your account id and the WhatsApp engines currently connected. If the list is empty, no number is connected and sends will not go out. For the full walkthrough, with cURL and Node as well, see send a WhatsApp message from an API.

How do you schedule a message the way sendwhatmsg does?

Add sendAt to the same body. It is an ISO 8601 timestamp with a UTC offset, at least 10 seconds in the future and at most 365 days out. Blueticks queues the message on its side, so your script does not have to stay running.

Python
from datetime import datetime, timedelta, timezone
import requests
 
send_at = (datetime.now(timezone.utc) + timedelta(hours=2)).isoformat()
 
resp = requests.post(
    "https://api.blueticks.co/v1/scheduled-messages/+15551234567",
    headers={"Authorization": "Bearer bt_live_YOUR_KEY_HERE"},
    json={"type": "text", "text": "Reminder: call at 4pm", "sendAt": send_at},
    timeout=30,
)
resp.raise_for_status()
print(resp.json()["data"]["status"])

Compare that with sendwhatmsg, which needs your computer awake, your browser open and your Python process sleeping until the minute arrives. For more on scheduling by API, see schedule WhatsApp messages with an API.

pywhatkit or API: which should you use?

pywhatkitBlueticks API
Needs an API keyNoYes (bt_live_ key)
How it sendsDrives WhatsApp Web with pyautoguiHTTP call to an engine on your number
Needs a screen and open browserYesOnly if your number runs through the browser extension
Runs unattended on a serverNot realisticallyYes, with a cloud Gateway
Message id and status backNoYes
SchedulingYour process sleeps until the timesendAt, queued on the server

Use pywhatkit for a quick personal script you run by hand. Use an API when the send has to happen without you watching a screen.

Does the API work when your computer is off?

Only if your WhatsApp number runs in the cloud. If your number is connected through the Blueticks browser extension, sends happen while that browser session is online. A Blueticks Gateway, the cloud-hosted engine on the Pro plan, keeps sending with your computer off. /v1/ping reports each connection as gateway or regular so you can see which you have. See how a WhatsApp agent answers with your computer off for the longer explanation.

What does it cost, and what are the limits?

The free plan allows 5 API requests per 6-hour window, shared with the MCP integration. Any active paid subscription has no request limit. Check the pricing page for current plans before you build around a number.

What are the risks?

  • WhatsApp can restrict numbers. Both pywhatkit and Blueticks send from a normal WhatsApp account, not through Meta's official Cloud API. We cannot promise WhatsApp will never restrict a number. Message people who expect to hear from you, keep volume modest, and remember that consent and opt-out are your responsibility.
  • Keys are bearer tokens. Anyone with your bt_live_ key can send as you. Keep it server-side and out of git, and revoke it on your API keys page if it leaks.
  • Test with your own number first. Send to yourself before you point a loop at real contacts.

FAQ

Is pywhatkit free?

Yes. It is an open-source package and needs no API key. It also needs your own browser, a logged-in WhatsApp Web session and a screen to drive.

Can pywhatkit run on a server?

Not in the usual sense. It opens a browser tab and uses pyautogui to click and press Enter, so it needs a desktop session. Headless servers do not have one.

Is there a pywhatkit alternative with no API key at all?

Not through an API: an HTTP API needs some credential. The Blueticks key is a single bearer token you create once, and it sends from your own number with no Meta Business verification. See WhatsApp REST API on your own number for how that model works.

Can I send images or documents like pywhatkit does?

Yes. Swap the body for {"type": "media", "mediaUrl": "https://example.com/file.pdf", "mediaKind": "document"}. Details are in the send-from-API guide.

Can an AI agent use the same API?

The same account is also exposed as an MCP server for agents. See the WhatsApp API for AI agents.

Share this article

The Dispatch, every week.

One sharp WhatsApp growth tactic in your inbox each week. Joined by 238,000+ founders, marketers and support leads.

Free forever. No spam, unsubscribe in one click.

Also on TikTok: @blueticksagents