Logo
Getting Started

Overview

API Overview

Use the WhatsApp Detection API to check whether a phone number is registered on WhatsApp. Send a POST request to the following endpoint:

http://api.whatsapp-detection.com/api/base_whatsapp_detection

Include your API token in the token HTTP header and provide the phone number in the JSON request body:

ParameterLocationDescription
tokenHTTP headerYour API access token.
phoneNumberJSON request bodyA phone number that includes its country calling code.

Get Your API Token

Sign in to the WhatsApp Detection dashboard and find your token in the Account settings menu. Keep your token private. Do not commit it to a public source-code repository or expose it in browser-side code.

Request Examples

Replace your_token_here and your_phone_number_with_country_code in the examples with your actual values.

Curl

curl -X POST \
	-H "Content-Type: application/json" \
	-H "token: your_token_here" \
	-d '{"phoneNumber":"your_phone_number_with_country_code"}' \
	http://api.whatsapp-detection.com/api/base_whatsapp_detection

Java

This example uses the built-in HTTP client available in Java 11 and later:

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class WhatsAppDetection {
    public static void main(String[] args) throws Exception {
        String json = "{\"phoneNumber\":\"your_phone_number_with_country_code\"}";
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("http://api.whatsapp-detection.com/api/base_whatsapp_detection"))
            .header("Content-Type", "application/json")
            .header("token", "your_token_here")
            .POST(HttpRequest.BodyPublishers.ofString(json))
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Python

This example uses the requests library:

import requests

url = "http://api.whatsapp-detection.com/api/base_whatsapp_detection"
headers = {
	"Content-Type": "application/json",
	"token": "your_token_here",
}
payload = {"phoneNumber": "your_phone_number_with_country_code"}

response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())

Node.js

This example uses the built-in fetch API available in Node.js 18 and later:

const response = await fetch("http://api.whatsapp-detection.com/api/base_whatsapp_detection", {
	method: "POST",
	headers: {
		"Content-Type": "application/json",
		token: "your_token_here",
	},
	body: JSON.stringify({
		phoneNumber: "your_phone_number_with_country_code",
	}),
});

console.log(response.status);
console.log(await response.json());

C++

This example uses libcurl:

#include <curl/curl.h>
#include <iostream>

int main() {
	CURL* curl = curl_easy_init();
	if (curl == nullptr) {
		return 1;
	}

	const char* json = "{\"phoneNumber\":\"your_phone_number_with_country_code\"}";
	struct curl_slist* headers = nullptr;
	headers = curl_slist_append(headers, "Content-Type: application/json");
	headers = curl_slist_append(headers, "token: your_token_here");

	curl_easy_setopt(curl, CURLOPT_URL,
		"http://api.whatsapp-detection.com/api/base_whatsapp_detection");
	curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json);
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
		+[](char* data, size_t size, size_t count, void* output) -> size_t {
			std::cout.write(data, size * count);
			return size * count;
		});

	const CURLcode result = curl_easy_perform(curl);
	curl_slist_free_all(headers);
	curl_easy_cleanup(curl);
	return result == CURLE_OK ? 0 : 1;
}

C#

This example uses HttpClient and System.Text.Json in .NET:

using System.Net.Http;
using System.Text;
using System.Text.Json;

using var client = new HttpClient();
using var request = new HttpRequestMessage(
	HttpMethod.Post,
	"http://api.whatsapp-detection.com/api/base_whatsapp_detection");
request.Headers.Add("token", "your_token_here");
request.Content = new StringContent(
	JsonSerializer.Serialize(new
	{
		phoneNumber = "your_phone_number_with_country_code"
	}),
	Encoding.UTF8,
	"application/json");

using var response = await client.SendAsync(request);
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(responseBody);

Response Example

On success, the API returns a response like the following. An isRegistered value of true means the number is registered on WhatsApp; false means it is not registered.

{
	"code": 200,
	"message": "success",
	"data": {
		"phoneNumber": "your_phone_number_with_country_code",
		"isRegistered": true
	}
}

Get Help

If you have any questions or issues, email support@email.whatsapp-detection.com or contact us through the live chat on the home page.

On this page