Get Group Participants
Retrieve the list of participants in a WhatsApp group
Get Group Participants
Retrieve the list of all participants in a WhatsApp group, including their roles and status.
Endpoint
GET /{sessionId}/groups/{groupId}/participants
Headers
Name | Type | Required | Description |
---|---|---|---|
Authorization | string | Yes | Bearer token for authentication |
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
sessionId | string | Yes | The session ID |
groupId | string | Yes | The group ID |
Response
{
"success": true,
"participants": [
{
"jid": "1234567890@c.us",
"phoneNumber": "+1234567890",
"isAdmin": true,
"isSuperAdmin": false,
"joinedAt": "2023-01-15T12:00:00Z",
"displayName": "Jane Doe"
}
],
"error": null
}
Examples
curl -X GET "https://api.wasend.dev/{sessionId}/groups/{groupId}/participants" \
-H "Authorization: Bearer YOUR_API_KEY"
import { WasendClient, GroupParticipant } from '@wasend/core';
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
const sessionId = "yourSessionId";
const groupId = "yourGroupId";
// Get group participants
// Assuming getGroupParticipants returns GroupParticipant[] directly as per API.md
// If it returns an object like {success, participants, error}, this needs adjustment.
async function run() {
try {
const participants: GroupParticipant[] = await client.getGroupParticipants(sessionId, groupId);
console.log('Participants:', participants);
// Example: Accessing details of the first participant
if (participants.length > 0) {
console.log('First participant JID:', participants[0].jid);
}
} catch (error) {
console.error("Failed to get participants:", error);
}
}
run();
const { WasendClient } = require('@wasend/core');
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
const sessionId = "yourSessionId";
const groupId = "yourGroupId";
// Get group participants
// Assuming getGroupParticipants returns a promise resolving to GroupParticipant[]
client.getGroupParticipants(sessionId, groupId)
.then(participants => {
console.log('Participants:', participants);
})
.catch(error => {
console.error("Failed to get participants:", error);
});
from wasend import WasendClient
client = WasendClient(
api_key='YOUR_API_KEY',
base_url='https://api.wasend.dev'
)
session_id = "yourSessionId"
group_id = "yourGroupId"
# Get group participants
# Assuming get_group_participants returns a list of GroupParticipant objects directly
participants = client.get_group_participants(
session_id=session_id,
group_id=group_id
)
print(f"Participants: {participants}")
# Example: Accessing details of the first participant
if participants:
print(f"First participant JID: {participants[0].jid}")
package main
import (
"fmt"
"log"
"github.com/wasenddev/wasend-sdk-go/wasendcore"
)
func StringPtr(s string) *string { return &s }
func main() {
client := wasendcore.NewWasendClient(&wasendcore.WasendConfig{
ApiKey: StringPtr("YOUR_API_KEY"),
BaseUrl: StringPtr("https://api.wasend.dev"),
})
sessionId := "yourSessionId"
groupId := "yourGroupId"
// Get group participants
// API.md states GetGroupParticipants returns []GroupParticipant, error
participants, err := client.GetGroupParticipants(sessionId, groupId)
if err != nil {
log.Fatalf("Error getting group participants: %v", err)
}
fmt.Printf("Participants: %+v\n", participants)
// Example: Accessing details of the first participant
if len(participants) > 0 {
fmt.Printf("First participant JID: %s\n", participants[0].Jid)
}
}
using Wasend.Core; // Assuming Wasend.Core for WasendClient, WasendConfig, GroupParticipant
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
public class Example
{
public static async Task Main(string[] args) // API.md for .NET doesn't specify async but typically it is.
{
var config = new WasendConfig
{
ApiKey = "YOUR_API_KEY"
// BaseUrl = "https://api.wasend.dev" // Optional
};
var client = new WasendClient(config);
string sessionId = "yourSessionId";
string groupId = "yourGroupId";
// Get group participants
// API.md implies GetGroupParticipants returns List<GroupParticipant>
List<GroupParticipant> participants = client.GetGroupParticipants(sessionId, groupId);
Console.WriteLine($"Participants count: {participants.Count}");
foreach (var p in participants)
{
Console.WriteLine($" JID: {p.Jid}, Admin: {p.IsAdmin}");
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient httpClient = HttpClient.newHttpClient();
String sessionId = "yourSessionId";
String groupId = "yourGroupId";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.wasend.dev/" + sessionId + "/groups/" + groupId + "/participants"))
.header("Authorization", "Bearer YOUR_API_KEY")
.GET()
.build();
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response: " + response.body());
}
}
<?php
$sessionId = 'yourSessionId';
$groupId = 'yourGroupId';
$url = "https://api.wasend.dev/{$sessionId}/groups/{$groupId}/participants";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http';
require 'uri';
require 'json';
session_id = 'yourSessionId'
group_id = 'yourGroupId'
uri = URI("https://api.wasend.dev/#{session_id}/groups/#{group_id}/participants")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true # For HTTPS
request_obj = Net::HTTP::Get.new(uri.request_uri)
request_obj['Authorization'] = 'Bearer YOUR_API_KEY'
response = http.request(request_obj)
puts "Response: #{response.body}"
import Foundation
let sessionId = "yourSessionId"
let groupId = "yourGroupId"
let url = URL(string: "https://api.wasend.dev/\(sessionId)/groups/\(groupId)/participants")!
var request = URLRequest(url: url)
request.httpMethod = "GET"
request.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print("Response: \(responseString)")
}
}
task.resume()
use reqwest::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let session_id = "yourSessionId";
let group_id = "yourGroupId";
let url = format!("https://api.wasend.dev/{}/groups/{}/participants", session_id, group_id);
let response_text = client
.get(&url)
.header("Authorization", "Bearer YOUR_API_KEY")
.send()
.await?
.text()
.await?;
println!("Response: {}", response_text);
Ok(())
}
Response Fields
Field | Type | Description |
---|---|---|
success | boolean | Whether the operation was successful |
participants | array | List of Participant objects |
error | string | Optional. Error message if success is false . |
Participant Object
Field | Type | Description |
---|---|---|
jid | string | Participant's JID (e.g., xxxxxxxxxxx@c.us ) |
phoneNumber | string | Participant's phone number (e.g., +1234567890 ) |
isAdmin | boolean | Whether the participant is an admin |
isSuperAdmin | boolean | Whether the participant is a super admin (usually the creator) |
joinedAt | string | ISO 8601 timestamp of when the participant joined the group |
displayName | string | Optional. Participant's display name / push name |
Error Codes
Code | Description |
---|---|
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Not authorized to get participants |
404 | Not Found - Session or group not found |
429 | Too many requests - Rate limit exceeded |
500 | Internal server error |
Notes
- You must be a member of the group to get its participants.
- The response includes all participants currently in the group along with their roles.
- The
joinedAt
timestamp indicates when the participant became part of the group. - The
isSuperAdmin
field is typically true for the original creator of the group. - The
displayName
might be the participant's WhatsApp profile name if available to the session.