curl --request GET \
--url https://api.wppfy.com/sseimport requests
url = "https://api.wppfy.com/sse"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.wppfy.com/sse', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wppfy.com/sse",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.wppfy.com/sse"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.wppfy.com/sse")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wppfy.com/sse")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyevent: messages
data: {"type":"message","data":{"text":"Olá"}}{
"error": "<string>"
}{
"error": "Unauthorized"
}Server-Sent Events (SSE)
Receber eventos em tempo real via Server-Sent Events (SSE)
Funcionalidades principais:
- conexão HTTP persistente em
text/event-stream - seleção granular de tipos de eventos
- filtragem de tipos de mensagens
- autenticação por token na query, compatível com
EventSource
Eventos Disponíveis:
connection: Alterações no estado da conexãohistory: Recebimento de histórico de mensagensmessages: Novas mensagens recebidasmessages_update: Atualizações em mensagens existentescall: Eventos de chamadas VoIPcontacts: Atualizações na agenda de contatospresence: Alterações no status de presençagroups: Modificações em gruposlabels: Gerenciamento de etiquetaschats: Eventos de conversaschat_labels: Alterações em etiquetas de conversas
Estabelece uma conexão persistente para receber eventos em tempo real. Este endpoint:
-
Requer autenticação via token
-
Mantém uma conexão HTTP aberta com o cliente
-
Envia eventos conforme ocorrem no servidor
-
Suporta diferentes tipos de eventos
Exemplo de uso:
const eventSource = new
EventSource('/sse?token=SEU_TOKEN&events=chats,messages');
eventSource.onmessage = function(event) {
const data = JSON.parse(event.data);
console.log('Novo evento:', data);
};
eventSource.onerror = function(error) {
console.error('Erro na conexão SSE:', error);
};
Estrutura de um evento:
{
"type": "message",
"data": {
"id": "3EB0538DA65A59F6D8A251",
"from": "5511999999999@s.whatsapp.net",
"to": "5511888888888@s.whatsapp.net",
"text": "Olá!",
"timestamp": 1672531200000
}
}
curl --request GET \
--url https://api.wppfy.com/sseimport requests
url = "https://api.wppfy.com/sse"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.wppfy.com/sse', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wppfy.com/sse",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.wppfy.com/sse"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.wppfy.com/sse")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wppfy.com/sse")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyevent: messages
data: {"type":"message","data":{"text":"Olá"}}{
"error": "<string>"
}{
"error": "Unauthorized"
}Parâmetros de consulta
Token de autenticação da instância
Tipos de eventos a serem recebidos. Suporta dois formatos:
- Separados por vírgula:
?events=chats,messages - Parâmetros repetidos:
?events=chats&events=messagesstatus_postsenewsletter_messagessó são entregues quando listados pelo nome.
Filtros de mensagens, os mesmos do webhook (wasSentByApi, wasNotSentByApi, fromMeYes,
fromMeNo, isGroupYes, isGroupNo). Valem para messages, messages_update, status_posts e
newsletter_messages; isGroupYes e isGroupNo não valem para status_posts e newsletter_messages.
Suporta dois formatos:
- Separados por vírgula:
?excludeMessages=wasSentByApi,isGroupYes - Parâmetros repetidos:
?excludeMessages=wasSentByApi&excludeMessages=isGroupYes
Resposta
Stream de eventos aberto
The response is of type string.
