Get Groups Count
Retrieve the total number of groups and count by status for a session
Get Groups Count
Retrieve the total number of groups for a given session, optionally broken down by status.
Endpoint
GET /{sessionId}/groups/count
Headers
Name | Type | Required | Description |
---|---|---|---|
Authorization | string | Yes | Bearer token for authentication |
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
sessionId | string | Yes | The session ID |
Response
{
"total": 5,
"byStatus": {
"active": 3,
"archived": 1,
"deleted": 1
}
}
Examples
curl -X GET "https://api.wasend.dev/{sessionId}/groups/count" \
-H "Authorization: Bearer YOUR_API_KEY"
import { WasendClient } from '@wasend/core';
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
const sessionId = "yourSessionId";
// Get groups count
const countResponse = await client.getGroupsCount(sessionId);
console.log('Total groups:', countResponse.total);
if (countResponse.byStatus) {
console.log('By status:', countResponse.byStatus);
}
const { WasendClient } = require('@wasend/core');
const client = new WasendClient({
apiKey: 'YOUR_API_KEY',
baseUrl: 'https://api.wasend.dev'
});
const sessionId = "yourSessionId";
// Get groups count
const countResponse = await client.getGroupsCount(sessionId);
console.log('Total groups:', countResponse.total);
if (countResponse.byStatus) {
console.log('By status:', countResponse.byStatus);
}
from wasend import WasendClient
client = WasendClient(
api_key='YOUR_API_KEY',
base_url='https://api.wasend.dev'
)
session_id = "yourSessionId"
# Get groups count
count_response = client.get_groups_count(session_id=session_id)
print(f"Total groups: {count_response.total}")
if count_response.by_status:
print(f"By status: {count_response.by_status}")
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"
// Get groups count
countResponse, err := client.GetGroupsCount(sessionId)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total groups: %d\n", countResponse.Total)
if countResponse.ByStatus != nil {
fmt.Printf("By status: %+v\n", countResponse.ByStatus)
}
}
using Wasend.Core;
using System.Threading.Tasks;
public class Example
{
public static async Task Main(string[] args)
{
var config = new WasendConfig
{
ApiKey = "YOUR_API_KEY"
};
var client = new WasendClient(config);
string sessionId = "yourSessionId";
// Get groups count
var countResponse = client.GetGroupsCount(sessionId);
System.Console.WriteLine($"Total groups: {countResponse.Total}");
if (countResponse.ByStatus != null)
{
foreach (var entry in countResponse.ByStatus)
{
System.Console.WriteLine($"Status {entry.Key}: {entry.Value}");
}
}
}
}
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";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.wasend.dev/" + sessionId + "/groups/count"))
.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';
$url = "https://api.wasend.dev/{$sessionId}/groups/count";
$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'
uri = URI("https://api.wasend.dev/#{session_id}/groups/count")
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 url = URL(string: "https://api.wasend.dev/\(sessionId)/groups/count")!
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;
use serde_json::Value;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let session_id = "yourSessionId";
let url = format!("https://api.wasend.dev/{}/groups/count", session_id);
let response_text = client
.get(&url)
.header("Authorization", "Bearer YOUR_API_KEY")
.send()
.await?
.text()
.await?;
println!("Response: {}", response_text);
// Example of parsing the JSON if needed
// let parsed_response: Value = serde_json::from_str(&response_text)?;
// if let Some(total) = parsed_response.get("total").and_then(Value::as_i64) {
// println!("Total groups: {}", total);
// }
Ok(())
}
Response Fields
Field | Type | Description |
---|---|---|
total | number | The total number of groups for the session. |
byStatus | object (string: number) | Optional. Count of groups broken down by status (e.g., active , archived ). |
Error Codes
Code | Description |
---|---|
401 | Unauthorized - Invalid API key |
404 | Not Found - Session not found |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error |
Notes
- This endpoint provides a quick way to get the total number of groups.
- The
byStatus
field is optional and may not be present if there are no groups or if the breakdown is not applicable.