Retrive list of chats

Retrive the WhatsApp chat list

get
chat

https://api.mercury.chat/sdk/v1/whatsapp/chat?api_token=tokenAPI&instance=instance_number&limit=100&skip=0
Get list of chats (conversations) of the WhastApp account. For more information on pagination, refer to the page Pagination.
Request
Response
Request
Query Parameters
skip
optional
number
Number of element to skip (see the "Pagination" section)
limit
optional
number
Number of element to return (see the "Pagination" section)
instance
required
string
The instance number
api_token
required
string
The API token
Response
200: OK
In "data" there is a list of chat object.
{
"object": "list",
"data": [
{
"_id": "5cebb9e09ce23ae3e3bffcc4",
"istance_number": "43279",
"last_message_time": 1558624371,
"last_message_number": 93,
"last_message_number_id": "5cebb9ea9ce23ae3e3c003ae",
"count_message_read": 57,
"chatId": "394455667788@c.us",
"name": "George",
"image": "https://storage.googleapis.com/393245903518/60281896_2563248167033379_8987400469118713856_n.jpg",
"metadata": {
"isGroup": false,
"participants": [],
"groupInviteLink": null
}
},
{
"_id": "5cebb9eb9ce23ae3e3c00510",
"istance_number": "43279",
"last_message_time": 1558619725,
"last_message_number": 110,
"last_message_number_id": "5cebb9eb9ce23ae3e3c004d9",
"count_message_read": 8,
"chatId": "3944556677885-1554893669@g.us",
"name": "Group",
"image": "https://storage.googleapis.com/393245903518/60424915_449566195819408_5445096307360268288_n.jpg",
"metadata": {
"isGroup": true,
"participants": [
"445566778855@c.us",
"443344885755@c.us",
"445566875785@c.us"
],
"groupInviteLink": "https://chat.whatsapp.com/FeUFQQX23VAQIu"
}
}],
"has_more": true,
"count_api": 4,
"reset_count_api": 45
}
400: Bad Request
GENERIC ERROR

Example:

cURL
C#
Go
Java
NodeJs
Objective-C
PHP
Python
Ruby
Swift
cURL
curl -X GET \
'https://api.mercury.chat/sdk/v1/whatsapp/chat?api_token=tokenAPI&instance=instance_number&limit=100&skip=0'
C#
var client = new RestClient("https://api.mercury.chat/sdk/v1/whatsapp/chat?api_token=tokenAPI&instance=instance_number&limit=100&skip=0");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
Go
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.mercury.chat/sdk/v1/whatsapp/chat?api_token=tokenAPI&instance=instance_number&limit=100&skip=0"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
Java
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.mercury.chat/sdk/v1/whatsapp/chat?api_token=tokenAPI&instance=instance_number&limit=100&skip=0")
.get()
.build();
Response response = client.newCall(request).execute();
NodeJs
var request = require("request");
var options = { method: 'GET',
url: 'https://api.mercury.chat/sdk/v1/whatsapp/chat',
qs:
{ api_token: 'tokenAPI',
instance: 'instance_number',
limit: '100',
skip: '0' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Objective-C
#import <Foundation/Foundation.h>
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.mercury.chat/sdk/v1/whatsapp/chat?api_token=tokenAPI&instance=instance_number&limit=100&skip=0"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
PHP
<?php
$request = new HttpRequest();
$request->setUrl('https://api.mercury.chat/sdk/v1/whatsapp/chat');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'api_token' => 'tokenAPI',
'instance' => 'instance_number',
'limit' => '100',
'skip' => '0'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Python
import requests
url = "https://api.mercury.chat/sdk/v1/whatsapp/chat"
querystring = {"api_token":"tokenAPI","instance":"instance_number","limit":"100","skip":"0"}
payload = ""
response = requests.request("GET", url, data=payload, params=querystring)
print(response.text)
Ruby
require 'uri'
require 'net/http'
url = URI("https://api.mercury.chat/sdk/v1/whatsapp/chat?api_token=tokenAPI&instance=instance_number&limit=100&skip=0")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
Swift
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercury.chat/sdk/v1/whatsapp/chat?api_token=tokenAPI&instance=instance_number&limit=100&skip=0")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()