هل الواجهة البرمجية مناسبة لموقعك؟
تربط واجهة النشر البرمجية مساحة عمل Beulog بموقعك أو نظام إدارة المحتوى لديك. يجلب خادم موقعك المقالات المعتمدة، ثم يمنح موقعك كل مقال عنوانًا مستقلًا وتصميمًا وبيانات للبحث. اطلب من مطوّرك أو مزوّد موقعك إعداد الاتصال على الخادم، ويمكنك تجهيز مساحة العمل ومراجعة المحتوى بنفسك.
- اختر الواجهة البرمجية لموقع مخصّص أو إطار عمل مثل Next.js أو نظام إدارة محتوى خاص بك.
- في WordPress، تتولى الإضافة الجاهزة استيراد المقالات. اتبع دليل WordPress.
- المدونة المضمّنة خيار عرض أبسط عندما لا يتيح موقعك سوى إضافة كتلة HTML. تستخدم صفحات إطار Beulog المضمّن توجيه noindex. لنشر المقالات كصفحات أصلية قابلة للزحف على نطاقك، استخدم الواجهة البرمجية أو إضافة WordPress.
جهّز مساحة العمل والمفتاح
- تحقّق من حسابك واختر مساحة العمل الصحيحة. أكمل التحقق من البريد الإلكتروني، ثم اختر مساحة العمل من لوحة التحكم. ينتمي مفتاح النشر إلى مساحة العمل التي أنشأته فيها، ولا يمنح الوصول إلى جميع مساحات حسابك.
- أدخل بيانات الموقع النهائية. في «إعدادات مساحة العمل»، أدخل عنوان موقعك الآمن HTTPS في «الموقع الإلكتروني»، والمسار الفعلي للمقالات في «نمط روابط المقالات»، مثل /blog/{slug}. أضف «اسم الناشر أو العلامة التجارية» و«رابط شعار الناشر» إن توفر. استخدم «اسم الكاتب (اختياري)» و«رابط صفحة الكاتب (اختياري)» للكاتب الذي يُنسب إليه المحتوى فعلًا؛ وترك الاسم فارغًا ينسبه إلى العلامة التجارية.
- أنشئ مفتاح نشر. افتح «الربط والنشر ← موقعك الخاص ← مفاتيح النشر ← إنشاء مفتاح». اختر اسمًا واضحًا خاصًا بهذا الموقع. أبقِ «قراءة المقالات المنشورة» مفعّلة، واترك «الوصول إلى المسودات أيضًا» و«إنشاء مقالات جديدة» غير محدّدتين للموقع العام المعتاد.
- احفظ المفتاح بأمان على الخادم. انسخ المفتاح عند ظهوره؛ لن يُعرض كاملًا مرة أخرى. احفظه في متغيرات بيئة الخادم أو مخزن الأسرار لدى مزوّد الاستضافة. استخدم اسمًا مثل BEULOG_PUBLISHING_KEY، واحفظ معرّف مساحة العمل المتوقع بعد اختبار الاتصال.
- راجع مقالًا تجريبيًا وانشره. راجع العنوان والوصف ووصف الصورة والمصادر والمؤلف واللغة والعنوان النهائي قبل تغيير الحالة إلى منشور. لا تظهر المسودة في الاستجابة الافتراضية للمقالات العامة.
اختبر الاتصال
تستخدم جميع المسارات أدناه عنوان HTTPS الأساسي https://beulog.com/api/v1. استخدم ترويسة Authorization: Bearer للمصادقة. تبدأ مفاتيح النشر الفعلية بـ ab_live_. تحتوي الأمثلة على قيم بديلة وليست مفاتيح صالحة؛ شغّلها على الخادم أو في الطرفية لديك بعد استبدال القيم.
افتح معاملات الاتصال والاستجابة والأمثلة بثماني لغات.
تحقّق من workspace.id وworkspace.name قبل الاستيراد. قارن المعرّف بمساحة العمل التي يتوقعها موقعك، وتوقف إذا اختلف. يحدّد api_version إصدار استجابة الواجهة، بينما يحدّد schema_version داخل المقال إصدار صيغة المحتوى المصدّر.
إذا كانت التحليلات مفعّلة، يحتوي analytics على معرّف الموقع العام ومتطلب الموافقة ونطاقات المواقع المسموح بها فقط؛ وإلا تكون قيمته null. إعدادات نطاقات المواقع للتضمين والتحليلات منفصلة عن مصادقة الواجهة على الخادم، ولا تحل محل مفتاح النشر.
المسارات والصلاحيات
المعامل قيمة ترسلها مع الطلب. يحدد معامل المسار موردًا مثل معرّف المقال. تأتي معاملات الاستعلام بعد ? في الرابط للتحكم في المرشحات أو الصفحات. تحمل الترويسات المفتاح وإعدادات الطلب. يقدّم جسم JSON مدخلات طلب POST. الاستجابة هي نتيجة JSON التي تعيدها Beulog؛ نستخدم نقطة لكتابة الحقول المتداخلة مثل workspace.id.
تحتاج كل الطلبات إلى Authorization: Bearer متبوعًا بمفتاح مساحة العمل. أرسل Accept: application/json. لطلب POST /generate، أرسل أيضًا Content-Type: application/json وIdempotency-Key. العنوان الأساسي هو https://beulog.com/api/v1. تعمل الطلبات على خادمك؛ ويتلقى زوار موقعك الصفحة المنشورة.
| الصلاحية | ما الذي تسمح به |
|---|---|
articles:read | قراءة المقالات المنشورة واختبار الاتصال وقراءة سجل المزامنة. استخدم هذه الصلاحية وحدها للموقع العام. |
drafts:read | صلاحية إضافية لتضمين المسودات عند استخدام drafts=true. لا تحل محل articles:read. أبقِ المعاينات خاصة. |
articles:generate | قراءة أسعار الإنشاء وبدء المهام ومتابعة حالتها. تستطيع هذه الصلاحية إنفاق الرصيد؛ خصّص لها مفتاحًا ومهمة منفصلين على الخادم. |
| الطريقة والمسار | الصلاحية المطلوبة | الاستجابة والغرض |
|---|---|---|
GET /connection | articles:read | هوية مساحة العمل والصلاحيات وapi_version وإعدادات التحليلات العامة إن توفرت. |
GET /articles | articles:read | مصفوفة data بصفحات من المقالات المنشورة المصدّرة كاملة. يتطلب drafts=true صلاحية drafts:read إضافية. |
GET /articles/{id} | articles:read | مقال واحد بمعرّف UUID، ويظل داخل data: [article]. تتطلب قراءة المسودة drafts=true وصلاحية drafts:read. المقال المفقود أو غير المتاح يعيد 404. |
GET /sync | articles:read | سجل مختصر لمعرّفات المقالات المنشورة وعناوينها ورموز تغيّرها، مع نقطة مزامنة وإصدار الإعدادات. |
GET /pricing | articles:generate | الحدود الحالية لحجز الرصيد لمهام article وarticle_with_image وresearch. |
POST /generate | articles:generate | إضافة مهمة إنشاء إلى الطابور. يتطلب جسم JSON وترويسة Idempotency-Key. يعيد معرّف المهمة وحالتها وبيانات الرصيد. |
GET /jobs/{id} | articles:generate | حالة المهمة ومرحلتها وخطؤها وarticle_id وcost وreserved_credits وsettled_at. |
لا توفر مسارات النشر هذه عملية لتعديل المقال أو حذفه أو upsert. يجري التحرير والنشر داخل Beulog، ويتولى تكاملك إدراج النسخة في قاعدة بيانات موقعك أو تحديثها. تجلب الواجهة المقال بمعرّف UUID وليس بالاسم المختصر slug. احتفظ بربط محلي بين slug والمعرّف لمسارات موقعك.
تحقّق من اتصال مساحة العمل
GET /api/v1/connection
تحقّق من المفتاح ومساحة العمل والصلاحيات التي يتيحها.
الصلاحية المطلوبة: articles:read
لا يتضمن الطلب محتوى أو معاملات استعلام. نفّذه قبل الاستيراد وقارن workspace.id بمساحة العمل المطلوب نشرها. يحدّث النجاح أيضًا وقت آخر اتصال للمفتاح.
تكون analytics بقيمة null عندما تكون إحصاءات الزوار معطّلة أو غير مهيّأة. عند تفعيلها تتضمن إعدادات عامة للمتصفح دون مفتاح مساحة العمل. اطلب موافقة الزائر قبل تحميل الإحصاءات.
معاملات الطلب
| المعامل / الموضع | النوع | الإلزام / الافتراضي | المعنى والقيم المقبولة |
|---|---|---|---|
If-None-Matchترويسة | string | اختياري | قيمة ETag السابقة كما هي لطلب ناجح إلى العنوان نفسه وبالمفتاح نفسه. عند التطابق تُرجع 304 دون محتوى. |
أمثلة الطلب — اختر لغتك
اختر لغتك لعرض الطلب نفسه. احفظ مفتاح النشر في متغير البيئة BEULOG_PUBLISHING_KEY على الخادم.
يتطلب Bash وcURL بإصدار 7.76 أو أحدث. لا يحتاج إلى مكتبات إضافية.
احفظ المثال باسم request.sh ثم شغّله: bash request.sh
#!/usr/bin/env bash
set -euo pipefail
# Set BEULOG_PUBLISHING_KEY in your server environment before running.
: "${BEULOG_PUBLISHING_KEY:?Set your server-side publishing key}"
# cURL returns a failure for HTTP errors and keeps the response body.
if response="$(curl --fail-with-body --silent --show-error \
--connect-timeout 10 --max-time 30 \
--request GET \
--header "Authorization: Bearer $BEULOG_PUBLISHING_KEY" \
--header 'Accept: application/json' \
'https://beulog.com/api/v1/connection')"; then
printf '%s\n' "$response"
else
printf '%s\n' "$response" >&2
exit 1
fiيتطلب Node.js بإصدار 20.20 أو أحدث، ويستخدم fetch المدمج دون مكتبات إضافية.
احفظ المثال باسم request.mjs ثم شغّله: node request.mjs
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/connection", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}يتطلب Node.js بإصدار 20.20 أو أحدث. ثبّت أدوات TypeScript مرة واحدة: npm install -D typescript tsx @types/node
احفظ المثال باسم request.ts ثم شغّله: npx tsx request.ts
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/connection", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload: unknown = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
export {};يتطلب Python بإصدار 3.10 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.py ثم شغّله: python3 request.py
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
# Read the key from your server environment, never browser code.
key = os.environ.get("BEULOG_PUBLISHING_KEY")
if not key:
sys.exit("Set BEULOG_PUBLISHING_KEY on your server")
headers = {
"Authorization": f"Bearer {key}",
"Accept": "application/json",
}
request = Request(
"https://beulog.com/api/v1/connection",
headers=headers,
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
payload = json.loads(response.read().decode("utf-8"))
print(json.dumps(payload, indent=2, ensure_ascii=False))
except HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode('utf-8')}", file=sys.stderr)
sys.exit(1)
except (URLError, OSError, ValueError) as error:
print(f"Request failed: {error}", file=sys.stderr)
sys.exit(1)يتطلب PHP بإصدار 8.2 أو أحدث مع تفعيل إضافة cURL.
احفظ المثال باسم request.php ثم شغّله: php request.php
<?php
// Run on your server; the key must never be embedded in browser code.
try {
$key = getenv('BEULOG_PUBLISHING_KEY');
if (!$key) {
throw new RuntimeException('Set BEULOG_PUBLISHING_KEY on your server');
}
$curl = curl_init('https://beulog.com/api/v1/connection');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $key,
'Accept: application/json',
],
]);
$text = curl_exec($curl);
if ($text === false) {
throw new RuntimeException(curl_error($curl));
}
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $text");
}
$payload = json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
} catch (Throwable $error) {
fwrite(STDERR, $error->getMessage() . PHP_EOL);
exit(1);
}يتطلب Ruby بإصدار 3.1 أو أحدث، ويستخدم مكتبتي net/http وjson القياسيتين.
احفظ المثال باسم request.rb ثم شغّله: ruby request.rb
require 'net/http'
require 'uri'
require 'json'
begin
# Read the key from your server environment, never browser code.
key = ENV.fetch('BEULOG_PUBLISHING_KEY')
raise 'Set BEULOG_PUBLISHING_KEY on your server' if key.empty?
uri = URI('https://beulog.com/api/v1/connection')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Bearer #{key}"
request['Accept'] = 'application/json'
response = Net::HTTP.start(
uri.host, uri.port, use_ssl: uri.scheme == 'https',
open_timeout: 10, read_timeout: 30, write_timeout: 30
) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
raise "HTTP #{response.code}: #{response.body}"
end
puts JSON.pretty_generate(JSON.parse(response.body))
rescue StandardError => error
warn "Request failed: #{error.message}"
exit 1
endيتطلب Go بإصدار 1.20 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.go ثم شغّله: go run request.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
func run() error {
// Read the key from your server environment, never browser code.
key := os.Getenv("BEULOG_PUBLISHING_KEY")
if key == "" {
return fmt.Errorf("set BEULOG_PUBLISHING_KEY on your server")
}
request, err := http.NewRequest(
"GET", "https://beulog.com/api/v1/connection",
nil,
)
if err != nil { return err }
request.Header.Set("Authorization", "Bearer " + key)
request.Header.Set("Accept", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil { return err }
defer response.Body.Close()
text, err := io.ReadAll(response.Body)
if err != nil { return err }
if response.StatusCode < 200 || response.StatusCode >= 300 {
return fmt.Errorf("HTTP %d: %s", response.StatusCode, text)
}
var pretty bytes.Buffer
if err := json.Indent(&pretty, text, "", " "); err != nil { return err }
fmt.Println(pretty.String())
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "Request failed:", err)
os.Exit(1)
}
}يتطلب JDK بإصدار 17 أو أحدث، ويستخدم عميل HTTP المدمج دون مكتبات إضافية.
احفظ المثال باسم RequestExample.java ثم شغّله: java RequestExample.java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class RequestExample {
public static void main(String[] args) {
try {
// Read the key from your server environment, never browser code.
String key = System.getenv("BEULOG_PUBLISHING_KEY");
if (key == null || key.isBlank()) {
throw new IllegalStateException("Set BEULOG_PUBLISHING_KEY on your server");
}
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10)).build();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://beulog.com/api/v1/connection"))
.timeout(Duration.ofSeconds(30))
.header("Authorization", "Bearer " + key)
.header("Accept", "application/json")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() < 200 || response.statusCode() >= 300) {
throw new IOException("HTTP " + response.statusCode() + ": " + response.body());
}
System.out.println(response.body());
} catch (Exception error) {
if (error instanceof InterruptedException) Thread.currentThread().interrupt();
System.err.println("Request failed: " + error.getMessage());
System.exit(1);
}
}
}حقول الاستجابة
| الحقل | النوع | ماذا يعني |
|---|---|---|
api_version | string: "1.2" | إصدار الواجهة العامة الحالي. |
workspace.id | UUID | مساحة العمل المرتبطة بالمفتاح. |
workspace.name | string | اسم مساحة العمل. |
workspace.language | "en" | "ar" | "es" | "fr" | "de" | لغة المحتوى الافتراضية لمساحة العمل. |
scopes | string[] | الصلاحيات الممنوحة لهذا المفتاح، وليست جميع صلاحيات الحساب. |
analytics | object | null | إعدادات الإحصاءات العامة، أو null عند التعطيل. |
analytics.site_id | 36-character hexadecimal string | معرّف الموقع العام للإحصاءات؛ يظهر عند التفعيل. |
analytics.consent_required | boolean: true | تلزم موافقة الزائر قبل التتبّع. |
analytics.allowed_origins | string[] | أصول المواقع المسموح لها بإرسال أحداث الإحصاءات. |
{
"api_version": "1.2",
"workspace": {
"id": "00000000-0000-4000-8000-000000000001",
"name": "Example publication",
"language": "en"
},
"scopes": [
"articles:read"
],
"analytics": null
}| الحالة | المعنى والخطوة التالية |
|---|---|
200 | مساحة العمل المتصلة والصلاحيات الممنوحة. |
304 | تطابق قيمة If-None-Match استجابة GET. لا يوجد محتوى؛ استخدم الاستجابة المحفوظة. |
401 | المفتاح مفقود أو غير صالح أو ملغى، أو حساب مالك مساحة العمل غير مؤكّد. |
403 | لا يملك المفتاح الصلاحية المطلوبة. |
429 | تم بلوغ حد الطلبات. اقرأ Retry-After وانتظر قبل المحاولة. |
500 | خطأ غير متوقّع على الخادم. احفظ X-Request-Id للدعم. |
503 | خدمة مطلوبة غير متاحة مؤقتًا. حاول لاحقًا. |
اجلب قائمة المقالات
GET /api/v1/articles
اجلب المقالات المنشورة مع HTML والمحتوى المنظّم والوصف والمصادر.
الصلاحية المطلوبة: articles:read; drafts:read when drafts=true
تُرتّب المقالات بالأحدث إنشاءً ثم بالمعرّف للفصل عند تساوي الوقت. تتضمن الاستجابة محتوى المقالات كاملًا؛ استخدم حجم صفحة مناسبًا واتبع pagination.next_cursor حتى يصبح null. تُرجع المساحة الفارغة data: [].
يُفضّل استخدام المؤشّر أثناء إضافة مقالات جديدة. حافظ على فلتر المسودات والمساحة نفسيهما. لا تجمع المؤشّر مع offset أكبر من صفر؛ تُقبل offset=0. مؤشّرات /articles لا تُستخدم مع /sync.
معاملات الطلب
| المعامل / الموضع | النوع | الإلزام / الافتراضي | المعنى والقيم المقبولة |
|---|---|---|---|
limitاستعلام الرابط | integer: 1–100 | اختياري الافتراضي: 20 | العدد الأقصى للمقالات في الصفحة. تُرجع الأرقام غير الصالحة أو خارج النطاق 400. |
cursorاستعلام الرابط | string, up to 1,000 characters | اختياري | استخدم pagination.next_cursor كما هي من الصفحة السابقة مع ترميز عنوان URL. تحفظ المساحة وفلتر المسودات ووقت الإنشاء والمعرّف. تُرجع المؤشّرات غير الصالحة أو غير المتطابقة 400. |
offsetاستعلام الرابط | integer: 0–100,000 | اختياري الافتراضي: 0 | عدد الصفوف المتجاوزة بالطريقة القديمة. يُفضّل المؤشّر لقائمة متغيرة؛ إضافة مقالات جديدة قد تغيّر صفحات الإزاحة. |
draftsاستعلام الرابط | boolean | اختياري الافتراضي: false | القيمة النصية true فقط تضمّن المسودات. تتطلب drafts:read بالإضافة إلى articles:read. تعامل القيم الأخرى كـ false؛ لا تعرض استجابات المسودات في صفحات عامة. |
If-None-Matchترويسة | string | اختياري | قيمة ETag السابقة كما هي لطلب ناجح إلى العنوان نفسه وبالمفتاح نفسه. عند التطابق تُرجع 304 دون محتوى. |
أمثلة الطلب — اختر لغتك
اختر لغتك لعرض الطلب نفسه. احفظ مفتاح النشر في متغير البيئة BEULOG_PUBLISHING_KEY على الخادم.
يتطلب Bash وcURL بإصدار 7.76 أو أحدث. لا يحتاج إلى مكتبات إضافية.
احفظ المثال باسم request.sh ثم شغّله: bash request.sh
#!/usr/bin/env bash
set -euo pipefail
# Set BEULOG_PUBLISHING_KEY in your server environment before running.
: "${BEULOG_PUBLISHING_KEY:?Set your server-side publishing key}"
# cURL returns a failure for HTTP errors and keeps the response body.
if response="$(curl --fail-with-body --silent --show-error \
--connect-timeout 10 --max-time 30 \
--request GET \
--header "Authorization: Bearer $BEULOG_PUBLISHING_KEY" \
--header 'Accept: application/json' \
'https://beulog.com/api/v1/articles?limit=20')"; then
printf '%s\n' "$response"
else
printf '%s\n' "$response" >&2
exit 1
fiيتطلب Node.js بإصدار 20.20 أو أحدث، ويستخدم fetch المدمج دون مكتبات إضافية.
احفظ المثال باسم request.mjs ثم شغّله: node request.mjs
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/articles?limit=20", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}يتطلب Node.js بإصدار 20.20 أو أحدث. ثبّت أدوات TypeScript مرة واحدة: npm install -D typescript tsx @types/node
احفظ المثال باسم request.ts ثم شغّله: npx tsx request.ts
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/articles?limit=20", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload: unknown = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
export {};يتطلب Python بإصدار 3.10 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.py ثم شغّله: python3 request.py
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
# Read the key from your server environment, never browser code.
key = os.environ.get("BEULOG_PUBLISHING_KEY")
if not key:
sys.exit("Set BEULOG_PUBLISHING_KEY on your server")
headers = {
"Authorization": f"Bearer {key}",
"Accept": "application/json",
}
request = Request(
"https://beulog.com/api/v1/articles?limit=20",
headers=headers,
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
payload = json.loads(response.read().decode("utf-8"))
print(json.dumps(payload, indent=2, ensure_ascii=False))
except HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode('utf-8')}", file=sys.stderr)
sys.exit(1)
except (URLError, OSError, ValueError) as error:
print(f"Request failed: {error}", file=sys.stderr)
sys.exit(1)يتطلب PHP بإصدار 8.2 أو أحدث مع تفعيل إضافة cURL.
احفظ المثال باسم request.php ثم شغّله: php request.php
<?php
// Run on your server; the key must never be embedded in browser code.
try {
$key = getenv('BEULOG_PUBLISHING_KEY');
if (!$key) {
throw new RuntimeException('Set BEULOG_PUBLISHING_KEY on your server');
}
$curl = curl_init('https://beulog.com/api/v1/articles?limit=20');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $key,
'Accept: application/json',
],
]);
$text = curl_exec($curl);
if ($text === false) {
throw new RuntimeException(curl_error($curl));
}
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $text");
}
$payload = json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
} catch (Throwable $error) {
fwrite(STDERR, $error->getMessage() . PHP_EOL);
exit(1);
}يتطلب Ruby بإصدار 3.1 أو أحدث، ويستخدم مكتبتي net/http وjson القياسيتين.
احفظ المثال باسم request.rb ثم شغّله: ruby request.rb
require 'net/http'
require 'uri'
require 'json'
begin
# Read the key from your server environment, never browser code.
key = ENV.fetch('BEULOG_PUBLISHING_KEY')
raise 'Set BEULOG_PUBLISHING_KEY on your server' if key.empty?
uri = URI('https://beulog.com/api/v1/articles?limit=20')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Bearer #{key}"
request['Accept'] = 'application/json'
response = Net::HTTP.start(
uri.host, uri.port, use_ssl: uri.scheme == 'https',
open_timeout: 10, read_timeout: 30, write_timeout: 30
) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
raise "HTTP #{response.code}: #{response.body}"
end
puts JSON.pretty_generate(JSON.parse(response.body))
rescue StandardError => error
warn "Request failed: #{error.message}"
exit 1
endيتطلب Go بإصدار 1.20 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.go ثم شغّله: go run request.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
func run() error {
// Read the key from your server environment, never browser code.
key := os.Getenv("BEULOG_PUBLISHING_KEY")
if key == "" {
return fmt.Errorf("set BEULOG_PUBLISHING_KEY on your server")
}
request, err := http.NewRequest(
"GET", "https://beulog.com/api/v1/articles?limit=20",
nil,
)
if err != nil { return err }
request.Header.Set("Authorization", "Bearer " + key)
request.Header.Set("Accept", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil { return err }
defer response.Body.Close()
text, err := io.ReadAll(response.Body)
if err != nil { return err }
if response.StatusCode < 200 || response.StatusCode >= 300 {
return fmt.Errorf("HTTP %d: %s", response.StatusCode, text)
}
var pretty bytes.Buffer
if err := json.Indent(&pretty, text, "", " "); err != nil { return err }
fmt.Println(pretty.String())
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "Request failed:", err)
os.Exit(1)
}
}يتطلب JDK بإصدار 17 أو أحدث، ويستخدم عميل HTTP المدمج دون مكتبات إضافية.
احفظ المثال باسم RequestExample.java ثم شغّله: java RequestExample.java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class RequestExample {
public static void main(String[] args) {
try {
// Read the key from your server environment, never browser code.
String key = System.getenv("BEULOG_PUBLISHING_KEY");
if (key == null || key.isBlank()) {
throw new IllegalStateException("Set BEULOG_PUBLISHING_KEY on your server");
}
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10)).build();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://beulog.com/api/v1/articles?limit=20"))
.timeout(Duration.ofSeconds(30))
.header("Authorization", "Bearer " + key)
.header("Accept", "application/json")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() < 200 || response.statusCode() >= 300) {
throw new IOException("HTTP " + response.statusCode() + ": " + response.body());
}
System.out.println(response.body());
} catch (Exception error) {
if (error instanceof InterruptedException) Thread.currentThread().interrupt();
System.err.println("Request failed: " + error.getMessage());
System.exit(1);
}
}
}حقول الاستجابة
| الحقل | النوع | ماذا يعني |
|---|---|---|
data | Article[] | مصفوفة تصديرات كاملة للمقالات. يستخدم مسار المقال الواحد الغلاف نفسه. |
pagination.limit | integer | حجم الصفحة؛ 1 لطلب المقال الواحد. |
pagination.offset | integer | null | الإزاحة الحالية عند استخدام الأسلوب القديم، أو null عند استخدام المؤشّر. |
pagination.has_more | boolean | true عند وجود صفحة أخرى. تكون false دائمًا لاستجابة المقال الواحد. |
pagination.next_cursor | string | null | رمز غير شفاف للصفحة التالية. تعني null اكتمال القائمة. استخدم مساحة العمل وفلتر المسودات نفسهما. |
pagination.next_offset | integer | null | الإزاحة التالية بالطريقة القديمة؛ null عند النهاية أو بعد التحول إلى المؤشّر. |
اطّلع على جميع حقول المقال، بما فيها المحتوى وبيانات البحث.
{
"data": [
{
"id": "00000000-0000-4000-8000-000000000002",
"workspace_id": "00000000-0000-4000-8000-000000000001",
"version": 1,
"status": "published",
"title": "How to plan an editorial calendar",
"slug": "plan-an-editorial-calendar",
"language": "en",
"translation_group_id": null,
"created_at": "2026-10-01T09:00:00.000Z",
"updated_at": "2026-10-01T09:00:00.000Z",
"published_at": "2026-10-01T09:00:00.000Z",
"canonical_url": null,
"image_url": null,
"image_width": null,
"image_height": null,
"quality": [],
"generation_warnings": null,
"content": {
"title": "How to plan an editorial calendar",
"slug": "plan-an-editorial-calendar",
"excerpt": "Create a practical publishing plan for your team.",
"metaTitle": "How to plan an editorial calendar",
"metaDescription": "Plan useful topics, clear deadlines and a review process for your publication.",
"category": "Publishing",
"keywords": [
"editorial calendar"
],
"takeaways": [
"Choose useful topics",
"Assign a review date",
"Review before publishing"
],
"sections": [
{
"heading": "Start with your readers",
"summary": "Plan around questions your readers ask.",
"paragraphs": [
"Choose one question and prepare an article that answers it clearly."
],
"bullets": [
"Keep the calendar manageable."
],
"sourceIds": [],
"subsections": [],
"steps": [
"Choose your next topic."
],
"table": null,
"callout": null
}
],
"faqs": [
{
"question": "How often should we publish?",
"answer": "Choose a schedule your team can maintain."
}
],
"imagePrompt": "",
"imageAlt": "",
"imageCaption": "",
"searchIntent": "Build an editorial calendar",
"reviewNotes": [],
"recommendedPublish": true
},
"references": [],
"references_json": [],
"schema_version": "1.1",
"html": "<article class=\"aiblogs-article\" lang=\"en\" dir=\"ltr\"><header><p class=\"aiblogs-category\">Publishing</p><h1>How to plan an editorial calendar</h1><p class=\"aiblogs-lead\">Create a practical publishing plan for your team.</p><p class=\"aiblogs-byline\">Example publication · Updated <time datetime=\"2026-10-01T09:00:00.000Z\">October 1, 2026</time> · 1 min read</p></header>\n <aside class=\"aiblogs-takeaways\"><h2>Key takeaways</h2><ul><li>Choose useful topics</li><li>Assign a review date</li><li>Review before publishing</li></ul></aside>\n <nav class=\"aiblogs-toc\" aria-label=\"In this article\"><h2>In this article</h2><ol><li><a href=\"#article-00000000-0000-4000-8000-000000000002-1\">Start with your readers</a></li><li><a href=\"#article-00000000-0000-4000-8000-000000000002-faq\">Frequently asked questions</a></li></ol></nav>\n <section id=\"article-00000000-0000-4000-8000-000000000002-1\"><h2>Start with your readers</h2><p class=\"aiblogs-section-summary\">Plan around questions your readers ask.</p><p>Choose one question and prepare an article that answers it clearly.</p><ul><li>Keep the calendar manageable.</li></ul><ol class=\"aiblogs-steps\"><li>Choose your next topic.</li></ol></section>\n <section id=\"article-00000000-0000-4000-8000-000000000002-faq\" class=\"aiblogs-faq\"><h2>Frequently asked questions</h2><details open><summary>How often should we publish?</summary><p>Choose a schedule your team can maintain.</p></details></section>\n <section class=\"aiblogs-references\"><h2>Sources & references</h2><ol></ol></section></article>",
"head_html": "<title>How to plan an editorial calendar</title><meta name=\"description\" content=\"Plan useful topics, clear deadlines and a review process for your publication.\" /><meta name=\"robots\" content=\"index, follow, max-image-preview:large\" /><link rel=\"canonical\" href=\"https://example.com/blog/plan-an-editorial-calendar\" /><meta property=\"og:type\" content=\"article\" /><meta property=\"og:title\" content=\"How to plan an editorial calendar\" /><meta property=\"og:description\" content=\"Plan useful topics, clear deadlines and a review process for your publication.\" /><meta property=\"og:url\" content=\"https://example.com/blog/plan-an-editorial-calendar\" /><meta property=\"og:site_name\" content=\"Example publication\" /><meta property=\"og:locale\" content=\"en_US\" /><meta property=\"article:published_time\" content=\"2026-10-01T09:00:00.000Z\" /><meta property=\"article:modified_time\" content=\"2026-10-01T09:00:00.000Z\" /><meta name=\"twitter:card\" content=\"summary\" /><meta name=\"twitter:title\" content=\"How to plan an editorial calendar\" /><meta name=\"twitter:description\" content=\"Plan useful topics, clear deadlines and a review process for your publication.\" /><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https://example.com/blog/plan-an-editorial-calendar#article\",\"url\":\"https://example.com/blog/plan-an-editorial-calendar\",\"mainEntityOfPage\":{\"@type\":\"WebPage\",\"@id\":\"https://example.com/blog/plan-an-editorial-calendar\"},\"headline\":\"How to plan an editorial calendar\",\"description\":\"Plan useful topics, clear deadlines and a review process for your publication.\",\"inLanguage\":\"en\",\"articleSection\":\"Publishing\",\"keywords\":\"editorial calendar\",\"datePublished\":\"2026-10-01T09:00:00.000Z\",\"dateModified\":\"2026-10-01T09:00:00.000Z\",\"author\":{\"@type\":\"Organization\",\"name\":\"Example publication\"},\"publisher\":{\"@type\":\"Organization\",\"name\":\"Example publication\",\"url\":\"https://example.com/\"},\"citation\":[],\"wordCount\":29,\"isAccessibleForFree\":true},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://example.com/blog/plan-an-editorial-calendar#breadcrumbs\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https://example.com/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to plan an editorial calendar\",\"item\":\"https://example.com/blog/plan-an-editorial-calendar\"}]},{\"@type\":\"FAQPage\",\"@id\":\"https://example.com/blog/plan-an-editorial-calendar#faq\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"How often should we publish?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Choose a schedule your team can maintain.\"}}]}]}</script>",
"seo": {
"title": "How to plan an editorial calendar",
"description": "Plan useful topics, clear deadlines and a review process for your publication.",
"canonical": "https://example.com/blog/plan-an-editorial-calendar",
"robots": "index, follow, max-image-preview:large",
"language": "en",
"openGraph": {
"type": "article",
"title": "How to plan an editorial calendar",
"description": "Plan useful topics, clear deadlines and a review process for your publication.",
"url": "https://example.com/blog/plan-an-editorial-calendar",
"siteName": "Example publication",
"locale": "en_US",
"images": [],
"publishedTime": "2026-10-01T09:00:00.000Z",
"modifiedTime": "2026-10-01T09:00:00.000Z"
},
"twitter": {
"card": "summary",
"title": "How to plan an editorial calendar",
"description": "Plan useful topics, clear deadlines and a review process for your publication.",
"image": null,
"imageAlt": ""
}
},
"publishing_checks": [
{
"label": "Title and search description",
"passed": true
},
{
"label": "Cover image and descriptive alt text",
"passed": false
},
{
"label": "Canonical article address",
"passed": true
},
{
"label": "Named publisher",
"passed": true
},
{
"label": "Sections, takeaways and FAQs",
"passed": false
},
{
"label": "Sources cited throughout the article",
"passed": false
},
{
"label": "Configured internal links",
"passed": true
}
],
"reading_minutes": 1,
"json_ld": {
"@context": "https://schema.org",
"@graph": [
{
"@type": "BlogPosting",
"@id": "https://example.com/blog/plan-an-editorial-calendar#article",
"url": "https://example.com/blog/plan-an-editorial-calendar",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://example.com/blog/plan-an-editorial-calendar"
},
"headline": "How to plan an editorial calendar",
"description": "Plan useful topics, clear deadlines and a review process for your publication.",
"inLanguage": "en",
"articleSection": "Publishing",
"keywords": "editorial calendar",
"datePublished": "2026-10-01T09:00:00.000Z",
"dateModified": "2026-10-01T09:00:00.000Z",
"author": {
"@type": "Organization",
"name": "Example publication"
},
"publisher": {
"@type": "Organization",
"name": "Example publication",
"url": "https://example.com/"
},
"citation": [],
"wordCount": 29,
"isAccessibleForFree": true
},
{
"@type": "BreadcrumbList",
"@id": "https://example.com/blog/plan-an-editorial-calendar#breadcrumbs",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://example.com/"
},
{
"@type": "ListItem",
"position": 2,
"name": "How to plan an editorial calendar",
"item": "https://example.com/blog/plan-an-editorial-calendar"
}
]
},
{
"@type": "FAQPage",
"@id": "https://example.com/blog/plan-an-editorial-calendar#faq",
"mainEntity": [
{
"@type": "Question",
"name": "How often should we publish?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Choose a schedule your team can maintain."
}
}
]
}
]
},
"revision": "772066718e41650d049603388c9a374c62817f529ed062f281a5e695c161ef70"
}
],
"pagination": {
"limit": 20,
"offset": 0,
"has_more": false,
"next_offset": null,
"next_cursor": null
}
}| الحالة | المعنى والخطوة التالية |
|---|---|
200 | صفحة من المقالات المصدّرة، أو مصفوفة data فارغة عند عدم وجود نتائج. |
304 | تطابق قيمة If-None-Match استجابة GET. لا يوجد محتوى؛ استخدم الاستجابة المحفوظة. |
400 | أرقام صفحات أو مؤشّر غير صالح، أو مؤشّر مع إزاحة أكبر من صفر. |
401 | المفتاح مفقود أو غير صالح أو ملغى، أو حساب مالك مساحة العمل غير مؤكّد. |
403 | لا يملك المفتاح الصلاحية المطلوبة. |
429 | تم بلوغ حد الطلبات. اقرأ Retry-After وانتظر قبل المحاولة. |
500 | خطأ غير متوقّع على الخادم. احفظ X-Request-Id للدعم. |
503 | خدمة مطلوبة غير متاحة مؤقتًا. حاول لاحقًا. |
اجلب مقالًا واحدًا
GET /api/v1/articles/{id}
نزّل مقالًا كاملًا باستخدام UUID من مساحة عمل المفتاح.
الصلاحية المطلوبة: articles:read; drafts:read when drafts=true
تستخدم النتيجة مصفوفة data نفسها، وتتضمن عنصرًا واحدًا في data[0] وpagination.limit: 1. تُرجع 404 للمقال المفقود أو الموجود في مساحة أخرى أو المسودة المحجوبة بفلتر المنشورات.
استخدم هذا المسار بعد اكتشاف معرّف متغيّر عبر /sync. اقرأ data[0].seo وdata[0].json_ld للوصف، أو اعرض data[0].head_html مرة واحدة. يوجد المقال داخل مصفوفة data.
معاملات الطلب
| المعامل / الموضع | النوع | الإلزام / الافتراضي | المعنى والقيم المقبولة |
|---|---|---|---|
idمسار الرابط | UUID | مطلوب | UUID المقال من /articles أو /sync أو مهمة إنشاء مكتملة. لا تُقبل أسماء المسارات بدل المعرّف. |
draftsاستعلام الرابط | boolean | اختياري الافتراضي: false | القيمة النصية true فقط تضمّن المسودات. تتطلب drafts:read بالإضافة إلى articles:read. تعامل القيم الأخرى كـ false؛ لا تعرض استجابات المسودات في صفحات عامة. |
If-None-Matchترويسة | string | اختياري | قيمة ETag السابقة كما هي لطلب ناجح إلى العنوان نفسه وبالمفتاح نفسه. عند التطابق تُرجع 304 دون محتوى. |
أمثلة الطلب — اختر لغتك
اختر لغتك لعرض الطلب نفسه. احفظ مفتاح النشر في متغير البيئة BEULOG_PUBLISHING_KEY على الخادم.
يتطلب Bash وcURL بإصدار 7.76 أو أحدث. لا يحتاج إلى مكتبات إضافية.
احفظ المثال باسم request.sh ثم شغّله: bash request.sh
#!/usr/bin/env bash
set -euo pipefail
# Set BEULOG_PUBLISHING_KEY in your server environment before running.
: "${BEULOG_PUBLISHING_KEY:?Set your server-side publishing key}"
# cURL returns a failure for HTTP errors and keeps the response body.
if response="$(curl --fail-with-body --silent --show-error \
--connect-timeout 10 --max-time 30 \
--request GET \
--header "Authorization: Bearer $BEULOG_PUBLISHING_KEY" \
--header 'Accept: application/json' \
'https://beulog.com/api/v1/articles/00000000-0000-4000-8000-000000000002')"; then
printf '%s\n' "$response"
else
printf '%s\n' "$response" >&2
exit 1
fiيتطلب Node.js بإصدار 20.20 أو أحدث، ويستخدم fetch المدمج دون مكتبات إضافية.
احفظ المثال باسم request.mjs ثم شغّله: node request.mjs
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/articles/00000000-0000-4000-8000-000000000002", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}يتطلب Node.js بإصدار 20.20 أو أحدث. ثبّت أدوات TypeScript مرة واحدة: npm install -D typescript tsx @types/node
احفظ المثال باسم request.ts ثم شغّله: npx tsx request.ts
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/articles/00000000-0000-4000-8000-000000000002", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload: unknown = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
export {};يتطلب Python بإصدار 3.10 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.py ثم شغّله: python3 request.py
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
# Read the key from your server environment, never browser code.
key = os.environ.get("BEULOG_PUBLISHING_KEY")
if not key:
sys.exit("Set BEULOG_PUBLISHING_KEY on your server")
headers = {
"Authorization": f"Bearer {key}",
"Accept": "application/json",
}
request = Request(
"https://beulog.com/api/v1/articles/00000000-0000-4000-8000-000000000002",
headers=headers,
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
payload = json.loads(response.read().decode("utf-8"))
print(json.dumps(payload, indent=2, ensure_ascii=False))
except HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode('utf-8')}", file=sys.stderr)
sys.exit(1)
except (URLError, OSError, ValueError) as error:
print(f"Request failed: {error}", file=sys.stderr)
sys.exit(1)يتطلب PHP بإصدار 8.2 أو أحدث مع تفعيل إضافة cURL.
احفظ المثال باسم request.php ثم شغّله: php request.php
<?php
// Run on your server; the key must never be embedded in browser code.
try {
$key = getenv('BEULOG_PUBLISHING_KEY');
if (!$key) {
throw new RuntimeException('Set BEULOG_PUBLISHING_KEY on your server');
}
$curl = curl_init('https://beulog.com/api/v1/articles/00000000-0000-4000-8000-000000000002');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $key,
'Accept: application/json',
],
]);
$text = curl_exec($curl);
if ($text === false) {
throw new RuntimeException(curl_error($curl));
}
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $text");
}
$payload = json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
} catch (Throwable $error) {
fwrite(STDERR, $error->getMessage() . PHP_EOL);
exit(1);
}يتطلب Ruby بإصدار 3.1 أو أحدث، ويستخدم مكتبتي net/http وjson القياسيتين.
احفظ المثال باسم request.rb ثم شغّله: ruby request.rb
require 'net/http'
require 'uri'
require 'json'
begin
# Read the key from your server environment, never browser code.
key = ENV.fetch('BEULOG_PUBLISHING_KEY')
raise 'Set BEULOG_PUBLISHING_KEY on your server' if key.empty?
uri = URI('https://beulog.com/api/v1/articles/00000000-0000-4000-8000-000000000002')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Bearer #{key}"
request['Accept'] = 'application/json'
response = Net::HTTP.start(
uri.host, uri.port, use_ssl: uri.scheme == 'https',
open_timeout: 10, read_timeout: 30, write_timeout: 30
) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
raise "HTTP #{response.code}: #{response.body}"
end
puts JSON.pretty_generate(JSON.parse(response.body))
rescue StandardError => error
warn "Request failed: #{error.message}"
exit 1
endيتطلب Go بإصدار 1.20 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.go ثم شغّله: go run request.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
func run() error {
// Read the key from your server environment, never browser code.
key := os.Getenv("BEULOG_PUBLISHING_KEY")
if key == "" {
return fmt.Errorf("set BEULOG_PUBLISHING_KEY on your server")
}
request, err := http.NewRequest(
"GET", "https://beulog.com/api/v1/articles/00000000-0000-4000-8000-000000000002",
nil,
)
if err != nil { return err }
request.Header.Set("Authorization", "Bearer " + key)
request.Header.Set("Accept", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil { return err }
defer response.Body.Close()
text, err := io.ReadAll(response.Body)
if err != nil { return err }
if response.StatusCode < 200 || response.StatusCode >= 300 {
return fmt.Errorf("HTTP %d: %s", response.StatusCode, text)
}
var pretty bytes.Buffer
if err := json.Indent(&pretty, text, "", " "); err != nil { return err }
fmt.Println(pretty.String())
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "Request failed:", err)
os.Exit(1)
}
}يتطلب JDK بإصدار 17 أو أحدث، ويستخدم عميل HTTP المدمج دون مكتبات إضافية.
احفظ المثال باسم RequestExample.java ثم شغّله: java RequestExample.java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class RequestExample {
public static void main(String[] args) {
try {
// Read the key from your server environment, never browser code.
String key = System.getenv("BEULOG_PUBLISHING_KEY");
if (key == null || key.isBlank()) {
throw new IllegalStateException("Set BEULOG_PUBLISHING_KEY on your server");
}
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10)).build();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://beulog.com/api/v1/articles/00000000-0000-4000-8000-000000000002"))
.timeout(Duration.ofSeconds(30))
.header("Authorization", "Bearer " + key)
.header("Accept", "application/json")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() < 200 || response.statusCode() >= 300) {
throw new IOException("HTTP " + response.statusCode() + ": " + response.body());
}
System.out.println(response.body());
} catch (Exception error) {
if (error instanceof InterruptedException) Thread.currentThread().interrupt();
System.err.println("Request failed: " + error.getMessage());
System.exit(1);
}
}
}حقول الاستجابة
| الحقل | النوع | ماذا يعني |
|---|---|---|
data | Article[] | مصفوفة تصديرات كاملة للمقالات. يستخدم مسار المقال الواحد الغلاف نفسه. |
pagination.limit | integer | حجم الصفحة؛ 1 لطلب المقال الواحد. |
pagination.offset | integer | null | الإزاحة الحالية عند استخدام الأسلوب القديم، أو null عند استخدام المؤشّر. |
pagination.has_more | boolean | true عند وجود صفحة أخرى. تكون false دائمًا لاستجابة المقال الواحد. |
pagination.next_cursor | string | null | رمز غير شفاف للصفحة التالية. تعني null اكتمال القائمة. استخدم مساحة العمل وفلتر المسودات نفسهما. |
pagination.next_offset | integer | null | الإزاحة التالية بالطريقة القديمة؛ null عند النهاية أو بعد التحول إلى المؤشّر. |
اطّلع على جميع حقول المقال، بما فيها المحتوى وبيانات البحث.
{
"data": [
{
"id": "00000000-0000-4000-8000-000000000002",
"workspace_id": "00000000-0000-4000-8000-000000000001",
"version": 1,
"status": "published",
"title": "How to plan an editorial calendar",
"slug": "plan-an-editorial-calendar",
"language": "en",
"translation_group_id": null,
"created_at": "2026-10-01T09:00:00.000Z",
"updated_at": "2026-10-01T09:00:00.000Z",
"published_at": "2026-10-01T09:00:00.000Z",
"canonical_url": null,
"image_url": null,
"image_width": null,
"image_height": null,
"quality": [],
"generation_warnings": null,
"content": {
"title": "How to plan an editorial calendar",
"slug": "plan-an-editorial-calendar",
"excerpt": "Create a practical publishing plan for your team.",
"metaTitle": "How to plan an editorial calendar",
"metaDescription": "Plan useful topics, clear deadlines and a review process for your publication.",
"category": "Publishing",
"keywords": [
"editorial calendar"
],
"takeaways": [
"Choose useful topics",
"Assign a review date",
"Review before publishing"
],
"sections": [
{
"heading": "Start with your readers",
"summary": "Plan around questions your readers ask.",
"paragraphs": [
"Choose one question and prepare an article that answers it clearly."
],
"bullets": [
"Keep the calendar manageable."
],
"sourceIds": [],
"subsections": [],
"steps": [
"Choose your next topic."
],
"table": null,
"callout": null
}
],
"faqs": [
{
"question": "How often should we publish?",
"answer": "Choose a schedule your team can maintain."
}
],
"imagePrompt": "",
"imageAlt": "",
"imageCaption": "",
"searchIntent": "Build an editorial calendar",
"reviewNotes": [],
"recommendedPublish": true
},
"references": [],
"references_json": [],
"schema_version": "1.1",
"html": "<article class=\"aiblogs-article\" lang=\"en\" dir=\"ltr\"><header><p class=\"aiblogs-category\">Publishing</p><h1>How to plan an editorial calendar</h1><p class=\"aiblogs-lead\">Create a practical publishing plan for your team.</p><p class=\"aiblogs-byline\">Example publication · Updated <time datetime=\"2026-10-01T09:00:00.000Z\">October 1, 2026</time> · 1 min read</p></header>\n <aside class=\"aiblogs-takeaways\"><h2>Key takeaways</h2><ul><li>Choose useful topics</li><li>Assign a review date</li><li>Review before publishing</li></ul></aside>\n <nav class=\"aiblogs-toc\" aria-label=\"In this article\"><h2>In this article</h2><ol><li><a href=\"#article-00000000-0000-4000-8000-000000000002-1\">Start with your readers</a></li><li><a href=\"#article-00000000-0000-4000-8000-000000000002-faq\">Frequently asked questions</a></li></ol></nav>\n <section id=\"article-00000000-0000-4000-8000-000000000002-1\"><h2>Start with your readers</h2><p class=\"aiblogs-section-summary\">Plan around questions your readers ask.</p><p>Choose one question and prepare an article that answers it clearly.</p><ul><li>Keep the calendar manageable.</li></ul><ol class=\"aiblogs-steps\"><li>Choose your next topic.</li></ol></section>\n <section id=\"article-00000000-0000-4000-8000-000000000002-faq\" class=\"aiblogs-faq\"><h2>Frequently asked questions</h2><details open><summary>How often should we publish?</summary><p>Choose a schedule your team can maintain.</p></details></section>\n <section class=\"aiblogs-references\"><h2>Sources & references</h2><ol></ol></section></article>",
"head_html": "<title>How to plan an editorial calendar</title><meta name=\"description\" content=\"Plan useful topics, clear deadlines and a review process for your publication.\" /><meta name=\"robots\" content=\"index, follow, max-image-preview:large\" /><link rel=\"canonical\" href=\"https://example.com/blog/plan-an-editorial-calendar\" /><meta property=\"og:type\" content=\"article\" /><meta property=\"og:title\" content=\"How to plan an editorial calendar\" /><meta property=\"og:description\" content=\"Plan useful topics, clear deadlines and a review process for your publication.\" /><meta property=\"og:url\" content=\"https://example.com/blog/plan-an-editorial-calendar\" /><meta property=\"og:site_name\" content=\"Example publication\" /><meta property=\"og:locale\" content=\"en_US\" /><meta property=\"article:published_time\" content=\"2026-10-01T09:00:00.000Z\" /><meta property=\"article:modified_time\" content=\"2026-10-01T09:00:00.000Z\" /><meta name=\"twitter:card\" content=\"summary\" /><meta name=\"twitter:title\" content=\"How to plan an editorial calendar\" /><meta name=\"twitter:description\" content=\"Plan useful topics, clear deadlines and a review process for your publication.\" /><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https://example.com/blog/plan-an-editorial-calendar#article\",\"url\":\"https://example.com/blog/plan-an-editorial-calendar\",\"mainEntityOfPage\":{\"@type\":\"WebPage\",\"@id\":\"https://example.com/blog/plan-an-editorial-calendar\"},\"headline\":\"How to plan an editorial calendar\",\"description\":\"Plan useful topics, clear deadlines and a review process for your publication.\",\"inLanguage\":\"en\",\"articleSection\":\"Publishing\",\"keywords\":\"editorial calendar\",\"datePublished\":\"2026-10-01T09:00:00.000Z\",\"dateModified\":\"2026-10-01T09:00:00.000Z\",\"author\":{\"@type\":\"Organization\",\"name\":\"Example publication\"},\"publisher\":{\"@type\":\"Organization\",\"name\":\"Example publication\",\"url\":\"https://example.com/\"},\"citation\":[],\"wordCount\":29,\"isAccessibleForFree\":true},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://example.com/blog/plan-an-editorial-calendar#breadcrumbs\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https://example.com/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to plan an editorial calendar\",\"item\":\"https://example.com/blog/plan-an-editorial-calendar\"}]},{\"@type\":\"FAQPage\",\"@id\":\"https://example.com/blog/plan-an-editorial-calendar#faq\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"How often should we publish?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Choose a schedule your team can maintain.\"}}]}]}</script>",
"seo": {
"title": "How to plan an editorial calendar",
"description": "Plan useful topics, clear deadlines and a review process for your publication.",
"canonical": "https://example.com/blog/plan-an-editorial-calendar",
"robots": "index, follow, max-image-preview:large",
"language": "en",
"openGraph": {
"type": "article",
"title": "How to plan an editorial calendar",
"description": "Plan useful topics, clear deadlines and a review process for your publication.",
"url": "https://example.com/blog/plan-an-editorial-calendar",
"siteName": "Example publication",
"locale": "en_US",
"images": [],
"publishedTime": "2026-10-01T09:00:00.000Z",
"modifiedTime": "2026-10-01T09:00:00.000Z"
},
"twitter": {
"card": "summary",
"title": "How to plan an editorial calendar",
"description": "Plan useful topics, clear deadlines and a review process for your publication.",
"image": null,
"imageAlt": ""
}
},
"publishing_checks": [
{
"label": "Title and search description",
"passed": true
},
{
"label": "Cover image and descriptive alt text",
"passed": false
},
{
"label": "Canonical article address",
"passed": true
},
{
"label": "Named publisher",
"passed": true
},
{
"label": "Sections, takeaways and FAQs",
"passed": false
},
{
"label": "Sources cited throughout the article",
"passed": false
},
{
"label": "Configured internal links",
"passed": true
}
],
"reading_minutes": 1,
"json_ld": {
"@context": "https://schema.org",
"@graph": [
{
"@type": "BlogPosting",
"@id": "https://example.com/blog/plan-an-editorial-calendar#article",
"url": "https://example.com/blog/plan-an-editorial-calendar",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://example.com/blog/plan-an-editorial-calendar"
},
"headline": "How to plan an editorial calendar",
"description": "Plan useful topics, clear deadlines and a review process for your publication.",
"inLanguage": "en",
"articleSection": "Publishing",
"keywords": "editorial calendar",
"datePublished": "2026-10-01T09:00:00.000Z",
"dateModified": "2026-10-01T09:00:00.000Z",
"author": {
"@type": "Organization",
"name": "Example publication"
},
"publisher": {
"@type": "Organization",
"name": "Example publication",
"url": "https://example.com/"
},
"citation": [],
"wordCount": 29,
"isAccessibleForFree": true
},
{
"@type": "BreadcrumbList",
"@id": "https://example.com/blog/plan-an-editorial-calendar#breadcrumbs",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://example.com/"
},
{
"@type": "ListItem",
"position": 2,
"name": "How to plan an editorial calendar",
"item": "https://example.com/blog/plan-an-editorial-calendar"
}
]
},
{
"@type": "FAQPage",
"@id": "https://example.com/blog/plan-an-editorial-calendar#faq",
"mainEntity": [
{
"@type": "Question",
"name": "How often should we publish?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Choose a schedule your team can maintain."
}
}
]
}
]
},
"revision": "772066718e41650d049603388c9a374c62817f529ed062f281a5e695c161ef70"
}
],
"pagination": {
"limit": 1,
"offset": 0,
"has_more": false,
"next_offset": null,
"next_cursor": null
}
}| الحالة | المعنى والخطوة التالية |
|---|---|
200 | مقال كامل واحد في data[0]. |
304 | تطابق قيمة If-None-Match استجابة GET. لا يوجد محتوى؛ استخدم الاستجابة المحفوظة. |
400 | معرّف المقال ليس UUID صالحًا. |
404 | المقال غير موجود في المساحة أو غير ظاهر وفق فلتر المسودات المختار. |
401 | المفتاح مفقود أو غير صالح أو ملغى، أو حساب مالك مساحة العمل غير مؤكّد. |
403 | لا يملك المفتاح الصلاحية المطلوبة. |
429 | تم بلوغ حد الطلبات. اقرأ Retry-After وانتظر قبل المحاولة. |
500 | خطأ غير متوقّع على الخادم. احفظ X-Request-Id للدعم. |
503 | خدمة مطلوبة غير متاحة مؤقتًا. حاول لاحقًا. |
اكتشف المقالات المتغيرة
GET /api/v1/sync
اجلب قائمة مختصرة لمعرّفات المقالات المنشورة وبصمات تغييرها.
الصلاحية المطلوبة: articles:read
احذف since وsettings_revision في المزامنة الأولى. في المرات التالية أرسل checkpoint المحفوظة في since وsettings_revision المحفوظة. غياب بصمة الإعدادات أو تغيّرها يؤدي إلى فحص جميع المنشورات لأن الإعدادات تؤثر في العرض والوصف.
اتبع pagination.next_cursor في جميع الصفحات. يحافظ على الحد الزمني والفلاتر للفحص. احفظ checkpoint وsettings_revision فقط بعد معالجة كل الصفحات أو وضعها في طابور محفوظ. تشمل المزامنة التالية تداخلًا لخمس دقائق قبل since؛ تجنّب التكرار باستخدام معرّف المقال وبصمة القائمة.
تختلف بصمة المزامنة عن بصمة تصدير المقال الكامل. اجلب /articles/{id} للعناصر المتغيرة. تتضمن القائمة منشورات فقط دون سجلات حذف أو إلغاء نشر. طابق دوريًا جميع المنشورات مع المستورد. أعد الفحص عند رفض مؤشّر غير صالح أو قديم.
معاملات الطلب
| المعامل / الموضع | النوع | الإلزام / الافتراضي | المعنى والقيم المقبولة |
|---|---|---|---|
limitاستعلام الرابط | integer: 1–100 | اختياري الافتراضي: 50 | الحد الأقصى لعناصر القائمة في الصفحة دون تنزيل محتوى المقالات. |
sinceاستعلام الرابط | UTC ISO 8601 date-time | اختياري | checkpoint من آخر فحص مكتمل، مثل 2026-10-01T09:00:00.000Z. استخدم UTC باللاحقة Z. يضيف الخادم تداخلًا لخمس دقائق. احذفه للفحص الأول. |
settings_revisionاستعلام الرابط | string | اختياري | بصمة الإعدادات المحفوظة مع checkpoint نفسها. القيمة المفقودة أو المختلفة تلغي since وتبدأ فحصًا كاملًا. |
cursorاستعلام الرابط | string, up to 2,000 characters | اختياري | pagination.next_cursor كما هي للفحص الجاري. تعتمد since وحده الزمني المحفوظين؛ يجب أن تنتمي إلى المساحة وبصمة إعداداتها الحالية. احذفها لبدء فحص جديد. |
If-None-Matchترويسة | string | اختياري | قيمة ETag السابقة كما هي لطلب ناجح إلى العنوان نفسه وبالمفتاح نفسه. عند التطابق تُرجع 304 دون محتوى. |
أمثلة الطلب — اختر لغتك
اختر لغتك لعرض الطلب نفسه. احفظ مفتاح النشر في متغير البيئة BEULOG_PUBLISHING_KEY على الخادم.
يتطلب Bash وcURL بإصدار 7.76 أو أحدث. لا يحتاج إلى مكتبات إضافية.
احفظ المثال باسم request.sh ثم شغّله: bash request.sh
#!/usr/bin/env bash
set -euo pipefail
# Set BEULOG_PUBLISHING_KEY in your server environment before running.
: "${BEULOG_PUBLISHING_KEY:?Set your server-side publishing key}"
# cURL returns a failure for HTTP errors and keeps the response body.
if response="$(curl --fail-with-body --silent --show-error \
--connect-timeout 10 --max-time 30 \
--request GET \
--header "Authorization: Bearer $BEULOG_PUBLISHING_KEY" \
--header 'Accept: application/json' \
'https://beulog.com/api/v1/sync?limit=50')"; then
printf '%s\n' "$response"
else
printf '%s\n' "$response" >&2
exit 1
fiيتطلب Node.js بإصدار 20.20 أو أحدث، ويستخدم fetch المدمج دون مكتبات إضافية.
احفظ المثال باسم request.mjs ثم شغّله: node request.mjs
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/sync?limit=50", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}يتطلب Node.js بإصدار 20.20 أو أحدث. ثبّت أدوات TypeScript مرة واحدة: npm install -D typescript tsx @types/node
احفظ المثال باسم request.ts ثم شغّله: npx tsx request.ts
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/sync?limit=50", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload: unknown = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
export {};يتطلب Python بإصدار 3.10 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.py ثم شغّله: python3 request.py
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
# Read the key from your server environment, never browser code.
key = os.environ.get("BEULOG_PUBLISHING_KEY")
if not key:
sys.exit("Set BEULOG_PUBLISHING_KEY on your server")
headers = {
"Authorization": f"Bearer {key}",
"Accept": "application/json",
}
request = Request(
"https://beulog.com/api/v1/sync?limit=50",
headers=headers,
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
payload = json.loads(response.read().decode("utf-8"))
print(json.dumps(payload, indent=2, ensure_ascii=False))
except HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode('utf-8')}", file=sys.stderr)
sys.exit(1)
except (URLError, OSError, ValueError) as error:
print(f"Request failed: {error}", file=sys.stderr)
sys.exit(1)يتطلب PHP بإصدار 8.2 أو أحدث مع تفعيل إضافة cURL.
احفظ المثال باسم request.php ثم شغّله: php request.php
<?php
// Run on your server; the key must never be embedded in browser code.
try {
$key = getenv('BEULOG_PUBLISHING_KEY');
if (!$key) {
throw new RuntimeException('Set BEULOG_PUBLISHING_KEY on your server');
}
$curl = curl_init('https://beulog.com/api/v1/sync?limit=50');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $key,
'Accept: application/json',
],
]);
$text = curl_exec($curl);
if ($text === false) {
throw new RuntimeException(curl_error($curl));
}
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $text");
}
$payload = json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
} catch (Throwable $error) {
fwrite(STDERR, $error->getMessage() . PHP_EOL);
exit(1);
}يتطلب Ruby بإصدار 3.1 أو أحدث، ويستخدم مكتبتي net/http وjson القياسيتين.
احفظ المثال باسم request.rb ثم شغّله: ruby request.rb
require 'net/http'
require 'uri'
require 'json'
begin
# Read the key from your server environment, never browser code.
key = ENV.fetch('BEULOG_PUBLISHING_KEY')
raise 'Set BEULOG_PUBLISHING_KEY on your server' if key.empty?
uri = URI('https://beulog.com/api/v1/sync?limit=50')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Bearer #{key}"
request['Accept'] = 'application/json'
response = Net::HTTP.start(
uri.host, uri.port, use_ssl: uri.scheme == 'https',
open_timeout: 10, read_timeout: 30, write_timeout: 30
) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
raise "HTTP #{response.code}: #{response.body}"
end
puts JSON.pretty_generate(JSON.parse(response.body))
rescue StandardError => error
warn "Request failed: #{error.message}"
exit 1
endيتطلب Go بإصدار 1.20 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.go ثم شغّله: go run request.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
func run() error {
// Read the key from your server environment, never browser code.
key := os.Getenv("BEULOG_PUBLISHING_KEY")
if key == "" {
return fmt.Errorf("set BEULOG_PUBLISHING_KEY on your server")
}
request, err := http.NewRequest(
"GET", "https://beulog.com/api/v1/sync?limit=50",
nil,
)
if err != nil { return err }
request.Header.Set("Authorization", "Bearer " + key)
request.Header.Set("Accept", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil { return err }
defer response.Body.Close()
text, err := io.ReadAll(response.Body)
if err != nil { return err }
if response.StatusCode < 200 || response.StatusCode >= 300 {
return fmt.Errorf("HTTP %d: %s", response.StatusCode, text)
}
var pretty bytes.Buffer
if err := json.Indent(&pretty, text, "", " "); err != nil { return err }
fmt.Println(pretty.String())
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "Request failed:", err)
os.Exit(1)
}
}يتطلب JDK بإصدار 17 أو أحدث، ويستخدم عميل HTTP المدمج دون مكتبات إضافية.
احفظ المثال باسم RequestExample.java ثم شغّله: java RequestExample.java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class RequestExample {
public static void main(String[] args) {
try {
// Read the key from your server environment, never browser code.
String key = System.getenv("BEULOG_PUBLISHING_KEY");
if (key == null || key.isBlank()) {
throw new IllegalStateException("Set BEULOG_PUBLISHING_KEY on your server");
}
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10)).build();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://beulog.com/api/v1/sync?limit=50"))
.timeout(Duration.ofSeconds(30))
.header("Authorization", "Bearer " + key)
.header("Accept", "application/json")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() < 200 || response.statusCode() >= 300) {
throw new IOException("HTTP " + response.statusCode() + ": " + response.body());
}
System.out.println(response.body());
} catch (Exception error) {
if (error instanceof InterruptedException) Thread.currentThread().interrupt();
System.err.println("Request failed: " + error.getMessage());
System.exit(1);
}
}
}حقول الاستجابة
| الحقل | النوع | ماذا يعني |
|---|---|---|
api_version | string: "1.2" | إصدار عقد الواجهة العامة. |
workspace_id | UUID | المساحة المفحوصة؛ قارنها بالمساحة المتوقّعة. |
settings_revision | string | بصمة إعدادات المساحة الحالية؛ احفظها مع checkpoint بعد اكتمال الفحص. |
checkpoint | UTC ISO 8601 date-time | الحد الزمني الأعلى للفحص؛ يبقى ثابتًا بين صفحات المؤشّر. ليس وقت آخر مقال في القائمة. |
data[] | { id: UUID, title: string, revision: string }[] | عناصر قائمة المنشورات مرتبة بوقت التعديل ثم المعرّف. قد تكون data فارغة. تتبع revision المعرّف ونسخة التعديل ووقته وإعدادات المساحة. |
data[].id | UUID | معرّف المقال المنشور. اجلب /articles/{id} لتصديره كاملًا. |
data[].title | string | عنوان المقال المحفوظ للتعرّف عليه دون تنزيل محتواه. |
data[].revision | string | بصمة تغيير غير شفافة تعتمد على المعرّف ونسخة التعديل ووقته وإعدادات المساحة. تختلف عن data[0].revision في تصدير المقال الكامل. |
pagination.next_cursor | string | null | رمز الصفحة التالية للفحص؛ null تعني اكتماله. لا تحدّث checkpoint المحفوظة قبل ذلك. |
{
"api_version": "1.2",
"workspace_id": "00000000-0000-4000-8000-000000000001",
"settings_revision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"checkpoint": "2026-10-01T09:05:00.000000Z",
"data": [
{
"id": "00000000-0000-4000-8000-000000000002",
"title": "How to plan an editorial calendar",
"revision": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
}
],
"pagination": {
"next_cursor": null
}
}| الحالة | المعنى والخطوة التالية |
|---|---|
200 | صفحة قائمة مختصرة؛ مصفوفة data الفارغة صالحة. |
304 | تطابق قيمة If-None-Match استجابة GET. لا يوجد محتوى؛ استخدم الاستجابة المحفوظة. |
400 | حد أو تاريخ UTC غير صالح، أو مؤشّر غير صالح أو قديم. أعد الفحص الحالي لأخطاء المؤشّر. |
401 | المفتاح مفقود أو غير صالح أو ملغى، أو حساب مالك مساحة العمل غير مؤكّد. |
403 | لا يملك المفتاح الصلاحية المطلوبة. |
429 | تم بلوغ حد الطلبات. اقرأ Retry-After وانتظر قبل المحاولة. |
500 | خطأ غير متوقّع على الخادم. احفظ X-Request-Id للدعم. |
503 | خدمة مطلوبة غير متاحة مؤقتًا. حاول لاحقًا. |
تحقّق من حجز الرصيد
GET /api/v1/pricing
اقرأ الحدود الحالية لحجز الرصيد قبل طلب الإنشاء.
الصلاحية المطلوبة: articles:generate
تمثّل القيم حدود الإنفاق المحجوزة عند إدراج المهمة، وليست أسعارًا نهائية ثابتة. تُسوّى المهام الناجحة وفق الاستخدام ويُرد الرصيد غير المستخدم؛ وتُرد حجوزات المهام الفاشلة. اجلب القيم الحالية واضبط maxCredits في /generate لفرض حدك.
قيم المثال تعبّر عن العقد الحالي وقد تتغير. اعتمد على استجابة /pricing الفعلية لحدود الحجز.
معاملات الطلب
| المعامل / الموضع | النوع | الإلزام / الافتراضي | المعنى والقيم المقبولة |
|---|---|---|---|
If-None-Matchترويسة | string | اختياري | قيمة ETag السابقة كما هي لطلب ناجح إلى العنوان نفسه وبالمفتاح نفسه. عند التطابق تُرجع 304 دون محتوى. |
أمثلة الطلب — اختر لغتك
اختر لغتك لعرض الطلب نفسه. احفظ مفتاح النشر في متغير البيئة BEULOG_PUBLISHING_KEY على الخادم.
يتطلب Bash وcURL بإصدار 7.76 أو أحدث. لا يحتاج إلى مكتبات إضافية.
احفظ المثال باسم request.sh ثم شغّله: bash request.sh
#!/usr/bin/env bash
set -euo pipefail
# Set BEULOG_PUBLISHING_KEY in your server environment before running.
: "${BEULOG_PUBLISHING_KEY:?Set your server-side publishing key}"
# cURL returns a failure for HTTP errors and keeps the response body.
if response="$(curl --fail-with-body --silent --show-error \
--connect-timeout 10 --max-time 30 \
--request GET \
--header "Authorization: Bearer $BEULOG_PUBLISHING_KEY" \
--header 'Accept: application/json' \
'https://beulog.com/api/v1/pricing')"; then
printf '%s\n' "$response"
else
printf '%s\n' "$response" >&2
exit 1
fiيتطلب Node.js بإصدار 20.20 أو أحدث، ويستخدم fetch المدمج دون مكتبات إضافية.
احفظ المثال باسم request.mjs ثم شغّله: node request.mjs
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/pricing", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}يتطلب Node.js بإصدار 20.20 أو أحدث. ثبّت أدوات TypeScript مرة واحدة: npm install -D typescript tsx @types/node
احفظ المثال باسم request.ts ثم شغّله: npx tsx request.ts
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/pricing", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload: unknown = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
export {};يتطلب Python بإصدار 3.10 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.py ثم شغّله: python3 request.py
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
# Read the key from your server environment, never browser code.
key = os.environ.get("BEULOG_PUBLISHING_KEY")
if not key:
sys.exit("Set BEULOG_PUBLISHING_KEY on your server")
headers = {
"Authorization": f"Bearer {key}",
"Accept": "application/json",
}
request = Request(
"https://beulog.com/api/v1/pricing",
headers=headers,
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
payload = json.loads(response.read().decode("utf-8"))
print(json.dumps(payload, indent=2, ensure_ascii=False))
except HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode('utf-8')}", file=sys.stderr)
sys.exit(1)
except (URLError, OSError, ValueError) as error:
print(f"Request failed: {error}", file=sys.stderr)
sys.exit(1)يتطلب PHP بإصدار 8.2 أو أحدث مع تفعيل إضافة cURL.
احفظ المثال باسم request.php ثم شغّله: php request.php
<?php
// Run on your server; the key must never be embedded in browser code.
try {
$key = getenv('BEULOG_PUBLISHING_KEY');
if (!$key) {
throw new RuntimeException('Set BEULOG_PUBLISHING_KEY on your server');
}
$curl = curl_init('https://beulog.com/api/v1/pricing');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $key,
'Accept: application/json',
],
]);
$text = curl_exec($curl);
if ($text === false) {
throw new RuntimeException(curl_error($curl));
}
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $text");
}
$payload = json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
} catch (Throwable $error) {
fwrite(STDERR, $error->getMessage() . PHP_EOL);
exit(1);
}يتطلب Ruby بإصدار 3.1 أو أحدث، ويستخدم مكتبتي net/http وjson القياسيتين.
احفظ المثال باسم request.rb ثم شغّله: ruby request.rb
require 'net/http'
require 'uri'
require 'json'
begin
# Read the key from your server environment, never browser code.
key = ENV.fetch('BEULOG_PUBLISHING_KEY')
raise 'Set BEULOG_PUBLISHING_KEY on your server' if key.empty?
uri = URI('https://beulog.com/api/v1/pricing')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Bearer #{key}"
request['Accept'] = 'application/json'
response = Net::HTTP.start(
uri.host, uri.port, use_ssl: uri.scheme == 'https',
open_timeout: 10, read_timeout: 30, write_timeout: 30
) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
raise "HTTP #{response.code}: #{response.body}"
end
puts JSON.pretty_generate(JSON.parse(response.body))
rescue StandardError => error
warn "Request failed: #{error.message}"
exit 1
endيتطلب Go بإصدار 1.20 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.go ثم شغّله: go run request.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
func run() error {
// Read the key from your server environment, never browser code.
key := os.Getenv("BEULOG_PUBLISHING_KEY")
if key == "" {
return fmt.Errorf("set BEULOG_PUBLISHING_KEY on your server")
}
request, err := http.NewRequest(
"GET", "https://beulog.com/api/v1/pricing",
nil,
)
if err != nil { return err }
request.Header.Set("Authorization", "Bearer " + key)
request.Header.Set("Accept", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil { return err }
defer response.Body.Close()
text, err := io.ReadAll(response.Body)
if err != nil { return err }
if response.StatusCode < 200 || response.StatusCode >= 300 {
return fmt.Errorf("HTTP %d: %s", response.StatusCode, text)
}
var pretty bytes.Buffer
if err := json.Indent(&pretty, text, "", " "); err != nil { return err }
fmt.Println(pretty.String())
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "Request failed:", err)
os.Exit(1)
}
}يتطلب JDK بإصدار 17 أو أحدث، ويستخدم عميل HTTP المدمج دون مكتبات إضافية.
احفظ المثال باسم RequestExample.java ثم شغّله: java RequestExample.java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class RequestExample {
public static void main(String[] args) {
try {
// Read the key from your server environment, never browser code.
String key = System.getenv("BEULOG_PUBLISHING_KEY");
if (key == null || key.isBlank()) {
throw new IllegalStateException("Set BEULOG_PUBLISHING_KEY on your server");
}
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10)).build();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://beulog.com/api/v1/pricing"))
.timeout(Duration.ofSeconds(30))
.header("Authorization", "Bearer " + key)
.header("Accept", "application/json")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() < 200 || response.statusCode() >= 300) {
throw new IOException("HTTP " + response.statusCode() + ": " + response.body());
}
System.out.println(response.body());
} catch (Exception error) {
if (error instanceof InterruptedException) Thread.currentThread().interrupt();
System.err.println("Request failed: " + error.getMessage());
System.exit(1);
}
}
}حقول الاستجابة
| الحقل | النوع | ماذا يعني |
|---|---|---|
billing | string: "usage_based" | يُحاسب الإنشاء وفق الاستخدام ضمن حجز أقصى. |
article | integer (credits) | الحجز الأقصى لمقال بقيمة image=false. |
article_with_image | integer (credits) | الحجز الأقصى لمقال بقيمة image=true. |
research | integer (credits) | الحجز الأقصى لمهمة بحث. |
description | string | شرح الحجز ورد الرصيد. |
{
"billing": "usage_based",
"article": 40,
"article_with_image": 45,
"research": 10,
"description": "Maximum credits reserved per job. Unused credits are returned on completion. Failed jobs are fully refunded."
}| الحالة | المعنى والخطوة التالية |
|---|---|
200 | الحدود الحالية لحجز الرصيد. |
304 | تطابق قيمة If-None-Match استجابة GET. لا يوجد محتوى؛ استخدم الاستجابة المحفوظة. |
401 | المفتاح مفقود أو غير صالح أو ملغى، أو حساب مالك مساحة العمل غير مؤكّد. |
403 | لا يملك المفتاح الصلاحية المطلوبة. |
429 | تم بلوغ حد الطلبات. اقرأ Retry-After وانتظر قبل المحاولة. |
500 | خطأ غير متوقّع على الخادم. احفظ X-Request-Id للدعم. |
503 | خدمة مطلوبة غير متاحة مؤقتًا. حاول لاحقًا. |
اطلب إنشاء مقال أو بحث
POST /api/v1/generate
احجز الرصيد وأدرج مهمة إنشاء غير متزامنة.
الصلاحية المطلوبة: articles:generate
أرسل كائن JSON حتى عند استخدام القيم الافتراضية جميعها ({} صالح). حد المحتوى 300000 بايت. النجاح 200 يتضمن معرّف مهمة وليس المقال الناتج. تابع GET /jobs/{id} بفواصل زمنية، واجلب GET /articles/{article_id} بعد اكتمال مهمة المقال. المحتوى الجديد مسودة افتراضيًا؛ قراءته قبل النشر تتطلب drafts:read وdrafts=true.
استخدم Idempotency-Key جديدة لكل مهمة مقصودة. أعد القيمة نفسها بالمفتاح البرمجي نفسه عند إعادة المهمة؛ تُرجع المهمة الموجودة دون حجز إضافي. تغيير المحتوى لا يغير المهمة الموجودة بالقيمة نفسها. يرتبط منع التكرار بالمفتاح البرمجي؛ قد ينشئ مفتاح آخر مهمة مستقلة. لا توجد مدة انتهاء موثّقة.
توفر إعدادات المساحة الجمهور واللغة والأسلوب وخيارات الإنشاء الأخرى. لا يمكن الإنشاء في مساحة مؤرشفة. تُرفض قيود الفوترة أو الرصيد غير الكافي أو تعطل الخدمات أو حجز أعلى من maxCredits قبل إدراج مهمة جديدة. تطلب autoPublish النشر لكن فحوص الجودة قد تُبقي النتيجة مسودة؛ اقرأ status للمقال الناتج.
معاملات الطلب
| المعامل / الموضع | النوع | الإلزام / الافتراضي | المعنى والقيم المقبولة |
|---|---|---|---|
Idempotency-Keyترويسة | string: 1–128 characters | مطلوب | معرّف إعادة محاولة فريد للمهمة المقصودة. أعده للمحاولات واستخدم قيمة جديدة للمهمة الجديدة. |
Content-Typeترويسة | application/json | اختياري | ترويسة موصى بها لإرسال JSON بترميز UTF-8. يقرأ الخادم JSON بغض النظر عن الترويسة؛ تُرجع 400 للـ JSON غير الصالح أو المحتوى الذي ليس كائنًا. |
topicجسم JSON | string: up to 1,500 characters | اختياري الافتراضي: "" | موضوع أو تعليمات تحريرية. تُحذف المسافات المحيطة. النص الفارغ يتيح استخدام موضوعات مساحة العمل. |
imageجسم JSON | boolean | اختياري الافتراضي: true | اطلب صورة غلاف لإنشاء المقال. اضبط false للمقالات النصية والبحث. يفحص توافر خدمة الصور بهذه القيمة حتى عندما تكون kind=research. |
autoPublishجسم JSON | boolean | اختياري الافتراضي: false | اطلب النشر بعد الإنشاء؛ قد تُبقي مراجعة الجودة المقال مسودة. لا تنشر ملخص البحث. |
kindجسم JSON | "article" | "research" | اختياري الافتراضي: "article" | article ينشئ مقالًا. research ينشئ ملخص بحث يظهر في المساحة؛ قد يكون article_id=null عند اكتماله، ولا تتضمن الواجهة العامة مسارًا لجلب البحث. |
researchIdجسم JSON | UUID | اختياري | معرّف ملخص بحث موجود في المساحة لاستخدامه في الإنشاء. تُرجع 404 لملخص مفقود أو تابع لمساحة أخرى. |
maxCreditsجسم JSON | integer: 1–1,000,000 | اختياري | حد أقصى اختياري للحجز المقبول. إذا تجاوزه الحجز الحالي تُرجع 409 دون حجز رصيد. غيابه يقبل الحد الحالي؛ تحقّق من /pricing أولًا. |
أمثلة الطلب — اختر لغتك
قبل تشغيل المثال، استخدم مفتاحًا بصلاحية articles:generate، واستبدل Idempotency-Key بمعرّف المهمة المحفوظ لديك، وتحقّق من GET /pricing. قيمة maxCredits البالغة 40 سقف إنفاق توضيحي؛ إذا كان الحجز الحالي أعلى فستعاد 409. حدّد سقفك المعتمد قبل الإرسال.
اختر لغتك لعرض الطلب نفسه. احفظ مفتاح النشر في متغير البيئة BEULOG_PUBLISHING_KEY على الخادم.
استبدل قيمة Idempotency-Key في المثال بقيمة فريدة تحفظها لكل مهمة جديدة، وأعد استخدام القيمة نفسها عند إعادة المحاولة.
يتطلب Bash وcURL بإصدار 7.76 أو أحدث. لا يحتاج إلى مكتبات إضافية.
احفظ المثال باسم request.sh ثم شغّله: bash request.sh
#!/usr/bin/env bash
set -euo pipefail
# Set BEULOG_PUBLISHING_KEY in your server environment before running.
: "${BEULOG_PUBLISHING_KEY:?Set your server-side publishing key}"
# cURL returns a failure for HTTP errors and keeps the response body.
if response="$(curl --fail-with-body --silent --show-error \
--connect-timeout 10 --max-time 30 \
--request POST \
--header "Authorization: Bearer $BEULOG_PUBLISHING_KEY" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: editorial-calendar-001' \
--data-raw '{"topic":"How to plan an editorial calendar","image":false,"autoPublish":false,"kind":"article","maxCredits":40}' \
'https://beulog.com/api/v1/generate')"; then
printf '%s\n' "$response"
else
printf '%s\n' "$response" >&2
exit 1
fiيتطلب Node.js بإصدار 20.20 أو أحدث، ويستخدم fetch المدمج دون مكتبات إضافية.
احفظ المثال باسم request.mjs ثم شغّله: node request.mjs
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/generate", {
method: "POST",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
"Content-Type": "application/json",
"Idempotency-Key": "editorial-calendar-001",
},
body: JSON.stringify({
"topic": "How to plan an editorial calendar",
"image": false,
"autoPublish": false,
"kind": "article",
"maxCredits": 40
}),
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}يتطلب Node.js بإصدار 20.20 أو أحدث. ثبّت أدوات TypeScript مرة واحدة: npm install -D typescript tsx @types/node
احفظ المثال باسم request.ts ثم شغّله: npx tsx request.ts
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/generate", {
method: "POST",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
"Content-Type": "application/json",
"Idempotency-Key": "editorial-calendar-001",
},
body: JSON.stringify({
"topic": "How to plan an editorial calendar",
"image": false,
"autoPublish": false,
"kind": "article",
"maxCredits": 40
}),
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload: unknown = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
export {};يتطلب Python بإصدار 3.10 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.py ثم شغّله: python3 request.py
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
# Read the key from your server environment, never browser code.
key = os.environ.get("BEULOG_PUBLISHING_KEY")
if not key:
sys.exit("Set BEULOG_PUBLISHING_KEY on your server")
headers = {
"Authorization": f"Bearer {key}",
"Accept": "application/json",
"Content-Type": "application/json",
"Idempotency-Key": "editorial-calendar-001",
}
request = Request(
"https://beulog.com/api/v1/generate",
headers=headers,
method="POST",
data="{\"topic\":\"How to plan an editorial calendar\",\"image\":false,\"autoPublish\":false,\"kind\":\"article\",\"maxCredits\":40}".encode("utf-8"),
)
try:
with urlopen(request, timeout=30) as response:
payload = json.loads(response.read().decode("utf-8"))
print(json.dumps(payload, indent=2, ensure_ascii=False))
except HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode('utf-8')}", file=sys.stderr)
sys.exit(1)
except (URLError, OSError, ValueError) as error:
print(f"Request failed: {error}", file=sys.stderr)
sys.exit(1)يتطلب PHP بإصدار 8.2 أو أحدث مع تفعيل إضافة cURL.
احفظ المثال باسم request.php ثم شغّله: php request.php
<?php
// Run on your server; the key must never be embedded in browser code.
try {
$key = getenv('BEULOG_PUBLISHING_KEY');
if (!$key) {
throw new RuntimeException('Set BEULOG_PUBLISHING_KEY on your server');
}
$curl = curl_init('https://beulog.com/api/v1/generate');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $key,
'Accept: application/json',
'Content-Type: application/json',
'Idempotency-Key: editorial-calendar-001',
],
CURLOPT_POSTFIELDS => '{"topic":"How to plan an editorial calendar","image":false,"autoPublish":false,"kind":"article","maxCredits":40}',
]);
$text = curl_exec($curl);
if ($text === false) {
throw new RuntimeException(curl_error($curl));
}
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $text");
}
$payload = json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
} catch (Throwable $error) {
fwrite(STDERR, $error->getMessage() . PHP_EOL);
exit(1);
}يتطلب Ruby بإصدار 3.1 أو أحدث، ويستخدم مكتبتي net/http وjson القياسيتين.
احفظ المثال باسم request.rb ثم شغّله: ruby request.rb
require 'net/http'
require 'uri'
require 'json'
begin
# Read the key from your server environment, never browser code.
key = ENV.fetch('BEULOG_PUBLISHING_KEY')
raise 'Set BEULOG_PUBLISHING_KEY on your server' if key.empty?
uri = URI('https://beulog.com/api/v1/generate')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{key}"
request['Accept'] = 'application/json'
request['Content-Type'] = 'application/json'
request['Idempotency-Key'] = 'editorial-calendar-001'
request.body = '{"topic":"How to plan an editorial calendar","image":false,"autoPublish":false,"kind":"article","maxCredits":40}'
response = Net::HTTP.start(
uri.host, uri.port, use_ssl: uri.scheme == 'https',
open_timeout: 10, read_timeout: 30, write_timeout: 30
) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
raise "HTTP #{response.code}: #{response.body}"
end
puts JSON.pretty_generate(JSON.parse(response.body))
rescue StandardError => error
warn "Request failed: #{error.message}"
exit 1
endيتطلب Go بإصدار 1.20 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.go ثم شغّله: go run request.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strings"
"time"
)
func run() error {
// Read the key from your server environment, never browser code.
key := os.Getenv("BEULOG_PUBLISHING_KEY")
if key == "" {
return fmt.Errorf("set BEULOG_PUBLISHING_KEY on your server")
}
request, err := http.NewRequest(
"POST", "https://beulog.com/api/v1/generate",
strings.NewReader("{\"topic\":\"How to plan an editorial calendar\",\"image\":false,\"autoPublish\":false,\"kind\":\"article\",\"maxCredits\":40}"),
)
if err != nil { return err }
request.Header.Set("Authorization", "Bearer " + key)
request.Header.Set("Accept", "application/json")
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Idempotency-Key", "editorial-calendar-001")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil { return err }
defer response.Body.Close()
text, err := io.ReadAll(response.Body)
if err != nil { return err }
if response.StatusCode < 200 || response.StatusCode >= 300 {
return fmt.Errorf("HTTP %d: %s", response.StatusCode, text)
}
var pretty bytes.Buffer
if err := json.Indent(&pretty, text, "", " "); err != nil { return err }
fmt.Println(pretty.String())
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "Request failed:", err)
os.Exit(1)
}
}يتطلب JDK بإصدار 17 أو أحدث، ويستخدم عميل HTTP المدمج دون مكتبات إضافية.
احفظ المثال باسم RequestExample.java ثم شغّله: java RequestExample.java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class RequestExample {
public static void main(String[] args) {
try {
// Read the key from your server environment, never browser code.
String key = System.getenv("BEULOG_PUBLISHING_KEY");
if (key == null || key.isBlank()) {
throw new IllegalStateException("Set BEULOG_PUBLISHING_KEY on your server");
}
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10)).build();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://beulog.com/api/v1/generate"))
.timeout(Duration.ofSeconds(30))
.header("Authorization", "Bearer " + key)
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Idempotency-Key", "editorial-calendar-001")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"topic\":\"How to plan an editorial calendar\",\"image\":false,\"autoPublish\":false,\"kind\":\"article\",\"maxCredits\":40}"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() < 200 || response.statusCode() >= 300) {
throw new IOException("HTTP " + response.statusCode() + ": " + response.body());
}
System.out.println(response.body());
} catch (Exception error) {
if (error instanceof InterruptedException) Thread.currentThread().interrupt();
System.err.println("Request failed: " + error.getMessage());
System.exit(1);
}
}
}حقول الاستجابة
| الحقل | النوع | ماذا يعني |
|---|---|---|
id | UUID | معرّف مهمة الإنشاء. استخدمه مع GET /jobs/{id}. |
status | "queued" | "running" | "completed" | "failed" | queued وrunning قيد الانتظار؛ completed وfailed نهائيتان. قد تنتهي مهمة بحث دون article_id. |
cost | integer (credits) | المبلغ المحجوز أثناء الانتظار؛ والخصم النهائي بعد التسوية الناجحة. قد يبقى في المهام الفاشلة مساويًا للحجز السابق رغم رد الرصيد. |
reserved_credits | integer | null | الرصيد المحجوز الأصلي. تستخدم استجابة الإنشاء cost بديلًا للمهام القديمة؛ وقد تُرجع المتابعة null للمهام القديمة. |
settled_at | ISO 8601 date-time | null | وقت تسوية الاستخدام الناجحة؛ null قبل التسوية، وربما للمهام القديمة أو الفاشلة. ليس وقت اكتمال المهمة. |
{
"id": "00000000-0000-4000-8000-000000000003",
"status": "queued",
"cost": 40,
"reserved_credits": 40,
"settled_at": null
}| الحالة | المعنى والخطوة التالية |
|---|---|
200 | مهمة جديدة أو موجودة لمنع التكرار؛ قد تكون running أو completed أو failed عند إعادة الطلب. |
400 | JSON أو حقول غير صالحة أو Idempotency-Key مفقودة أو طويلة. |
402 | الرصيد غير كافٍ للحجز الحالي. |
404 | مساحة العمل أو ملخص البحث غير موجود. |
409 | يتجاوز الحجز maxCredits أو تكون المساحة مؤرشفة. |
413 | يتجاوز محتوى الطلب 300000 بايت. |
401 | المفتاح مفقود أو غير صالح أو ملغى، أو حساب مالك مساحة العمل غير مؤكّد. |
403 | صلاحية articles:generate مفقودة أو يحتاج الحساب إلى مراجعة الفوترة. |
429 | تم بلوغ حد الطلبات. اقرأ Retry-After وانتظر قبل المحاولة. |
500 | خطأ غير متوقّع على الخادم. احفظ X-Request-Id للدعم. |
503 | خدمة مطلوبة غير متاحة مؤقتًا. حاول لاحقًا. |
تابع مهمة إنشاء
GET /api/v1/jobs/{id}
اقرأ تقدّم الإنشاء ومعرّف المقال الناتج وتسوية الرصيد.
الصلاحية المطلوبة: articles:generate
تابع بفاصل زمني عندما تكون status بقيمة queued أو running، وتوقّف عند completed أو failed. تصف stage العمل الجاري وهي نص معلوماتي قد يتوسع؛ لا تفترض نسبة إنجاز ثابتة. قد تتضمن مهمة البحث المكتملة article_id=null؛ يتوفر ملخصها في المساحة.
عند الاكتمال مع article_id اجلب /articles/{article_id}. تتطلب المسودة drafts=true وصلاحية drafts:read. يُرجع الفشل شرحًا في error ويرد الحجز. قد يبقى cost وreserved_credits مساويين للحجز السابق في المهام الفاشلة؛ لا تستنتج الخصم من هذين الحقلين وحدهما.
معاملات الطلب
| المعامل / الموضع | النوع | الإلزام / الافتراضي | المعنى والقيم المقبولة |
|---|---|---|---|
idمسار الرابط | UUID | مطلوب | UUID المهمة من POST /generate. يجب أن تنتمي إلى مساحة المفتاح. |
If-None-Matchترويسة | string | اختياري | قيمة ETag السابقة كما هي لطلب ناجح إلى العنوان نفسه وبالمفتاح نفسه. عند التطابق تُرجع 304 دون محتوى. |
أمثلة الطلب — اختر لغتك
اختر لغتك لعرض الطلب نفسه. احفظ مفتاح النشر في متغير البيئة BEULOG_PUBLISHING_KEY على الخادم.
يتطلب Bash وcURL بإصدار 7.76 أو أحدث. لا يحتاج إلى مكتبات إضافية.
احفظ المثال باسم request.sh ثم شغّله: bash request.sh
#!/usr/bin/env bash
set -euo pipefail
# Set BEULOG_PUBLISHING_KEY in your server environment before running.
: "${BEULOG_PUBLISHING_KEY:?Set your server-side publishing key}"
# cURL returns a failure for HTTP errors and keeps the response body.
if response="$(curl --fail-with-body --silent --show-error \
--connect-timeout 10 --max-time 30 \
--request GET \
--header "Authorization: Bearer $BEULOG_PUBLISHING_KEY" \
--header 'Accept: application/json' \
'https://beulog.com/api/v1/jobs/00000000-0000-4000-8000-000000000003')"; then
printf '%s\n' "$response"
else
printf '%s\n' "$response" >&2
exit 1
fiيتطلب Node.js بإصدار 20.20 أو أحدث، ويستخدم fetch المدمج دون مكتبات إضافية.
احفظ المثال باسم request.mjs ثم شغّله: node request.mjs
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/jobs/00000000-0000-4000-8000-000000000003", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}يتطلب Node.js بإصدار 20.20 أو أحدث. ثبّت أدوات TypeScript مرة واحدة: npm install -D typescript tsx @types/node
احفظ المثال باسم request.ts ثم شغّله: npx tsx request.ts
// Run on your server. Never put this key in browser code.
const key = process.env.BEULOG_PUBLISHING_KEY;
if (!key) throw new Error("Set BEULOG_PUBLISHING_KEY on your server");
try {
const response = await fetch("https://beulog.com/api/v1/jobs/00000000-0000-4000-8000-000000000003", {
method: "GET",
headers: {
Authorization: `Bearer ${key}`,
"Accept": "application/json",
},
signal: AbortSignal.timeout(30_000),
});
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text}`);
}
const payload: unknown = JSON.parse(text);
console.log(JSON.stringify(payload, null, 2));
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
process.exitCode = 1;
}
export {};يتطلب Python بإصدار 3.10 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.py ثم شغّله: python3 request.py
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
# Read the key from your server environment, never browser code.
key = os.environ.get("BEULOG_PUBLISHING_KEY")
if not key:
sys.exit("Set BEULOG_PUBLISHING_KEY on your server")
headers = {
"Authorization": f"Bearer {key}",
"Accept": "application/json",
}
request = Request(
"https://beulog.com/api/v1/jobs/00000000-0000-4000-8000-000000000003",
headers=headers,
method="GET",
)
try:
with urlopen(request, timeout=30) as response:
payload = json.loads(response.read().decode("utf-8"))
print(json.dumps(payload, indent=2, ensure_ascii=False))
except HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode('utf-8')}", file=sys.stderr)
sys.exit(1)
except (URLError, OSError, ValueError) as error:
print(f"Request failed: {error}", file=sys.stderr)
sys.exit(1)يتطلب PHP بإصدار 8.2 أو أحدث مع تفعيل إضافة cURL.
احفظ المثال باسم request.php ثم شغّله: php request.php
<?php
// Run on your server; the key must never be embedded in browser code.
try {
$key = getenv('BEULOG_PUBLISHING_KEY');
if (!$key) {
throw new RuntimeException('Set BEULOG_PUBLISHING_KEY on your server');
}
$curl = curl_init('https://beulog.com/api/v1/jobs/00000000-0000-4000-8000-000000000003');
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $key,
'Accept: application/json',
],
]);
$text = curl_exec($curl);
if ($text === false) {
throw new RuntimeException(curl_error($curl));
}
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status < 200 || $status >= 300) {
throw new RuntimeException("HTTP $status: $text");
}
$payload = json_decode($text, true, 512, JSON_THROW_ON_ERROR);
echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . PHP_EOL;
} catch (Throwable $error) {
fwrite(STDERR, $error->getMessage() . PHP_EOL);
exit(1);
}يتطلب Ruby بإصدار 3.1 أو أحدث، ويستخدم مكتبتي net/http وjson القياسيتين.
احفظ المثال باسم request.rb ثم شغّله: ruby request.rb
require 'net/http'
require 'uri'
require 'json'
begin
# Read the key from your server environment, never browser code.
key = ENV.fetch('BEULOG_PUBLISHING_KEY')
raise 'Set BEULOG_PUBLISHING_KEY on your server' if key.empty?
uri = URI('https://beulog.com/api/v1/jobs/00000000-0000-4000-8000-000000000003')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = "Bearer #{key}"
request['Accept'] = 'application/json'
response = Net::HTTP.start(
uri.host, uri.port, use_ssl: uri.scheme == 'https',
open_timeout: 10, read_timeout: 30, write_timeout: 30
) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
raise "HTTP #{response.code}: #{response.body}"
end
puts JSON.pretty_generate(JSON.parse(response.body))
rescue StandardError => error
warn "Request failed: #{error.message}"
exit 1
endيتطلب Go بإصدار 1.20 أو أحدث، ويستخدم المكتبة القياسية فقط.
احفظ المثال باسم request.go ثم شغّله: go run request.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
func run() error {
// Read the key from your server environment, never browser code.
key := os.Getenv("BEULOG_PUBLISHING_KEY")
if key == "" {
return fmt.Errorf("set BEULOG_PUBLISHING_KEY on your server")
}
request, err := http.NewRequest(
"GET", "https://beulog.com/api/v1/jobs/00000000-0000-4000-8000-000000000003",
nil,
)
if err != nil { return err }
request.Header.Set("Authorization", "Bearer " + key)
request.Header.Set("Accept", "application/json")
client := &http.Client{Timeout: 30 * time.Second}
response, err := client.Do(request)
if err != nil { return err }
defer response.Body.Close()
text, err := io.ReadAll(response.Body)
if err != nil { return err }
if response.StatusCode < 200 || response.StatusCode >= 300 {
return fmt.Errorf("HTTP %d: %s", response.StatusCode, text)
}
var pretty bytes.Buffer
if err := json.Indent(&pretty, text, "", " "); err != nil { return err }
fmt.Println(pretty.String())
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "Request failed:", err)
os.Exit(1)
}
}يتطلب JDK بإصدار 17 أو أحدث، ويستخدم عميل HTTP المدمج دون مكتبات إضافية.
احفظ المثال باسم RequestExample.java ثم شغّله: java RequestExample.java
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class RequestExample {
public static void main(String[] args) {
try {
// Read the key from your server environment, never browser code.
String key = System.getenv("BEULOG_PUBLISHING_KEY");
if (key == null || key.isBlank()) {
throw new IllegalStateException("Set BEULOG_PUBLISHING_KEY on your server");
}
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10)).build();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://beulog.com/api/v1/jobs/00000000-0000-4000-8000-000000000003"))
.timeout(Duration.ofSeconds(30))
.header("Authorization", "Bearer " + key)
.header("Accept", "application/json")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() < 200 || response.statusCode() >= 300) {
throw new IOException("HTTP " + response.statusCode() + ": " + response.body());
}
System.out.println(response.body());
} catch (Exception error) {
if (error instanceof InterruptedException) Thread.currentThread().interrupt();
System.err.println("Request failed: " + error.getMessage());
System.exit(1);
}
}
}حقول الاستجابة
| الحقل | النوع | ماذا يعني |
|---|---|---|
id | UUID | معرّف مهمة الإنشاء. استخدمه مع GET /jobs/{id}. |
status | "queued" | "running" | "completed" | "failed" | queued وrunning قيد الانتظار؛ completed وfailed نهائيتان. قد تنتهي مهمة بحث دون article_id. |
cost | integer (credits) | المبلغ المحجوز أثناء الانتظار؛ والخصم النهائي بعد التسوية الناجحة. قد يبقى في المهام الفاشلة مساويًا للحجز السابق رغم رد الرصيد. |
reserved_credits | integer | null | الرصيد المحجوز الأصلي. تستخدم استجابة الإنشاء cost بديلًا للمهام القديمة؛ وقد تُرجع المتابعة null للمهام القديمة. |
settled_at | ISO 8601 date-time | null | وقت تسوية الاستخدام الناجحة؛ null قبل التسوية، وربما للمهام القديمة أو الفاشلة. ليس وقت اكتمال المهمة. |
stage | string | مرحلة العمل، مثل queued أو researching أو writing أو reviewing أو image أو saving أو completed أو failed. تعامل مع المراحل الإضافية كقيم صالحة. |
error | string | null | شرح الفشل، أو null عندما لا يوجد خطأ محفوظ. |
article_id | UUID | null | معرّف المقال الناتج عند توفره. يكون null أثناء الانتظار أو للبحث أو إذا حُذف المقال المرتبط. |
{
"id": "00000000-0000-4000-8000-000000000003",
"status": "completed",
"stage": "completed",
"error": null,
"article_id": "00000000-0000-4000-8000-000000000002",
"cost": 18,
"reserved_credits": 40,
"settled_at": "2026-10-01T09:03:00.000Z"
}| الحالة | المعنى والخطوة التالية |
|---|---|
200 | حالة المهمة ومرجع النتيجة؛ تُرجع المهمة الفاشلة HTTP 200 مع status=failed. |
304 | تطابق قيمة If-None-Match استجابة GET. لا يوجد محتوى؛ استخدم الاستجابة المحفوظة. |
400 | معرّف المهمة ليس UUID صالحًا. |
404 | المهمة غير موجودة في مساحة عمل المفتاح. |
401 | المفتاح مفقود أو غير صالح أو ملغى، أو حساب مالك مساحة العمل غير مؤكّد. |
403 | لا يملك المفتاح الصلاحية المطلوبة. |
429 | تم بلوغ حد الطلبات. اقرأ Retry-After وانتظر قبل المحاولة. |
500 | خطأ غير متوقّع على الخادم. احفظ X-Request-Id للدعم. |
503 | خدمة مطلوبة غير متاحة مؤقتًا. حاول لاحقًا. |
اجلب المقالات واتبع جميع الصفحات
تحتوي القائمة الافتراضية على المقالات المنشورة في مساحة عمل المفتاح، بالأحدث أولًا حسب وقت الإنشاء والمعرّف. تعني القائمة الفارغة الناجحة عدم وجود مقالات منشورة مطابقة، ولا تعني فشل المفتاح. لا تستبدل خطأ الواجهة بصمت بقائمة فارغة.
| المعامل | القيمة المقبولة والسلوك |
|---|---|
limit | عدد صحيح من 1 إلى 100؛ الافتراضي 20. |
cursor | انسخ pagination.next_cursor كما هو وشفّره للرابط. الحد الأقصى 1000 محرف. استخدم مساحة العمل ومرشح المسودات نفسيهما. توقف عندما تصبح next_cursor مساوية لـ null. |
offset | موضع بدء بالطريقة القديمة، عدد صحيح من 0 إلى 100000؛ الافتراضي 0. يُفضّل استخدام المؤشر cursor. لا تجمعه مع offset غير صفري. |
drafts=true | يضمّن المسودات مع المقالات المنشورة، ويتطلب articles:read وdrafts:read معًا. حذفه يبقي السلوك الافتراضي الذي يقتصر على المنشور. |
اطّلع على استجابة قائمة المقالات كاملة والأمثلة بثماني لغات.
تحتوي الاستجابة على data وpagination. اقرأ عناصر data، ثم اتبع pagination.next_cursor حتى تصبح null. تشير has_more إلى وجود صفحة أخرى، وتخص next_offset طريقة offset القديمة فقط. لا تفك المؤشرات أو تعدّلها أو تنشئها بنفسك. أعد بدء القائمة من الصفحة الأولى إذا رُفض مؤشرها.
اطّلع على مرجع طلب المقال الواحد واستجابته.
استبدل المعرّف بمعرّف UUID لمقال من data. اقرأ data[0] في استجابة التفاصيل الناجحة؛ لا تعيد الواجهة كائن المقال مباشرة. لا يتاح المقال المسودة أو مقال مساحة عمل أخرى لمفتاح يقتصر على المنشور.
ماذا تتضمن استجابة المقال؟
المرجع الكامل لحقول استجابة المقال
يعيد مسارا المقالات هذا الكائن داخل مصفوفة data. تشير [] إلى مصفوفة، وتشير النقطة إلى خاصية متداخلة. قد تتضمن الحقول التي تقبل ذلك قيمة null. قد تضيف الواجهة حقولًا، لذا ينبغي أن يتقبل تكاملك الخصائص الإضافية.
| الحقل | النوع | المعنى والاستخدام |
|---|---|---|
id | UUID | معرّف ثابت للمقال. استخدمه مع workspace_id عند الاستيراد. |
workspace_id | UUID | مساحة العمل المالكة للمقال. |
schema_version | string: "1.1" | إصدار بنية تصدير المقال؛ وهو مستقل عن إصدار الواجهة 1.2. |
revision | string | بصمة غير شفافة لتصدير المقال كاملًا، بما في ذلك البيانات المبنية من إعدادات المساحة. قارنها لاكتشاف التغيّر؛ تختلف عن بصمة قائمة المزامنة. |
version | integer | رقم نسخة المقال المحفوظة. قد تغيّر إعدادات المساحة revision دون تغيير هذا الرقم. |
status | "published" | "draft" | تُرجع المقالات المنشورة افتراضيًا. تتطلب المسودات drafts=true وصلاحية drafts:read. |
title | string | عنوان المقال المحفوظ للتعريف به في القوائم. |
slug | string | اسم مسار المقال المحفوظ. لا يُقبل بدل UUID في /articles/{id}. |
language | "en" | "ar" | "es" | "fr" | "de" | لغة المقال المحفوظة؛ تمثّل seo.language اللغة المعتمدة للتصدير. |
translation_group_id | UUID | null | يربط نسخ المقال الكاملة بلغات مختلفة عند توفرها؛ null يعني عدم وجود مجموعة ترجمة. |
created_at | ISO 8601 date-time | وقت إنشاء المقال؛ يُستخدم لترتيب قائمة المقالات. |
updated_at | ISO 8601 date-time | وقت آخر تعديل محفوظ؛ يُستخدم لترتيب المزامنة. |
published_at | ISO 8601 date-time | null | وقت النشر؛ قد يكون null للمسودات. |
canonical_url | string | null | تجاوز محفوظ للرابط الأساسي. تعتمد seo.canonical عليه أو على موقع المساحة ومسار المقال. |
image_url | string | null | عنوان صورة الغلاف، أو null عند عدم وجود صورة. |
image_width | integer | null | عرض الغلاف المحفوظ بالبكسل، أو null عند عدم توفره. |
image_height | integer | null | ارتفاع الغلاف المحفوظ بالبكسل، أو null عند عدم توفره. |
html | string | جزء HTML دلالي للمقال يتضمن العنوان والخلاصات والفهرس والأقسام والأسئلة والمراجع والصورة الاختيارية. اعرضه على الخادم كصفحة أصلية. |
head_html | string | عنوان ووسوم وصف ورابط أساسي وJSON-LD جاهزة للعرض. استخدمها أو حوّل seo/json_ld عبر إطار موقعك؛ الجمع بينهما يكرر البيانات. |
reading_minutes | integer | مدة القراءة المقدّرة، دقيقة واحدة على الأقل، وفق 200 كلمة في الدقيقة. |
quality | string[] | ملاحظات أو مشاكل جودة المقال المحفوظة. المصفوفة الفارغة تعني عدم وجود ملاحظات محفوظة. |
generation_warnings | string[] | null | تحذيرات اختيارية محفوظة أثناء الإنشاء. راجعها قبل النشر. |
publishing_checks[] | { label: string, passed: boolean } | فحوص جاهزية للوصف والصور والرابط الأساسي والناشر والبنية والمراجع والروابط الداخلية؛ وهي إرشادات لا ضمان ترتيب. |
references[] | object[] | مصادر المقال. يتضمن كل مصدر id وtitle وurl، وقد يتضمن publisher وaccessedAt. تشير sourceIds في الأقسام إلى هذه المعرّفات. |
references_json | object[] | تتضمن الاستجابة الحالية أيضًا مصفوفة المصادر المحفوظة بهذا الاسم. يُفضّل استخدام references في التكامل. |
content.title | string | عنوان المقال القابل للتحرير؛ يُستخدم في HTML وBlogPosting.headline. |
content.slug | string | اسم مسار المقال القابل للتحرير داخل المحتوى. |
content.excerpt | string | مقدّمة قصيرة تُعرض أسفل العنوان؛ بديل metaDescription عند فراغها. |
content.category | string | التصنيف التحريري المعروض فوق العنوان وفي articleSection بالبيانات المنظّمة. |
content.metaTitle | string | عنوان البحث القابل للتحرير. يُستخدم content.title بديلًا عند الفراغ في seo.title. |
content.metaDescription | string | وصف البحث القابل للتحرير. يُستخدم content.excerpt بديلًا عند الفراغ في seo.description. |
content.keywords | string[] | كلمات موضوع المقال؛ تُجمع كنص مفصول بفواصل في BlogPosting. |
content.takeaways | string[] | الخلاصات الأساسية للقارئ؛ تُعرض كقائمة قرب البداية. |
content.sections[] | object[] | أقسام مرتبة، يتضمن كل منها heading وsummary وparagraphs وbullets وsourceIds. |
content.sections[].subsections[] | object[] (optional) | عناوين فرعية ومصفوفات فقرات. قد لا يوجد الحقل في المقالات القديمة. |
content.sections[].steps | string[] (optional) | خطوات عملية مرتبة تُعرض كقائمة مرقّمة. |
content.sections[].table | object | null (optional) | يتضمن caption وcolumns كمصفوفة نصوص وrows كمصفوفة صفوف نصية؛ null يعني عدم وجود جدول. |
content.sections[].callout | object | null (optional) | عنوان ونص مبرزان؛ null يعني عدم وجود ملاحظة بارزة. |
content.faqs[] | { question: string, answer: string }[] | أسئلة القرّاء وإجاباتها، وتُستخدم أيضًا لبناء بيانات FAQPage المنظّمة. |
content.imagePrompt | string | تعليمات إنشاء صورة الغلاف المحفوظة عند طلبها. |
content.imageAlt | string | وصف الغلاف للنص البديل في HTML والمشاركة وتعليق الصورة في البيانات المنظّمة. |
content.imageCaption | string (optional) | تعليق مرئي أسفل الغلاف؛ قد لا يوجد في المقالات القديمة. |
content.searchIntent | string (optional) | سؤال القارئ أو هدف البحث المقصود؛ سياق تحريري وليس وسم وصف HTML. |
content.reviewNotes | string[] (optional) | ملاحظات المراجعة التحريرية المحفوظة مع المحتوى. |
content.recommendedPublish | boolean | توصية الإنشاء فقط؛ يحدّد status ما إذا كان المقال منشورًا فعلًا. |
seo.title | string | عنوان الصفحة النهائي من metaTitle أو content.title. |
seo.description | string | وصف البحث النهائي من metaDescription أو content.excerpt. |
seo.robots | string | تستخدم المنشورات index, follow, max-image-preview:large؛ والمسودات noindex, nofollow. |
seo.canonical | string | null | عنوان الرابط الأساسي الكامل؛ null يعني عدم تهيئة رابط أساسي صالح. |
seo.language | "en" | "ar" | "es" | "fr" | "de" | اللغة المعتمدة لـ HTML والبيانات المنظّمة. |
seo.openGraph | object | بيانات مشاركة المقال: type وtitle وdescription وurl وsiteName وlocale وimages وpublishedTime وmodifiedTime. قد تكون العناوين والأوقات null. |
seo.openGraph.images[] | { url, alt, width, height }[] | صور الغلاف؛ [] عند عدم وجود صورة صالحة. قد يكون width وheight null. |
seo.twitter | object | card وtitle وdescription وimage وimageAlt. تكون card بقيمة summary_large_image مع الغلاف وإلا summary؛ وقد تكون image null. |
json_ld | object | @context و@graph من Schema.org تتضمن BlogPosting وBreadcrumbList الاختيارية وFAQPage. اعرضها بأمان مرة واحدة وبما يتطابق مع المحتوى المرئي. |
publishing_checks[].label | string | اسم قابل للقراءة لفحص الجاهزية. |
publishing_checks[].passed | boolean | ما إذا كان شرط الجاهزية الفردي متحققًا. |
references[].id | string | معرّف المصدر المستخدم في sourceIds والاستشهادات المعروضة. |
references[].title | string | عنوان صفحة المصدر المعروض في قائمة المراجع. |
references[].url | string | عنوان المصدر؛ يعرض النظام روابط HTTPS الآمنة فقط. |
references[].publisher | string (optional) | اسم ناشر المصدر عند حفظه. |
references[].accessedAt | string (optional) | وقت الاطلاع على المصدر المحفوظ عند توفره. |
content.sections[].heading | string | عنوان القسم؛ يُعرض كـ h2 وفي فهرس المحتوى. |
content.sections[].summary | string | نص اختياري داخل الحقل summary المطلوب؛ لا تُعرض فقرة ملخص عند فراغه. |
content.sections[].paragraphs | string[] | الفقرات الرئيسية بترتيب عرضها. |
content.sections[].bullets | string[] | عناصر قائمة غير مرقّمة؛ لا تُعرض القائمة عند فراغ المصفوفة. |
content.sections[].sourceIds | string[] | معرّفات مصادر references المستشهد بها في نهاية القسم. |
content.sections[].subsections[].heading | string | عنوان القسم الفرعي المعروض كـ h3. |
content.sections[].subsections[].paragraphs | string[] | الفقرات المعروضة أسفل العنوان الفرعي. |
content.sections[].table.caption | string | عنوان توضيحي للجدول يدعم إمكانية الوصول. |
content.sections[].table.columns | string[] | عناوين الأعمدة بترتيبها. |
content.sections[].table.rows | string[][] | صفوف الجدول؛ تحتوي كل مصفوفة داخلية قيم الخلايا بترتيب الأعمدة. |
content.sections[].callout.title | string | عنوان الملاحظة التحريرية البارزة. |
content.sections[].callout.text | string | نص الملاحظة البارزة. |
content.faqs[].question | string | سؤال يُعرض في عنوان تفاصيل قابل للتوسيع. |
content.faqs[].answer | string | الإجابة المعروضة أسفل السؤال وفي بيانات FAQPage المنظّمة. |
seo.openGraph.type | string: "article" | نوع كائن المشاركة الاجتماعية للمقال. |
seo.openGraph.title | string | عنوان المشاركة النهائي المطابق لـ seo.title. |
seo.openGraph.description | string | وصف المشاركة النهائي المطابق لـ seo.description. |
seo.openGraph.url | string | null | عنوان المشاركة الأساسي المطابق لـ seo.canonical. |
seo.openGraph.siteName | string | publisherName في المساحة، أو اسمها عند عدم توفره. |
seo.openGraph.locale | "en_US" | "ar_SA" | "es_ES" | "fr_FR" | "de_DE" | لغة المشاركة المحلية المستمدة من لغة المقال المعتمدة. |
seo.openGraph.images[].url | string | عنوان HTTPS آمن لصورة الغلاف. |
seo.openGraph.images[].alt | string | وصف الغلاف من content.imageAlt. |
seo.openGraph.images[].width | integer | null | عرض الغلاف بالبكسل عند حفظه. |
seo.openGraph.images[].height | integer | null | ارتفاع الغلاف بالبكسل عند حفظه. |
seo.openGraph.publishedTime | ISO 8601 date-time | null | وقت نشر المقال بصيغته المعتمدة. |
seo.openGraph.modifiedTime | ISO 8601 date-time | null | وقت تعديل المقال بصيغته المعتمدة. |
seo.twitter.card | "summary" | "summary_large_image" | تستخدم summary_large_image عند وجود عنوان غلاف آمن؛ وإلا summary. |
seo.twitter.title | string | عنوان بطاقة المشاركة النهائي. |
seo.twitter.description | string | وصف بطاقة المشاركة النهائي. |
seo.twitter.image | string | null | عنوان صورة غلاف آمن، أو null دون صورة. |
seo.twitter.imageAlt | string | وصف الغلاف من content.imageAlt. |
json_ld.@context | string: "https://schema.org" | المفردات المستخدمة في رسم البيانات المنظّمة. |
json_ld.@graph | object[] | BlogPosting مع BreadcrumbList عند توفر روابط الموقع والمقال الأساسية، وFAQPage عند وجود أسئلة. تعتمد الخصائص الاختيارية على قيم المقال والمساحة المتوفرة. |
| الحقل | كيفية استخدامه |
|---|---|
id, slug, title, status | استخدم id كهوية مصدر ثابتة، وslug لربط عنوان الصفحة، وstatus لضمان عرض المنشور فقط للعامة. احفظ معرّف مساحة العمل المتصلة مع المقال. |
revision | رمز تغيّر غير قابل للتفسير للتصدير. قارنه بإصدار التصدير السابق لتجاوز المحتوى الذي لم يتغير. يشمل المحتوى المصدّر وإعدادات النشر؛ رقم نسخة المقال وحده غير كافٍ. |
html | جزء HTML دلالي لجسم المقال يتضمن عنصر article وعنوان H1 والأقسام والروابط والنص البديل للصورة والمراجع واللغة واتجاه القراءة. ليس مستند HTML كاملًا. |
head_html | عنوان ووصف وتوجيهات robots ورابط canonical عند توفره وبيانات المشاركة وJSON-LD، جاهزة لرأس مستند يُعرض من الخادم. استخدمه أو استخدم تحويل البيانات عبر إطار العمل. |
seo | حقول منظّمة للعنوان والوصف وcanonical وrobots واللغة وopenGraph وtwitter لإطار العمل لديك. قد يكون canonical مساويًا لـ null إذا لم يُضبط العنوان النهائي. |
json_ld | بيانات منظّمة تُنشأ من المقال وإعدادات مساحة العمل. حافظ على تطابق المؤلف والناشر واللغة والتواريخ والصور والمراجع والرابط مع الصفحة المرئية. |
content | محتوى منظّم قابل للتحرير يشمل imageAlt وimageCaption والأقسام والنقاط الأساسية والأسئلة الشائعة. استخدمه لبناء تخطيط خاص بدل html الجاهز. |
image_url, image_width, image_height | رابط الغلاف وأبعاده عند توفرها. حافظ على الأبعاد الصحيحة والنص البديل عند استبدال مكوّن الصورة، ولا تخترع قيمًا مفقودة. |
publishing_checks, reading_minutes, schema_version | فحوص التصدير ووقت القراءة التقديري وإصدار صيغة المحتوى. تساعد الفحوص في المراجعة، ولا تمنح اعتمادًا لموقعك أو تضمن ترتيب البحث. |
استورد باستخدام عميل TypeScript
نزّل العميل وضعه في وحدة تعمل على الخادم فقط. يستخدم fetch وAbortSignal.timeout الأصليين؛ استخدم بيئة خادم حديثة تدعمهما. يرفض العميل العمل داخل المتصفح. مرّر https://beulog.com إلى المُنشئ، فهو يضيف /api/v1 بنفسه.
- أنشئ BeulogClient باستخدام https://beulog.com ومفتاح بيئة الخادم. استدعِ connection() وتحقق من مطابقة workspace.id لمساحة العمل المتوقعة.
- استخدم حلقة for await مع client.articles()؛ يتبع العميل مؤشرات الصفحات تلقائيًا. احفظ كل مقال بمعرّفه الثابت ومعرّف مساحة العمل المتصلة.
- نفّذ عملية إدراج أو تحديث في قاعدة بياناتك أو نظام إدارة المحتوى: حدّث معرّف المصدر الموجود أو أدرجه مرة واحدة. نفّذ الحفظ على الخادم وأبلغ عن الأخطاء قبل تقديم نقطة المزامنة.
يتبع client.articles() صفحات المؤشر ويعيد المقالات المنشورة تباعًا. يعيد client.article(id) العنصر data[0]. ويوفر العميل أيضًا connection() وpricing() وgenerate() وjob(). لقراءة المسودات أو سجل المزامنة أو استخدام طلبات ETag الشرطية، استخدم مسارات HTTP الموثّقة مباشرة؛ لا يوفّر العميل هذه الخيارات.
اجعل تكرار الاستيراد آمنًا: استخدم مفتاحًا فريدًا مثل (workspace_id, article_id)، وحدّث السجل الموجود عندما يتغير إصدار تصديره، ثم حدّث الصفحة المعروضة وخريطة الموقع بعد نجاح التحديث. حدّد كذلك كيفية الحفاظ على التعديلات التي تُجرى مباشرة في موقعك.
حافظ على تحديث موقعك
للتحديثات الدورية، يقدم /sync سجلًا صغيرًا لاكتشاف التغييرات. يعيد المعرّفات والعناوين وإصدارات السجل، دون HTML المقالات. اجلب المقال كاملًا عندما يكون إصدار السجل جديدًا أو متغيرًا فقط. شغّل ذلك في مهمة مجدولة على الخادم، وليس مع كل زيارة.
| المعامل | القيمة المقبولة والسلوك |
|---|---|
limit | عدد صحيح من 1 إلى 100؛ الافتراضي 50. |
since | نقطة المزامنة المحفوظة سابقًا، بنص التاريخ والوقت ISO نفسه الذي أعادته الواجهة. احذفه في أول فحص كامل. |
settings_revision | احفظه مع checkpoint وأرسله مع since. إذا تغيرت إعدادات النشر أو غابت القيمة أو اختلفت، تبدأ الواجهة فحصًا كاملًا. |
cursor | قيمة pagination.next_cursor كما وردت في هذا الفحص، مع تشفيرها للرابط؛ حدها 2000 محرف. تحفظ الحد الزمني للفحص. تعني استجابة 400 ضرورة إعادة بدء الفحص. |
- ابدأ دون since/settings_revision، أو حمّل القيمتين من آخر فحص اكتمل بالكامل. تحقّق من مطابقة workspace_id لمساحة العمل المتوقعة.
- لكل عنصر، قارن إصدار السجل بإصدار السجل المحفوظ للمقال. اجلب العناصر المتغيرة من GET /articles/{id}، ثم أدرج التصدير الكامل أو حدّثه في مخزنك المحلي.
- احفظ المقال المحلي وإصدار السجل الذي عالجته معًا، وبعد نجاح الاستيراد فقط. احفظ إصدار التصدير وإصدار السجل في حقلين منفصلين؛ فهما رمزان مختلفان ولا تصح مقارنتهما ببعضهما.
- واصل باستخدام pagination.next_cursor حتى تصبح null. احتفظ بنقطة المزامنة السابقة إذا فشلت صفحة أو عملية استيراد. يجب أن يكون تكرار معالجة المقالات السابقة آمنًا.
- بعد نجاح جميع الصفحات وعمليات الاستيراد، احفظ checkpoint وsettings_revision اللذين أعادتهما الواجهة كزوج واحد. إذا كنت تستخدم طابورًا دائمًا، فلا تتقدم إلا بعد حفظ عمل جميع الصفحات فيه مع إمكانية إعادة المحاولة. لا تستخدم الوقت الحالي لجهازك كنقطة مزامنة تالية.
افتح معاملات المزامنة الكاملة واستجابة JSON والأمثلة بثماني لغات.
يتداخل السجل عمدًا مع نقطة المزامنة السابقة بخمس دقائق لتقليل احتمال فقد التحديثات قرب اعتماد عمليات قاعدة البيانات. ظهور المعرّفات مجددًا أمر متوقع؛ امنع التكرار اعتمادًا على معرّف المصدر وإصدار السجل. يبطل تغيير الإعدادات المؤشر الجاري؛ أعد البدء من آخر زوج محفوظ للنقطة والإعدادات، واسمح بالفحص الكامل الناتج، وحدّث السجلات بأمان.
اعرض المقال وبيانات الصفحة
امنح كل مقال عنوانًا دائمًا وعامًا على موقعك. اعرض المقال ضمن استجابة الخادم أو عند بناء الموقع، بحيث يتوفر النص والروابط والبيانات دون طلب مصادق عليه من المتصفح. توصي Google بالعرض من الخادم أو العرض المسبق لأنه يفيد الزوار وبرامج الزحف، وبعضها لا ينفّذ JavaScript. إرشادات Google لتهيئة مواقع JavaScript للبحث.
اختر طريقة واحدة لبيانات الصفحة
- قالب خادم تقليدي: أدرج head_html في رأس المستند وhtml في جسمه. أبقِ ترويستي charset وviewport الخاصتين بالقالب. لا تحوّل الأجزاء الجاهزة إلى نص ظاهر، ولا تضع head_html داخل جسم المقال.
- بيانات إطار العمل: حوّل seo إلى واجهة بيانات الصفحة في إطار العمل واعرض json_ld مرة واحدة. اعرض html في جسم الصفحة. لا تدرج head_html أيضًا، لأنه يحتوي أصلًا على العنوان والترويسات وcanonical وJSON-LD.
في Next.js، حوّل seo.title وseo.description وseo.robots وseo.canonical عبر generateMetadata في مسار الخادم. حوّل seo.openGraph وseo.twitter إلى بيانات المشاركة، بما فيها أبعاد الصورة ونصها البديل عند توفرها. استخدم إصدار المقال نفسه للصفحة وبياناتها.
اعرض article.html في قالب خادم أو مكوّن Server Component. سلسِل article.json_ld مرة واحدة داخل script من النوع application/ld+json؛ استبدل علامة أصغر من بالصيغة \u003c قبل إدراج JSON في HTML. يتضمن الجزء الجاهز عنصر article وعنوان H1. اقبل الأجزاء من تكاملك المصادق عليه فقط وطبّق سياسة موقعك للثقة بالمحتوى.
اضبط لغة المستند من seo.language، واستخدم الاتجاه من اليمين إلى اليسار للعربية. حافظ على سمتي lang وdir داخل المقال. إذا بنيت العرض من content، فأعد إنشاء عناوين ميسّرة وروابط فعلية ونصوص بديلة وصفية للصور وجداول ومراجع. أضف تنقّل موقعك وخطوة تالية مفيدة حول المقال دون عنوان H1 ثانٍ للمقال نفسه.
هيّئ صفحات موقعك للاكتشاف
- طابق canonical مع الصفحة الفعلية. يُنشئ الموقع الإلكتروني مع نمط عنوان المقال رابط canonical الافتراضي، وتتجاوزه قيمة رابط المقال المنشور داخل المقال. تحقّق من أنه عنوان HTTPS النهائي للمقال على نطاقك، وليس رابط الواجهة أو الإطار المضمّن. صحّح canonical المفقود أو الخاطئ قبل الإطلاق، وتجنّب تعارضه مع قالبك أو إضافة SEO.
- استخدم بيانات دقيقة للصفحة والمشاركة. راجع عنوان SEO ووصف SEO في محرر المقال. احتفظ بعنوان واحد ووصف مفيد وبيانات صورة متّسقة في Open Graph وTwitter. قد تختار محركات البحث عنوانًا أو مقتطفًا مختلفًا؛ البيانات وصف للصفحة وليست وعدًا بترتيبها.
- اجعل الصور مفيدة وسريعة. استخدم imageAlt لوصف الصورة المرئية، وحافظ على العرض والارتفاع المعروفين. وفّر صورًا مضغوطة ومتجاوبة عبر نظام الصور لديك عند الحاجة. حمّل غلاف المقال الظاهر بسرعة، وأجّل تحميل الصور البعيدة أسفل الصفحة. يجب أن يحافظ التخطيط المخصّص على المعنى والنص البديل الميسّر.
- اجعل البيانات المنظّمة صادقة. استخدم المؤلف الحقيقي أو الجهة المنسوب إليها المحتوى، وملفًا متاحًا للمؤلف إن توفر. اضبط علامتك وموقعك بوصفهما الناشر؛ Beulog مزوّد البرنامج، وليس تلقائيًا ناشر مقالات موقعك. طابق اللغة ورابط المقال والتواريخ والصور مع ما يراه القارئ. حافظ على الاستشهادات المفيدة بالمصادر. لا تضف تقييمات أو مؤلفين أو ادعاءات مختلقة، ولا تتوقع أن تؤدي الشيفرة وحدها إلى نتائج بحث محسّنة.
- اجعل اكتشاف المقالات سهلًا. اربط المقالات بفهرس مدونة أصلي وصفحات ذات صلة باستخدام روابط عادية بنص واضح. ضمّن في خريطة الموقع عناوين المقالات المنشورة الحالية والأساسية فقط. إذا نشرت ترجمات فعلية، فاستخدم عناوين منفصلة للغات وhreflang متبادلًا؛ ولا تُشر إلى ترجمة غير موجودة.
- أبقِ الصفحات العامة متاحة. ينبغي أن تعيد الصفحات المنشورة المخصصة للبحث محتوى مفيدًا مع HTTP 200، دون تسجيل دخول أو noindex غير مقصود. راجع robots.txt وقواعد الاستضافة وشبكة التوزيع. أتح صفحات المقالات لبرامج الزحف دون كشف مفتاح الواجهة السري. احمِ معاينات المسودات بصلاحيات وصول خاصة وnoindex.
تعتمد AI Overviews وAI Mode في Google على أسس SEO نفسها؛ ولا تشترط Google مخطط AI منفصلًا أو ملفًا خاصًا للذكاء الاصطناعي. يجب أن تكون الصفحة المؤهلة مفهرسة وقابلة للعرض بمقتطف بحث. يساعد المحتوى الأصلي المفيد والصفحات الأصلية المتاحة على الاكتشاف، لكن استخدام الواجهة أو بيانات الصفحة لا يضمن ترتيبًا أو استشهادًا من الذكاء الاصطناعي. إرشادات Google لميزات الذكاء الاصطناعي.
اتبع قائمة المراجعة الكاملة للنشر وGoogle وبحث الذكاء الاصطناعي. تغطي صلاحيات الزحف لمحركات البحث ومزوّدي الذكاء الاصطناعي، وفحوص Search Console وتجربة الصفحة ومراجعة المحتوى.
Google: عناوين canonical · Google: البيانات المنظّمة للمقالات
تعامل مع إلغاء النشر والمقالات المفقودة
يلغي إلغاء نشر المقال أو حذفه داخل Beulog ظهوره في الطلبات الجديدة التي تقتصر على المنشور. لكنه لا يحذف نسخة سبق استيرادها إلى موقعك. حدّد سرعة انعكاس الإزالة المطلوبة في موقعك ونفّذ هذه السياسة بوضوح.
- للتحقق المباشر من مقال معروف، اطلب GET /articles/{id} بمفتاح يقتصر على المنشور. تعني 404 أنه غير متاح عبر مساحة العمل والمفتاح هذين؛ أخفِ نسخته العامة وفق سياستك. لا تثبت 401 أو403 أو429 أو المهلة أو أخطاء 5xx أنه حُذف.
- للمطابقة الدورية، أكمل فحصًا جديدًا لجميع المقالات المنشورة وقارن المعرّفات بالمقالات المستوردة من مساحة العمل المتحقق منها نفسها. لا تتصرف بناءً على الغياب إلا بعد نجاح جميع الصفحات. لا تزل محتوى جماعيًا بعد فحص ناقص أو خطأ اتصال. إذا كانت الإزالة ذات أثر مهم، فتحقّق من المعرّفات المفقودة منفردة قبل تغيير حالتها العامة.
- للصفحة العامة المفقودة فعلًا، أعد حالة 404 أو410 حقيقية وأزلها من خريطة الموقع والروابط الداخلية. استخدم إعادة توجيه دائمة فقط عند وجود بديل مناسب فعلًا؛ ولا توجّه كل مقال محذوف إلى الصفحة الرئيسية.
- امسح أو حدّث مخازن الصفحات وشبكة التوزيع والبناء لديك بعد التعديلات والإزالة. حدّد سياسة لتغيير slug تتضمن إعادة توجيه دائمة من العنوان القديم عندما ينتقل المقال نفسه. تعامل مع فشل الشبكة وفق سياسة الانقطاع، ولا تعرضه كمقال فارغ ناجح.
في Next.js، استخدم notFound() للمورد الذي تأكد فقده، وتحقق من حالة HTTP النهائية في الإنتاج. أعد خطأ خدمة مؤقتًا مناسبًا عند انقطاع المصدر. تجنّب إرسال محتوى الصفحة قبل التحقق من المورد إذا كان ذلك سيحوّل الصفحة المفقودة إلى استجابة متدفقة بحالة 200.
الأخطاء وإعادة المحاولة ومعرّفات الطلبات
| الترويسة | القيمة / النوع | المعنى |
|---|---|---|
Content-Type | application/json | تستخدم استجابات النجاح 200 والأخطاء JSON. لا تتضمن استجابة 304 محتوى. |
X-API-Version | string: "1.2" | إصدار عقد الاستجابة. يبقى المسار /api/v1. |
X-Request-Id | UUID | معرّف فريد للطلب؛ أرسله للدعم عند الإبلاغ عن طلب فاشل. |
ETag | quoted string | تُرجعها طلبات GET الناجحة. أرسل القيمة كما هي في If-None-Match لتحصل على 304 إذا لم تتغير الاستجابة كاملة. |
Cache-Control | string: "no-store" | لا تعتمد على ذاكرات HTTP المشتركة لبيانات مساحة العمل. يمكن حفظ نسخة موثّقة داخل تكاملك عند الحاجة. |
Vary | string: "Authorization" | تعتمد الاستجابات على مفتاح مساحة العمل. |
Retry-After | string: "60" (429 only) | انتظر 60 ثانية على الأقل قبل إعادة طلب تجاوز الحد. تستمر نافذة حد الإنشاء للحساب ساعة وقد تتطلب انتظارًا أطول. |
| الحقل | النوع | المعنى |
|---|---|---|
error | string | شرح إنجليزي يمكن قراءته. لا تعتمد على صياغته لتحديد سلوك التطبيق. |
code | string | فئة الخطأ: invalid_request أو unauthorized أو forbidden أو not_found أو insufficient_credits أو conflict أو rate_limited أو unavailable أو internal_error. يستخدم الخطأ 413 حاليًا internal_error. |
{
"error": "This key needs the articles:read permission.",
"code": "forbidden"
}تستخدم أخطاء الواجهة جسم JSON يتضمن error لشرح المشكلة وcode لتصنيف ثابت تقرؤه البرامج. تتضمن الاستجابات X-Request-Id لتشخيص المشكلات؛ سجّل الحالة والرمز والمسار ومعرّف الطلب على الخادم دون تسجيل المفتاح. احتفظ بمعرّف الطلب عند التواصل مع الدعم. تحدّد استجابات v1 الإصدار أيضًا عبر X-API-Version.
| الحالة / الرمز | الإجراء المناسب |
|---|---|
400 invalid_request | راجع معرّفات UUID وحدود الاستعلام وJSON وIdempotency-Key. أعد بدء فحص المؤشر المرفوض؛ ولا تكرر الطلب غير الصالح نفسه. |
401 unauthorized | راجع مفتاح Bearer ومساحة العمل والتحقق من الحساب واحتمال إلغاء المفتاح. لا تكشف المفتاح أثناء التشخيص. |
402 insufficient_credits | رصيد الإنشاء غير كافٍ. راجع الرصيد قبل المحاولة مجددًا؛ قراءة المقالات المنشورة لا تبدأ مهمة إنشاء. |
403 forbidden | راجع الصلاحية المطلوبة وقيود الحساب. تتطلب قراءة المسودات drafts:read مع articles:read، ويتطلب الإنشاء articles:generate. |
404 not_found | راجع المسار ومعرّف UUID. للمقال، تحقّق من مساحة العمل واستمرار النشر. عالج غياب المقال المؤكد على موقعك. |
409 conflict | في الإنشاء، قد يتجاوز الحجز الحالي maxCredits. أعد قراءة /pricing واعتمد حد إنفاق جديدًا بقرار واضح بدل رفعه تلقائيًا. |
429 rate_limited | التزم بـ Retry-After وخفّض المعدل واستخدم عددًا محدودًا من المحاولات. الحدود 120 طلب واجهة في الدقيقة لكل مفتاح و20 طلب إنشاء في الساعة لكل حساب. |
500 / 502 / 503 / 504 | تعامل مع أعطال الخدمة والشبكة كمؤقتة. أعد المحاولة بتأخير وحد أقصى، واحتفظ بنقطة المزامنة السابقة الآمنة، وأرسل تنبيهًا إذا استمر الفشل. لا تفسّرها كإلغاء نشر. |
يجري العميل الجاهز حتى ثلاث محاولات HTTP عند 429 و502 و503 و504، باستخدام Retry-After الرقمي أو تأخير تصاعدي قصير بحد أقصى 60 ثانية. ويرمي BeulogError مع status وcode وrequestId بعد الاستجابة غير الناجحة. تحتاج أخطاء الشبكة والمهل إلى معالجة إعادة محاولة محدودة لديك. يجب أن تعيد محاولة الإنشاء باستخدام Idempotency-Key الأصلي نفسه.
التخزين المؤقت والطلبات الشرطية
تستخدم الاستجابات المصادق عليها Cache-Control: no-store وتتغير بحسب Authorization. اجعل مخزن المحتوى المحلي المقصود خاصًا بالتكامل وافصله بحسب مساحة العمل. توفر استجابات GET قيمة ETag؛ ويمكن لعميل HTTP مباشر إرسالها كما هي في If-None-Match. عند 304، أعد استخدام الاستجابة المحفوظة ولا تحاول قراءة جسم JSON. لا ينفّذ عميل TypeScript المتاح هذا المسار الشرطي.
اختياري: أنشئ مقالًا مع ضبط الإنفاق
لا تتطلب قراءة المقالات وعرضها صلاحية الإنشاء. إذا أردت سير عمل على الخادم ينشئ المقالات أيضًا، فأنشئ مفتاحًا منفصلًا مع تفعيل إنشاء مقالات جديدة. لا تعطِه للزوار؛ فهو يستطيع حجز رصيد حسابك وإنفاقه.
| الحقل | القيمة المقبولة والسلوك |
|---|---|
topic | نص بحد أقصى 1500 محرف؛ الافتراضي نص فارغ. حدّد موضوعًا واضحًا للمهمة المقصودة. |
image | قيمة منطقية؛ الافتراضي true. استخدم false لطلب مقال دون صورة مولّدة. |
autoPublish | قيمة منطقية؛ الافتراضي false. أبقِها false للمراجعة التحريرية قبل إتاحة المقال للتكاملات العامة. |
kind | article أوresearch؛ الافتراضي article. تنشئ دالة generate() في العميل مهام مقالات؛ استخدم HTTP مباشرة لمهام البحث. |
maxCredits | عدد صحيح اختياري من 1 إلى 1000000. إذا تجاوز الحجز هذا السقف، تعاد 409 دون حجز رصيد. استخدم /pricing الحالي وحد الإنفاق الذي اعتمدته. |
researchId | معرّف UUID اختياري لملخص بحث موجود في مساحة العمل نفسها. استخدم HTTP مباشرة؛ لا يوفّر العميل هذا الحقل. |
أرسل ترويسة Idempotency-Key بطول من 1 إلى 128 محرفًا. احفظ قيمة فريدة لكل مهمة مقصودة قبل إرسالها، وأعد استخدامها عند المحاولة بالمفتاح البرمجي نفسه. يعيد المفتاح والقيمة نفسيهما المهمة الموجودة بدل حجز الرصيد مجددًا، ولا يطبّقان مدخلات معدّلة عليها. تحتاج المهمة الجديدة المقصودة إلى قيمة جديدة.
١. تحقّق من الأسعار · ٢. أرسل مهمة إنشاء · ٣. تحقّق من استجابة المهمة — يتضمن كل طلب أمثلة بثماني لغات وشرحًا مفصّلًا لحقول الاستجابة.
- اقرأ /pricing قبل الإرسال. قيم article وarticle_with_image وresearch حدود حجز قصوى وليست تأكيدًا للتكلفة النهائية.
- احفظ معرّف المهمة من POST /generate. افحص GET /jobs/{id} بمفتاح الإنشاء على فترات مثل كل 10 إلى 30 ثانية، مع مهلة إجمالية وتأخير عند الفشل؛ ولا تفحص في حلقة متواصلة بلا انتظار.
- استمر عندما تكون status هي queued أوrunning. توقف عند completed أوfailed. عند الفشل، سجّل الخطأ ومعرّف الطلب، ولا ترسل تلقائيًا مهمة جديدة قابلة للإنفاق. عند الاكتمال، يحدّد article_id نتيجة مهمة المقال.
- عند autoPublish:false، راجع المسودة داخل Beulog وانشرها عندما تصبح جاهزة. لا يستطيع المفتاح المعتاد المقتصر على المنشور جلبها قبل ذلك. تتطلب المعاينة الخاصة articles:read مع drafts:read والمسار المباشر بمعامل ?drafts=true.
- يمثل reserved_credits الرصيد المحجوز؛ وتمثل cost الحجز أثناء الانتظار والتكلفة النهائية بعد النجاح؛ وتسجّل settled_at التسوية. يُعاد الرصيد المحجوز غير المستخدم بعد النجاح، وتُرد تكلفة المهام الفاشلة كاملة. قد تحتفظ المهام الفاشلة بقيمة الحجز السابقة في cost وreserved_credits، فلا يثبت هذان الحقلان وحدهما حدوث خصم.
راجع التكامل قبل إطلاقه
- يعيد الاتصال مساحة العمل المقصودة المتحقق منها والصلاحيات المطلوبة فقط، ولا يظهر مفتاح النشر في مصدر الصفحة أو طلبات المتصفح أو الحزم العامة.
- يظهر المقال التجريبي المنشور مرة واحدة في عنوانه الأصلي النهائي. ويتوفر نصه وعنوان H1 واحد للمقال والنص البديل للصورة والمراجع واللغة والبيانات في استجابة الخادم.
- تتضمن الصفحة canonical المقصود دون noindex غير متعمّد أو تكرار للبيانات والمخطط، وتعمل صور المشاركة. اختبر البيانات المنظّمة بأداة النتائج المنسّقة من Google وافحص العنوان الفعلي في Search Console.
- يعمل استيراد أكثر من صفحة مقالات بصورة صحيحة، ولا ينشئ تكرار الاستيراد نسخًا مكررة. ويحدّث تعديل المقال أو إعدادات النشر النسخة المحلية وبياناتها.
- تبقى المسودة خاصة. ويتبع إلغاء نشر المقال التجريبي سياسة الإزالة وتحديث التخزين المؤقت لديك. ويعيد العنوان المفقود فعلًا 404 أو410، ولا يظهر انقطاع الواجهة كصفحة فارغة ناجحة.
- تظهر إعادة بدء المؤشرات وحدود المعدل والمفاتيح غير الصالحة أو الملغاة والمهل ومهام الإنشاء الفاشلة في مراقبة الخادم مع معرّفات الطلبات ودون أسرار.
فتح أداة اختبار النتائج المنسّقة · فتح Google Search Console · تابع إلى دليل SEO للنشر