Get all contacts
curl --request GET \
--url https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all \
--header 'Authorization: Bearer <token>'import requests
url = "https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "Contacts retrieved successfully.",
"data": [
{
"id": "100875997589545@lid",
"name": "Maria",
"pushname": "Maria Doe"
}
]
}{
"message": "Resource not found."
}{
"message": "Internal Server Error"
}Get All Contacts
Retrieve a list of all contacts in the WhatsApp instance with pagination and sorting options.
GET
/
{instance}
/
contacts
/
get-all
Get all contacts
curl --request GET \
--url https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all \
--header 'Authorization: Bearer <token>'import requests
url = "https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.hypersender.com/api/whatsapp/v2/{instance}/contacts/get-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"message": "Contacts retrieved successfully.",
"data": [
{
"id": "100875997589545@lid",
"name": "Maria",
"pushname": "Maria Doe"
}
]
}{
"message": "Resource not found."
}{
"message": "Internal Server Error"
}Retrieve a paginated list of all contacts in your WhatsApp instance.
This endpoint allows you to:
- Fetch all contacts from your WhatsApp instance
- Paginate through large contact lists
- Sort contacts by name or ID
- Control the number of contacts returned
This is useful for syncing contacts with your CRM, building contact lists, or displaying contacts in your application.
Use Cases
Contact Synchronization
Sync all your WhatsApp contacts with your CRM or external database.Contact Management
Build a contact management interface with pagination and sorting capabilities.Bulk Operations
Retrieve contact lists for bulk messaging or data analysis operations.Export Contacts
Export your WhatsApp contacts for backup or migration purposes.Query Parameters
limit
- Type: Integer
- Range: 1-1000
- Default: 100
- Description: Number of contacts to return per request
offset
- Type: Integer
- Minimum: 0
- Default: 0
- Description: Number of contacts to skip (for pagination)
sort_by
- Type: String
- Options:
id,name - Default:
name - Description: Field to sort contacts by
sort_order
- Type: String
- Options:
asc,desc - Default:
asc - Description: Sort order (ascending or descending)
Response Examples
Successful Response
When contacts are retrieved successfully:{
"message": "Contacts retrieved successfully.",
"data": [
{
"id": "100875997589545@lid",
"name": "Maria",
"pushname": "Maria Doe"
},
{
"id": "10226367471836@lid",
"name": "John",
"pushname": "John Doe"
}
]
}
Pagination Example
To paginate through contacts, use thelimit and offset parameters:
# First page (contacts 1-100)
GET /{instance}/contacts/get-all?limit=100&offset=0
# Second page (contacts 101-200)
GET /{instance}/contacts/get-all?limit=100&offset=100
# Third page (contacts 201-300)
GET /{instance}/contacts/get-all?limit=100&offset=200
Best Practices
Use pagination with reasonable limits (e.g., 100-200) to avoid timeouts and improve performance.
The
pushname is the name the user has set in their WhatsApp profile, while name is the name saved in your phone’s contacts.Large contact lists may take time to retrieve. Consider implementing progressive loading in your UI.
Integration Example
Fetching All Contacts with Pagination
async function getAllContacts(instance, apiKey) {
let allContacts = [];
let offset = 0;
const limit = 100;
let hasMore = true;
while (hasMore) {
const response = await fetch(
`https://app.hypersender.com/api/whatsapp/v2/${instance}/contacts/get-all?limit=${limit}&offset=${offset}`,
{
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
}
);
const data = await response.json();
allContacts = allContacts.concat(data.data);
// Check if there are more contacts
hasMore = data.data.length === limit;
offset += limit;
}
return allContacts;
}
The
chatId can be in any format +20123456789, 20123456789, 0123456789, or 123456789Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
application/json
Example:
"application/json"
application/json
Example:
"application/json"
Path Parameters
Instance UUID copied from hypersender dashboard
Example:
"{{ instance_id }}"
Query Parameters
Number of contacts to return (1-1000)
Required range:
1 <= x <= 1000Example:
100
Number of contacts to skip
Required range:
x >= 0Example:
0
Sort by id or name
Available options:
id, name Example:
"name"
Sort order: asc or desc
Available options:
asc, desc Example:
"asc"