Nick WhatsApp API for Python

With Nick you can start using WhatsApp messages in your service wherever, whenever. Integrating it is easy enough with our simple API.

In this guide we’ll supply you with an example on how to send messages with Nick. You can read on how it works, or just copy and paste it into your code and reuse our method!

If you haven’t linked your phone yet follow the code below to get started up.

Requirements

If you’ve got Python installed you’re almost good to go. On top of that you will need the “requests” package for Python which is not standard. If you’re using pip to manage your python packages use:

pip install requests

If you’re using conda do

conda install requests

That’s all we need. You’re set up now.

How to send a message

Sending a message is pretty straightforward. In this example we’ll show how to create a simple method for sending messages. The imports import the requests and json library so that we can parse json and do API requests. The URL part is the endpoint you’re talking to as described in our API documentation. The token is where you put in your token for authorisation. Then we simply load this information to a header that’s formatted for our authorisation and send a request with the info.

We’ve include a line of example at the end so that you can try this code and see what happens. You can reuse this method to send messages in your application.

import requests
import json

url = "http://api.getnick.io/api/v1/send"
token = "YOUR NICK TOKEN"
headers = {"Authorization": "Bearer "+token}

def sendMessage(message,number):
payload= {
    "message":message,
    "number":number
}
return requests.post(url, json=payload, headers=headers);

print(sendMessage("Hey, it's Nick","31612345678"));

That's all

You’re now ready to send WhatsApp messages wherever you want in your application. Whatever you’re doing we hope you can serve your customers better with this added service!

× Hey! Need help?