Groups API
Manage and retrieve your contact groups programmatically.
List Groups
Get a list of all your contact groups.
Endpoint: GET /groups
Example (Node.js)
const axios = require('axios');
const listGroups = async () => {
try {
const response = await axios.get('https://api.whatsspot.in/groups', {
headers: { 'x-api-key': 'YOUR_API_TOKEN' }
});
console.log(response.data);
} catch (error) {
console.error(error);
}
};
listGroups();
Response
{
"success": true,
"data": [
{
"id": "group_123",
"name": "VIP Customers",
"contactsCount": 50,
"createdAt": "2023-01-01T00:00:00Z"
}
]
}
Get Group Details
Endpoint: GET /groups/:id
List Group Members
Endpoint: GET /groups/:id/contacts
Code Examples
- Node.js
- Python
const axios = require('axios');
const listGroupMembers = async (groupId) => {
try {
const response = await axios.get(`https://api.whatsspot.in/groups/${groupId}/contacts`, {
headers: { 'x-api-key': 'YOUR_API_TOKEN' }
});
console.log(response.data);
} catch (error) {
console.error(error);
}
};
listGroupMembers('group_123');
import requests
group_id = "group_123"
url = f"https://api.whatsspot.in/groups/{group_id}/contacts"
headers = {"x-api-key": "YOUR_API_TOKEN"}
response = requests.get(url, headers=headers)
print(response.json())