REST API
كل إجراء في واجهة Celerp نقطة نهاية REST، وهي الواجهة البرمجية نفسها التي تستخدمها واجهة الاستخدام داخليًا. أتمِت سير العمل، أو اربط أنظمة أخرى، أو ابنِ أدواتك الخاصة. تعمل الواجهة البرمجية محليًا على بياناتك؛ ولا يُرسَل شيء إلى السحابة.
🔗 العنوان الأساسي
http://localhost:8000 عند التثبيت عبر pip. يختار تطبيق سطح المكتب منفذه بنفسه: راجع celerp-data/api-port.
🔑 المصادقة
Bearer JWT من /auth/login
📦 التنسيق
JSON دخلًا، JSON خرجًا
📖 المواصفات
GET /openapi.json (OpenAPI 3.1)
أي منفذ؟ عند التثبيت باستخدام pip install celerp يعمل خادم الواجهة البرمجية على localhost:8000 (غيّره باستخدام --api-port)، أما المنفذ 8080 فمخصّص لواجهة الويب التي يستخدمها الأشخاص، لا للواجهة البرمجية. يختار تطبيق سطح المكتب منافذ متاحة في كل مرة يبدأ فيها، ويكتب منفذ الواجهة البرمجية في الملف api-port داخل مجلد celerp-data. لتثبيت المنفذ، عيّن CELERP_API_PORT قبل تشغيل التطبيق.
المصادقة
يستخدم Celerp رموز وصول قصيرة الأمد من نوع JSON Web Token. سجّل الدخول ببريدك الإلكتروني وكلمة مرورك في Celerp للحصول على رمز وصول، ثم أرسله في ترويسة Bearer مع كل طلب.
1. تسجيل الدخول
curl -X POST http://localhost:8000/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "password": "your-password"}'
تحتوي الاستجابة على رمزَين:
{
"access_token": "eyJhbGciOiJI...",
"refresh_token": "eyJhbGciOiJI..."
}
2. استدعاء الواجهة البرمجية باستخدام الرمز
curl http://localhost:8000/items \
-H "Authorization: Bearer eyJhbGciOiJI..."
- يُعرّف الرمز المستخدمَ والدورَ والشركةَ، لذا تُقيَّد الطلبات تلقائيًا بتلك الشركة - دون الحاجة إلى ترويسة إضافية.
- تصل صلاحية رموز الوصول إلى 24 ساعة. عند انتهاء صلاحية أحدها، احصل على زوج جديد بإرسال
refresh_tokenبطريقة POST إلى/auth/token/refresh. - هل تنتمي إلى أكثر من شركة؟ أدرجها باستخدام
GET /auth/my-companies، ثم احصل على رمز لشركة أخرى باستخدامPOST /auth/switch-company/{company_id}.
تحمل الرموز صلاحياتك. يستطيع رمز viewer القراءة لا الكتابة؛ وتستلزم أرقام التكلفة دور manager أو أعلى. تعامل مع رموز الوصول معاملة كلمات المرور، فمن يحملها يستطيع التصرّف باسمك.
إرسال الطلبات
توجد جميع نقاط النهاية تحت عنوان خادم الواجهة البرمجية لديك (http://localhost:8000 في تثبيت pip، كما في الأمثلة أدناه) وتُعيد JSON. وتُعيد نقاط نهاية القوائم مصفوفة items وإجماليًا في total:
curl "http://localhost:8000/items?limit=20&offset=0" \
-H "Authorization: Bearer $TOKEN"
{
"items": [
{ "id": "item:...", "sku": "WIDGET-001", "name": "Widget", "quantity": 42 }
],
"total": 142
}
تقسيم الصفحات: مرّر ?limit= (الافتراضي 50) و?offset=. وتقبل معظم نقاط نهاية القوائم أيضًا عبارة بحث في q= ومرشّحات للأعمدة (مثل ?status=available).
إنشاء البيانات
أرسل JSON بطريقة POST لإنشاء السجلات. وتُعيد عمليات الكتابة مُعرِّف الكيان الجديد id (ومعه event_id الأساسي، فكل تغيير في Celerp حدث).
curl -X POST http://localhost:8000/crm/contacts \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corp",
"email": "[email protected]",
"contact_type": "customer",
"idempotency_key": "acme-2026-06-21"
}'
الأمان عند التكرار (Idempotency): أدرج idempotency_key في أي عملية كتابة. فالطلب المُعاد بالمفتاح نفسه لا ينشئ سجلًا مكرّرًا، وهذا آمن مع الشبكات غير المستقرّة والمهام الدُفعية.
الاصطلاحات
- الأخطاء تُعيد الاستجابات التي لا تبدأ بـ 2xx الشكل
{"detail": "..."}مع رمز حالة HTTP قياسي. - حدود المعدّل 60 طلبًا في الدقيقة لكل عنوان IP افتراضيًا، وتسجيل الدخول محدود بـ 10 طلبات في الدقيقة. وتجاوز الحد يُعيد الرمز
429. - الصلاحيات تخضع نقاط النهاية لدورك:
viewer → operator → manager → admin → owner. - نطاق الشركة يعمل كل طلب على الشركة المحدّدة في رمز وصولك؛ وللعمل على شركة أخرى بدّل الشركة أولًا.
نقاط النهاية الشائعة
شريحة صغيرة تكفي للبدء. وتضيف كل وحدة نقاط النهاية الخاصة بها، والقائمة الكاملة في مخطط OpenAPI أدناه.
| الطريقة | المسار | الوصف |
|---|---|---|
POST | /auth/login | الحصول على رمز وصول (لا تتطلب مصادقة) |
GET | /health | حالة الخدمة (لا تتطلب مصادقة) |
GET | /items | سرد أصناف المخزون |
POST | /items | إنشاء صنف |
GET | /docs | سرد المستندات (فواتير وأوامر شراء وفواتير مورّدين، …) |
POST | /docs | إنشاء مستند |
GET | /crm/contacts | سرد العملاء والمورّدين |
POST | /crm/contacts | إنشاء جهة اتصال |
GET | /dashboard/kpis | مؤشّرات أداء العمل الرئيسية |
مرجع كامل حسب القسم
كل نقطة نهاية يقدّمها الـ API قيد التشغيل، مجمّعة حسب القسم. تسرد كل صفحة الطريقة والمسار والمعاملات وبنية الطلب والاستجابة ومثالًا على الاستدعاء.
Auth
Authentication API for Celerp users, login, logout, password recovery, company switching, and API access. (13 endpoints)
Companies
Company settings and administration API for users, roles, locations, taxes, payment terms, price lists, modules, and company preferences. (70 endpoints)
Items
Inventory API for products and stock items, quantities, pricing, locations, barcodes, valuation, imports, reservations, transfers, transformations, and stock status. (39 endpoints)
Docs
Business document API for invoices, bills, purchase orders, quotations, credit notes, shipping documents, payments, fulfillment, PDF output, and document lifecycle operations. (52 endpoints)
Lists
Inventory list API for stock audits, transfers, write-offs, manifests, scans, reservations, notes, exports, and list lifecycle operations. (38 endpoints)
Accounting
Celerp accounting REST API for the chart of accounts, journal entries, general ledger, bank reconciliation, financial statements, transfers, and fiscal period controls. (59 endpoints)
Ledger
Event ledger API for reading Celerp business events and rebuilding derived application data. (3 endpoints)
Reports
ERP reporting API for accounts receivable and payable aging, sales, purchases, and expiring inventory. (5 endpoints)
Manufacturing
Manufacturing API for production orders, recipes, work centers, workflows, material requirements, costing, scheduling, component issue, and finished-goods receipt. (32 endpoints)
Labels
Inventory label and barcode API for label templates, single-item labels, bulk label sheets, and printable PDFs. (7 endpoints)
Crm
CRM REST API for customers, suppliers, contacts, addresses, people, notes, tags, files, imports, exports, and contact management. (25 endpoints)
Subscriptions
Recurring document and subscription API for invoice and purchase-order templates, scheduling, activation, pausing, resuming, cancellation, and on-demand generation. (6 endpoints)
Connectors
Integration API for connecting Celerp ERP to external commerce and business platforms, managing connector credentials, and running data synchronization. (9 endpoints)
Payments
Payment integration API for connecting payment processing, checking payment availability, and reading connection status. (7 endpoints)
Backup
Backup and restore API for exporting, importing, listing, creating, and restoring Celerp ERP backups. (8 endpoints)
Notifications
User notification API for listing notifications and marking individual or all notifications as read. (3 endpoints)
Events
Real-time server-sent events API for Celerp notifications and live application events. (1 endpoint)
System
System health, readiness, restart, and factory reset endpoints for a Celerp ERP installation. (10 endpoints)
Admin
Administrative diagnostics and system status endpoints for maintaining a Celerp ERP installation. (2 endpoints)
Ai
Celerp AI API for ERP assistant conversations, document extraction, batch jobs, memory, usage, and user-confirmed business actions. (22 endpoints)
Attachments
Inventory attachment API for uploading, downloading, tagging, previewing, and deleting item files and product images. (12 endpoints)
Dashboard
Dashboard API for ERP KPIs, recent business activity, and searchable activity history. (3 endpoints)
Payments Public
Public payment endpoints for customer payment links and payment-provider return handling. (2 endpoints)
Received
Received documents API for documents other Celerp users shared with you: list and review them, book one as your own draft, and bring a booked draft up to date with the sender's latest revision. (5 endpoints)
Search
Global Celerp ERP search API for finding permitted records across modules from a single query. (1 endpoint)
Settings
System settings and Celerp Connect API for account setup, cloud connection state, billing, backups, connectors, and partner configuration. (17 endpoints)
Share
Document sharing API for creating, inspecting, updating, and revoking public share links for Celerp documents and lists. (4 endpoints)
Share Public
Public document sharing and import endpoints for viewing shared Celerp documents and downloading or importing portable document bundles. (4 endpoints)
Stars
Supporter badge and Celerp community recognition API for badge verification, display, opt-out, and prompts. (6 endpoints)
Verticals
Industry preset and category schema API for configuring Celerp ERP fields and defaults by business vertical. (5 endpoints)
Company Backups
16 endpoints
Migrations
22 endpoints
استكشاف الواجهة البرمجية الكاملة
المرجع الكامل والمحدَّث دائمًا مخطط OpenAPI 3.1 الذي تولّده نسختك:
GET http://localhost:8000/openapi.json
حمّله في أي أداة تدعم OpenAPI - Postman أو Insomnia أو Swagger UI أو أي مولّد عملاء برمجيين - لتستعرض كل نقطة نهاية وكل نموذج، وتجرّب الطلبات، وتولّد عميلًا بأنواع محدّدة بلغتك. ويشحن Celerp المخطط نفسه بدلًا من صفحة توثيق مستضافة، لتبقى واجهتك البرمجية خاصة بنسختك وحدها.
تفضّل اللغة الطبيعية؟ يستدعي مساعد الذكاء الاصطناعي (Connect) هذه الواجهة البرمجية نفسها نيابةً عنك؛ اطلب منه استخراج تقرير أو إنشاء مستند بلغة طبيعية. وتذكّر: كل ما تفعله الواجهة البرمجية تفعله دون وصول خاص، تمامًا كما يستطيع أي مستخدم مسجَّل الدخول.