Obtain QR code

Get the QR code to authenticate the phone number on a specific instance

get
instance_whatsapp/getQrCode

https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode?api_token=tokenAPI&instance=instance_number
Get new Qr code for the specified instance. The QR code is valid for 30 seconds from the date of creation (see response). After this time, if necessary, a new request che be sent. If the instance is in "Authenticated" state it forces logout and returns the new QR code.
Request
Response
Query Parameters
instance
optional
string
The instance number
api_token
optional
string
The API token
200: OK
In field "data" there is a field "qrCode" with the image of QR code in data URI image format and a field "time_qrCode" with the timestamp of QR code creation. The QR code is valid only for 30 seconds from the time of creation (time_qrCode)
{
"object": "object",
"data": {
"qrCode": "data:image/png;base64,iVBORw0KGgIV4..."
"time_qrCode": 1567672628
},
"has_more": false,
"count_api": 4,
"reset_count_api": 45
}
404: Not Found
GENERIC ERROR

Example

cUrl
C#
Go
Java
NodeJs
Objective-C
PHP
Python
Ryby
Swift
curl -X GET \
'https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode?api_token=tokenAPI&instance=instance_number'
var client = new RestClient("https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode?api_token=tokenAPI&instance=instance_number");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode?api_token=tokenAPI&instance=instance_number"
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))
}
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode?api_token=tokenAPI&instance=instance_number")
.get()
.build();
Response response = client.newCall(request).execute();
var request = require("request");
var options = { method: 'GET',
url: 'https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode',
qs: { api_token: 'tokenAPI', instance: 'instance_number' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
#import <Foundation/Foundation.h>
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode?api_token=tokenAPI&instance=instance_number"]
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
$request = new HttpRequest();
$request->setUrl('https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'api_token' => 'tokenAPI',
'instance' => 'instance_number'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
import requests
url = "https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode"
querystring = {"api_token":"tokenAPI","instance":"instance_number"}
payload = ""
response = requests.request("GET", url, data=payload, params=querystring)
print(response.text)
require 'uri'
require 'net/http'
url = URI("https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode?api_token=tokenAPI&instance=instance_number")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "https://api.mercury.chat/sdk/v1/whatsapp/instance_whatsapp/getQrCode?api_token=tokenAPI&instance=instance_number")! 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()