اختبار تسليم الـ Webhook
curl --request GET \
--url https://api.benzinga.com/api/v1/webhook/test \
--header 'Key: <api-key>'import requests
url = "https://api.benzinga.com/api/v1/webhook/test"
headers = {"Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Key: '<api-key>'}};
fetch('https://api.benzinga.com/api/v1/webhook/test', 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.benzinga.com/api/v1/webhook/test",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Key: <api-key>"
],
]);
$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.benzinga.com/api/v1/webhook/test"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Key", "<api-key>")
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.benzinga.com/api/v1/webhook/test")
.header("Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.benzinga.com/api/v1/webhook/test")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"status": "success"
}
{
"error": "Invalid destination URL"
}
{
"error": "Failed to deliver test payload to destination"
}
{
"ok": false,
"errors": [
{
"code": "auth_failed",
"id": "unauthorized",
"value": "Invalid or missing authentication token"
}
]
}
{
"ok": false,
"errors": [
{
"code": "no_data_found",
"id": "not_found",
"value": "No data found for the specified parameters"
}
]
}
{
"ok": false,
"errors": [
{
"code": "internal_server_error",
"id": "server_error",
"value": "An unexpected error occurred while processing your request"
}
]
}
واجهة برمجة التطبيقات API لخطافات الويب
اختبار إرسال Webhook
ستُرسل نقطة النهاية هذه بيانات اختبار إلى نقطة الـ webhook الخاصة بك حتى تتمكن من التحقق من صحة عملية التكامل
GET
/
api
/
v1
/
webhook
/
test
اختبار تسليم الـ Webhook
curl --request GET \
--url https://api.benzinga.com/api/v1/webhook/test \
--header 'Key: <api-key>'import requests
url = "https://api.benzinga.com/api/v1/webhook/test"
headers = {"Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Key: '<api-key>'}};
fetch('https://api.benzinga.com/api/v1/webhook/test', 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.benzinga.com/api/v1/webhook/test",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Key: <api-key>"
],
]);
$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.benzinga.com/api/v1/webhook/test"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Key", "<api-key>")
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.benzinga.com/api/v1/webhook/test")
.header("Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.benzinga.com/api/v1/webhook/test")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"status": "success"
}
{
"error": "Invalid destination URL"
}
{
"error": "Failed to deliver test payload to destination"
}
{
"ok": false,
"errors": [
{
"code": "auth_failed",
"id": "unauthorized",
"value": "Invalid or missing authentication token"
}
]
}
{
"ok": false,
"errors": [
{
"code": "no_data_found",
"id": "not_found",
"value": "No data found for the specified parameters"
}
]
}
{
"ok": false,
"errors": [
{
"code": "internal_server_error",
"id": "server_error",
"value": "An unexpected error occurred while processing your request"
}
]
}
استخدم نقطة النهاية هذه لإطلاق إرسال Webhook تجريبي إلى نقطة النهاية التي قمت بتكوينها. يتيح لك ذلك التأكد من أن تكامل Webhook الخاص بك يعمل بشكل صحيح قبل تلقي بيانات الإنتاج الحية.
عند استدعاء نقطة النهاية هذه، سترسل Benzinga حمولة Webhook اختبارية إلى عنوان
destination URL الذي قمت بتكوينه. يتّبع هذا الإرسال الاختباري نفس التنسيق ومنطق إعادة المحاولة كما في عمليات تسليم Webhook في بيئة الإنتاج.
- استجابة فورية: تستجيب واجهة برمجة التطبيقات API برمز الحالة
200إذا تم تفعيل الإرسال التجريبي بنجاح - حمولة تجريبية: تتلقى نقطة الـwebhook النهائية الخاصة بك حمولة اختبارية بالتنسيق نفسه لبيانات بيئة الإنتاج
- رؤوس الإرسال: يتضمّن الإرسال التجريبي الرأس
X-BZ-Deliveryتمامًا مثل عمليات الإرسال في بيئة الإنتاج
- نقطة نهاية Webhook لديك متاحة للعامة على الإنترنت
- يمكن لنقطة النهاية لديك تحليل تنسيق حمولة Webhook بشكل صحيح
- تستجيب نقطة النهاية لديك برموز حالة مناسبة (2xx للنجاح)
- تستجيب نقطة النهاية لديك ضمن مهلة 30 ثانية
- منطق idempotency لديك يتعامل بشكل صحيح مع الترويسة
X-BZ-Deliveryوحقلidفي الحمولة
- اختبر أولًا باستخدام نقاط نهاية Webhook خارج بيئة الإنتاج
- تحقق من أن نقطة النهاية الخاصة بك تستجيب برموز الحالة
200أو204 - تأكد من أن أنظمة التسجيل والمراقبة لديك تلتقط عملية التسليم التجريبية
- تحقق من أن منطق إزالة التكرار لديك يعمل مع معرّف التسليم في الاختبار
- اختبر سيناريوهات الأخطاء عن طريق إرجاع رموز حالة خطأ بشكل مؤقت
424، فهذا يعني أن النظام لم يتمكن من إرسال الحمولة التجريبية إلى نقطة نهاية الوجهة. الأسباب الشائعة:
- عنوان URL للوجهة غير متاح للعامة
- نقطة نهاية الوجهة تُرجع رموز حالة خطأ
- مشكلات في اتصال الشبكة
- أخطاء في شهادة SSL/TLS على نقطة نهاية الوجهة
- يجب أن يكون
destinationعنوان URL صالحًا باستخدام HTTPS - يجب أن تكون قيمة
versionهيwebhook/v1 - يجب أن تكون قيمة
kindهيNews/v1
{
"status": "success"
}
{
"error": "Invalid destination URL"
}
{
"error": "Failed to deliver test payload to destination"
}
{
"ok": false,
"errors": [
{
"code": "auth_failed",
"id": "unauthorized",
"value": "Invalid or missing authentication token"
}
]
}
{
"ok": false,
"errors": [
{
"code": "no_data_found",
"id": "not_found",
"value": "No data found for the specified parameters"
}
]
}
{
"ok": false,
"errors": [
{
"code": "internal_server_error",
"id": "server_error",
"value": "An unexpected error occurred while processing your request"
}
]
}
معلمات الاستعلام
يُحدِّد قيمة الحقل kind في حمولة الاختبار
الخيارات المتاحة:
News/v1, Signals/v1, Earnings/v1, Ratings/v1, Dividends/v1, IPOs/v1, Guidance/v1, Splits/v1, OptionActivity/v1, Conference/v1, Economics/v1, Offerings/v1, MA/v1, Retail/v1, FDA/v1, WIIMs/v1, SECInsiderTransaction/v1, GovernmentTrade/v1 هل كانت هذه الصفحة مفيدة؟