Konuşma geçmişini çekmek
Konuşma listesini ve her konuşmanın mesajlarını sayfa sayfa okuyarak konuşma geçmişini kendi sisteminize alırsınız.
Adımlar
-
Konuşmaları sayfa sayfa okuyun Sizin sisteminiz
GET/v1/whatsapp/conversationsKonuşma listesi sonucu sayfa sayfa verir. Yanıttaki
next_cursordeğerini sonraki istektecursorolarak gönderin. Son sayfada danext_cursorgelir ve boş dizedir; boşsa durun. İmleç opaktır; içeriğini çözmeyin, kendiniz üretmeyin. Her konuşmanın kimliğiconversations[].idalanındadır. Kurallar: Sürüm ve sınırlar › Sayfalama.Konuşmalarda ve mesaj içeriğinde aramak için
qgönderin: konuşmalar numara ve ada göre süzülür, ilk sayfada ayrıca mesaj içeriğinde eşleşenlermessage_hitsiçinde gelir (içerik için en az 3 harf). Mesaj sonuçlarının sonraki sayfasınımessage_hits.next_cursordeğeriyle,qile birliktemessage_cursorolarak isteyin; bu istekte yalnız mesaj sonuçları döner.Sonraki adımda kullanılan alan:
conversations[].id. Ucun alanları, kuralları ve hataları: Konuşmaları sayfa sayfa listeler.İstek
curl "https://api.veritakibi.com/v1/whatsapp/conversations" \ -H "Authorization: Bearer <YOUR_API_KEY>"
// The key is read from an environment variable, never written into the code $apiKey = getenv('VERITAKIBI_API_KEY'); $ch = curl_init('https://api.veritakibi.com/v1/whatsapp/conversations'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $apiKey, ], ]); $response = json_decode(curl_exec($ch), true); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Node 18+: built-in fetch; save as .mjs (import syntax) // The key is read from an environment variable, never written into the code const apiKey = process.env.VERITAKIBI_API_KEY; const res = await fetch('https://api.veritakibi.com/v1/whatsapp/conversations', { method: 'GET', headers: { 'Authorization': `Bearer ${apiKey}`, }, }); const response = await res.json(); const status = res.status;
# Python 3.6+: standard library only (urllib, json) # The key is read from an environment variable, never written into the code import json, os, urllib.request api_key = os.environ['VERITAKIBI_API_KEY'] req = urllib.request.Request( 'https://api.veritakibi.com/v1/whatsapp/conversations', method='GET', headers={ 'Authorization': f'Bearer {api_key}', }, ) with urllib.request.urlopen(req) as res: status = res.status response = json.load(res)
// Go 1.18+: standard library only (net/http, encoding/json) // The key is read from an environment variable, never written into the code package main import ( "encoding/json" "net/http" "os" ) func main() { apiKey := os.Getenv("VERITAKIBI_API_KEY") req, err := http.NewRequest("GET", "https://api.veritakibi.com/v1/whatsapp/conversations", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer "+apiKey) res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() status := res.StatusCode var response map[string]any json.NewDecoder(res.Body).Decode(&response) _, _ = status, response }
// Java 11+: built-in java.net.http; file name Example.java // The key is read from an environment variable, never written into the code import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class Example { public static void main(String[] args) throws Exception { String apiKey = System.getenv("VERITAKIBI_API_KEY"); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.veritakibi.com/v1/whatsapp/conversations")) .header("Authorization", "Bearer " + apiKey) .method("GET", HttpRequest.BodyPublishers.noBody()) .build(); HttpResponse<String> res = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); // JSON text; Java has no built-in JSON parser, use a JSON library String response = res.body(); int status = res.statusCode(); } }
// .NET 6+: top-level statements; default console template (implicit usings on) // The key is read from an environment variable, never written into the code using System.Net.Http.Headers; using System.Text.Json; var apiKey = Environment.GetEnvironmentVariable("VERITAKIBI_API_KEY"); using var http = new HttpClient(); var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.veritakibi.com/v1/whatsapp/conversations"); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); var res = await http.SendAsync(request); var response = JsonDocument.Parse(await res.Content.ReadAsStringAsync()); var status = (int)res.StatusCode;
// C++11+: requires libcurl (link with -lcurl) // The key is read from an environment variable, never written into the code #include <curl/curl.h> #include <cstdlib> #include <string> // Collects the response body into a string static size_t write_body(char* data, size_t size, size_t nmemb, void* out) { static_cast<std::string*>(out)->append(data, size * nmemb); return size * nmemb; } int main() { const char* api_key = std::getenv("VERITAKIBI_API_KEY"); std::string auth = std::string("Authorization: Bearer ") + (api_key ? api_key : ""); std::string response; long status = 0; curl_global_init(CURL_GLOBAL_DEFAULT); CURL* ch = curl_easy_init(); curl_slist* headers = nullptr; headers = curl_slist_append(headers, auth.c_str()); curl_easy_setopt(ch, CURLOPT_URL, "https://api.veritakibi.com/v1/whatsapp/conversations"); curl_easy_setopt(ch, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, write_body); curl_easy_setopt(ch, CURLOPT_WRITEDATA, &response); curl_easy_perform(ch); curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &status); curl_slist_free_all(headers); curl_easy_cleanup(ch); curl_global_cleanup(); }
Yanıt · 200 · değerler yer tutucudur
{ "conversations": [ { "id": 0, "group": "<VALUE>", "status": "<VALUE>", "customer": "<VALUE>", "owner_agent_id": 0, "owner_bot": false, "assignee_agent_id": 0, "owner": { "id": 0, "name": "<VALUE>", "external": false, "bot": false }, "assignee": { "id": 0, "name": "<VALUE>", "external": false, "bot": false }, "assistant_active": false, "claimed_at": "<VALUE>", "last_message_at": "<VALUE>", "created_at": "<VALUE>", "line": { "key": "<VALUE>", "number": "<VALUE>", "label": "<VALUE>" }, "source": { "kind": "<VALUE>", "source_id": "<VALUE>", "title": "<VALUE>", "body": "<VALUE>", "url": "<VALUE>", "message_id": 0, "created_at": "<VALUE>" }, "blocked": false, "name": "<VALUE>", "box": "<VALUE>", "unread": 0, "labels": [ { "id": 0, "name": "<VALUE>", "color": "<VALUE>", "group": "<VALUE>", "position": 0, "tab": false, "show_in_head": false } ], "summary": [ { "label": "<VALUE>", "value": "<VALUE>" } ], "summary_enabled": false } ], "next_cursor": "<VALUE>", "trash_hide_days": 0, "deleted": [ { "conversation_id": 0, "message_id": 0, "deleted_at": "<VALUE>" } ], "message_hits": { "items": [ { "id": 0, "conversation_id": 0, "customer": "<VALUE>", "name": "<VALUE>", "peer_label": "<VALUE>", "direction": "<VALUE>", "kind": "<VALUE>", "sent_at": "<VALUE>", "snippet": "<VALUE>", "cut_start": false, "cut_end": false, "box": "<VALUE>" } ], "next_cursor": "<VALUE>" }, "inbox_view": { "tab_badge": "<VALUE>", "tab_badge_boxes": false, "read_row_tone": false, "tab_colors": false, "tab_palette": {}, "takeover_double_click": false, "box_tabs_as_text": false, "takeover_click": "<VALUE>", "tab_layout": "<VALUE>", "default_tab": "<VALUE>" } } -
Her konuşmanın mesajlarını okuyun Sizin sisteminiz
GET/v1/whatsapp/conversations/{id}/messagesMesaj listesi mesajları gönderim zamanına göre en yeniden geriye doğru verir. Yanıttaki
next_iddeğerini sonraki istektebeforeolarak gönderin;next_id0ise son sayfadasınız. Mesaj alanları: Alan sözlüğü.Ucun alanları, kuralları ve hataları: Bir konuşmanın mesajlarını, en yeniden geriye doğru listeler.
İstek
curl "https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages" \ -H "Authorization: Bearer <YOUR_API_KEY>"
// The key is read from an environment variable, never written into the code $apiKey = getenv('VERITAKIBI_API_KEY'); $ch = curl_init('https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $apiKey, ], ]); $response = json_decode(curl_exec($ch), true); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Node 18+: built-in fetch; save as .mjs (import syntax) // The key is read from an environment variable, never written into the code const apiKey = process.env.VERITAKIBI_API_KEY; const res = await fetch('https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages', { method: 'GET', headers: { 'Authorization': `Bearer ${apiKey}`, }, }); const response = await res.json(); const status = res.status;
# Python 3.6+: standard library only (urllib, json) # The key is read from an environment variable, never written into the code import json, os, urllib.request api_key = os.environ['VERITAKIBI_API_KEY'] req = urllib.request.Request( 'https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages', method='GET', headers={ 'Authorization': f'Bearer {api_key}', }, ) with urllib.request.urlopen(req) as res: status = res.status response = json.load(res)
// Go 1.18+: standard library only (net/http, encoding/json) // The key is read from an environment variable, never written into the code package main import ( "encoding/json" "net/http" "os" ) func main() { apiKey := os.Getenv("VERITAKIBI_API_KEY") req, err := http.NewRequest("GET", "https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages", nil) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer "+apiKey) res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() status := res.StatusCode var response map[string]any json.NewDecoder(res.Body).Decode(&response) _, _ = status, response }
// Java 11+: built-in java.net.http; file name Example.java // The key is read from an environment variable, never written into the code import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class Example { public static void main(String[] args) throws Exception { String apiKey = System.getenv("VERITAKIBI_API_KEY"); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages")) .header("Authorization", "Bearer " + apiKey) .method("GET", HttpRequest.BodyPublishers.noBody()) .build(); HttpResponse<String> res = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); // JSON text; Java has no built-in JSON parser, use a JSON library String response = res.body(); int status = res.statusCode(); } }
// .NET 6+: top-level statements; default console template (implicit usings on) // The key is read from an environment variable, never written into the code using System.Net.Http.Headers; using System.Text.Json; var apiKey = Environment.GetEnvironmentVariable("VERITAKIBI_API_KEY"); using var http = new HttpClient(); var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages"); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); var res = await http.SendAsync(request); var response = JsonDocument.Parse(await res.Content.ReadAsStringAsync()); var status = (int)res.StatusCode;
// C++11+: requires libcurl (link with -lcurl) // The key is read from an environment variable, never written into the code #include <curl/curl.h> #include <cstdlib> #include <string> // Collects the response body into a string static size_t write_body(char* data, size_t size, size_t nmemb, void* out) { static_cast<std::string*>(out)->append(data, size * nmemb); return size * nmemb; } int main() { const char* api_key = std::getenv("VERITAKIBI_API_KEY"); std::string auth = std::string("Authorization: Bearer ") + (api_key ? api_key : ""); std::string response; long status = 0; curl_global_init(CURL_GLOBAL_DEFAULT); CURL* ch = curl_easy_init(); curl_slist* headers = nullptr; headers = curl_slist_append(headers, auth.c_str()); curl_easy_setopt(ch, CURLOPT_URL, "https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages"); curl_easy_setopt(ch, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, write_body); curl_easy_setopt(ch, CURLOPT_WRITEDATA, &response); curl_easy_perform(ch); curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &status); curl_slist_free_all(headers); curl_easy_cleanup(ch); curl_global_cleanup(); }
Yanıt · 200 · değerler yer tutucudur
{ "messages": [ { "id": 0, "direction": "<VALUE>", "kind": "<VALUE>", "body": "<VALUE>", "agent_id": 0, "sent_at": "<VALUE>", "media_state": "<VALUE>", "media_mime": "<VALUE>", "media_size": 0, "location": { "latitude": 0, "longitude": 0, "name": "<VALUE>", "address": "<VALUE>" }, "contacts": [ { "name": "<VALUE>", "phones": [ { "phone": "<VALUE>", "wa_id": "<VALUE>" } ] } ], "reply_to_id": 0, "delivered_at": "<VALUE>", "read_at": "<VALUE>", "reactions": [ { "emoji": "<VALUE>", "direction": "<VALUE>", "author": { "id": 0, "name": "<VALUE>", "external": false, "bot": false } } ], "delivery_state": "<VALUE>", "delivery_error_code": "<VALUE>", "resendable": false, "resend_of": 0, "payload": {}, "header_media": { "kind": "<VALUE>", "link": "<VALUE>", "filename": "<VALUE>" }, "quotable": false, "reactable": false, "author": { "id": 0, "name": "<VALUE>", "external": false, "bot": false } } ], "next_id": 0 }Örnek · bütün sayfalar
# First page without before, later pages with next_id from the response curl "https://api.veritakibi.com/v1/whatsapp/conversations/<CONVERSATION_ID>/messages?before=<NEXT_ID>" \ -H "Authorization: Bearer <YOUR_API_KEY>"
// The key is read from an environment variable, never written into the code function fetchMessages(int $conversationId): array { $apiKey = getenv('VERITAKIBI_API_KEY'); $all = []; $before = 0; do { $url = 'https://api.veritakibi.com/v1/whatsapp/conversations/' . $conversationId . '/messages'; if ($before !== 0) { $url .= '?before=' . $before; } $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey], ]); $page = json_decode(curl_exec($ch), true); if (curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) { throw new RuntimeException($page['error'] ?? 'request failed'); } array_push($all, ...$page['messages']); $before = $page['next_id']; } while ($before !== 0); return $all; }
// Node 18+: built-in fetch; save as .mjs (import syntax) // The key is read from an environment variable, never written into the code const apiKey = process.env.VERITAKIBI_API_KEY; async function* fetchMessages(conversationId) { let before = 0; do { const url = new URL(`https://api.veritakibi.com/v1/whatsapp/conversations/${conversationId}/messages`); if (before !== 0) url.searchParams.set('before', before); const res = await fetch(url, { headers: { 'Authorization': `Bearer ${apiKey}` } }); const page = await res.json(); if (!res.ok) throw new Error(page.error ?? 'request failed'); yield* page.messages; before = page.next_id; } while (before !== 0); }
# Python 3.6+: standard library only (urllib, json) # The key is read from an environment variable, never written into the code import json, os, urllib.request api_key = os.environ['VERITAKIBI_API_KEY'] def fetch_messages(conversation_id): before = 0 while True: url = 'https://api.veritakibi.com/v1/whatsapp/conversations/' \ + str(conversation_id) + '/messages' if before != 0: url += '?before=' + str(before) req = urllib.request.Request(url, headers={'Authorization': f'Bearer {api_key}'}) with urllib.request.urlopen(request) as res: # raises HTTPError on 4xx/5xx page = json.load(res) yield from page['messages'] before = page['next_id'] if before == 0: break
// Go 1.18+: standard library only (net/http, encoding/json); add the function to your own package // The key is read from an environment variable, never written into the code import ( "encoding/json" "errors" "net/http" "os" "strconv" ) type page struct { Messages []map[string]any `json:"messages"` NextID int64 `json:"next_id"` Error string `json:"error"` } func fetchMessages(conversationId int64) ([]map[string]any, error) { apiKey := os.Getenv("VERITAKIBI_API_KEY") var all []map[string]any var before int64 for { url := "https://api.veritakibi.com/v1/whatsapp/conversations/" + strconv.FormatInt(conversationId, 10) + "/messages" if before != 0 { url += "?before=" + strconv.FormatInt(before, 10) } req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } req.Header.Set("Authorization", "Bearer "+apiKey) res, err := http.DefaultClient.Do(req) if err != nil { return nil, err } var s page err = json.NewDecoder(res.Body).Decode(&s) res.Body.Close() if res.StatusCode != http.StatusOK { if s.Error == "" { s.Error = "request failed" } return nil, errors.New(s.Error) } if err != nil { return nil, err } all = append(all, s.Messages...) before = s.NextID if before == 0 { return all, nil } } }
// Java 11+: built-in java.net.http; file name Example.java // Requires Jackson for JSON parsing (com.fasterxml.jackson.core:jackson-databind) // The key is read from an environment variable, never written into the code import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.util.ArrayList; import java.util.List; public class Example { static List<JsonNode> fetchMessages(long conversationId) throws Exception { String apiKey = System.getenv("VERITAKIBI_API_KEY"); HttpClient http = HttpClient.newHttpClient(); ObjectMapper json = new ObjectMapper(); List<JsonNode> all = new ArrayList<>(); long before = 0; do { String url = "https://api.veritakibi.com/v1/whatsapp/conversations/" + conversationId + "/messages"; if (before != 0) { url += "?before=" + before; } HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .header("Authorization", "Bearer " + apiKey) .GET() .build(); HttpResponse<String> res = http.send(request, HttpResponse.BodyHandlers.ofString()); JsonNode page = json.readTree(res.body()); if (res.statusCode() != 200) { throw new RuntimeException(page.path("error").asText("request failed")); } page.get("messages").forEach(all::add); before = page.get("next_id").asLong(); } while (before != 0); return all; } }
// .NET 6+: top-level statements; default console template (implicit usings on) // The key is read from an environment variable, never written into the code using System.Net.Http.Headers; using System.Text.Json; var apiKey = Environment.GetEnvironmentVariable("VERITAKIBI_API_KEY"); using var http = new HttpClient(); async Task<List<JsonElement>> FetchMessages(long conversationId) { var all = new List<JsonElement>(); long before = 0; do { var url = $"https://api.veritakibi.com/v1/whatsapp/conversations/{conversationId}/messages"; if (before != 0) url += $"?before={before}"; var request = new HttpRequestMessage(HttpMethod.Get, url); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); var res = await http.SendAsync(request); var page = JsonDocument.Parse(await res.Content.ReadAsStringAsync()).RootElement; if (!res.IsSuccessStatusCode) throw new Exception(page.TryGetProperty("error", out var err) ? err.GetString() : "request failed"); all.AddRange(page.GetProperty("messages").EnumerateArray()); before = page.GetProperty("next_id").GetInt64(); } while (before != 0); return all; }
// C++11+: requires libcurl and nlohmann/json (link with -lcurl) // The key is read from an environment variable, never written into the code // Call curl_global_init(CURL_GLOBAL_DEFAULT) once at program start #include <curl/curl.h> #include <nlohmann/json.hpp> #include <cstdlib> #include <stdexcept> #include <string> #include <vector> // Collects the response body into a string static size_t write_body(char* data, size_t size, size_t nmemb, void* out) { static_cast<std::string*>(out)->append(data, size * nmemb); return size * nmemb; } std::vector<nlohmann::json> fetch_messages(long long conversation_id) { const char* api_key = std::getenv("VERITAKIBI_API_KEY"); std::string auth = std::string("Authorization: Bearer ") + (api_key ? api_key : ""); std::vector<nlohmann::json> all; long long before = 0; do { std::string url = "https://api.veritakibi.com/v1/whatsapp/conversations/" + std::to_string(conversation_id) + "/messages"; if (before != 0) { url += "?before=" + std::to_string(before); } std::string response; long status = 0; CURL* ch = curl_easy_init(); curl_slist* headers = curl_slist_append(nullptr, auth.c_str()); curl_easy_setopt(ch, CURLOPT_URL, url.c_str()); curl_easy_setopt(ch, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, write_body); curl_easy_setopt(ch, CURLOPT_WRITEDATA, &response); CURLcode result = curl_easy_perform(ch); curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &status); curl_slist_free_all(headers); curl_easy_cleanup(ch); if (result != CURLE_OK) { throw std::runtime_error(curl_easy_strerror(result)); } nlohmann::json page = nlohmann::json::parse(response); if (status != 200) { throw std::runtime_error(page.value("error", "request failed")); } for (const auto& m : page["messages"]) { all.push_back(m); } before = page["next_id"].get<long long>(); } while (before != 0); return all; }
-
Sınıra takılırsanız bekleyin Sizin sisteminiz
Çok sayıda konuşmayı art arda okurken istek
429 RATE_LIMITEDile reddedilebilir. Bir süre bekleyip aynı isteği yeniden gönderin. Sınırın değeri: Hatalar › Hız sınırı.
Sürüm öneki, sayfalama, zaman biçimi ve hata gövdesi: Sürümleme, sayfalama, limitler →