Integrating 1C-Bitrix with external systems via REST API is a challenge every developer faces when automating data exchange: products, orders, counterparties. We often see the same mistakes: missing pagination, weak authentication, ignoring caching. For example, one company experienced significant losses due to server crashes during mass import — no pagination, and the server hit memory limit. Proper API design saves up to 40% of support time and allows painless scaling. In this article, we'll cover key techniques: how to choose the application type, why OAuth is 5 times more secure than a webhook, why pagination and cache are essential, and how we build turnkey REST APIs.
Types of REST Apps in Bitrix
Let's review the three options to choose the right one for your scenario.
- Local Application — installed on a specific Bitrix24 portal, not published in the marketplace. Created in "Applications → For Developers → Other → Local Application". Easier setup, no review process.
- Inbound Webhook — a simplified option: a fixed token tied to a specific user. Suitable for server-to-server integrations where user OAuth is not needed.
- OAuth Application — a full-fledged application with user authorization via OAuth 2.0. Needed if the application serves multiple portals.
| Parameter | Local | Webhook | OAuth |
|---|---|---|---|
| Authentication | Built-in OAuth | Fixed token | OAuth 2.0 (Authorization Code) |
| Multi-portal support | No | No | Yes |
| Setup complexity | Low | Minimal | Medium |
| Security | Medium | Low | High |
When to Use OAuth 2.0 Instead of a Webhook?
If the integration must serve multiple portals or handle confidential data — choose OAuth 2.0. It is 5 times more secure than a fixed webhook due to short-lived tokens and rotation capability. API key rotation every 90 days reduces leakage risk by 3 times compared to a static key. For internal server-to-server scenarios where security is not critical, a webhook suffices.
Creating a REST API for 1C-Bitrix as a Data Source
The standard bitrix.rest module exposes Bitrix data to external systems. But sometimes you need the reverse: create a REST API for 1C-Bitrix data that an external system can call. Use the main module and Bitrix D7 routes:
// In module or init.php — register the handler use Bitrix\Main\Routing\Controllers\PublicPageController; $app = \Bitrix\Main\Application::getInstance(); $app->getRouter()->add( 'GET', '/api/v1/products/{id}', function(\Bitrix\Main\HttpRequest $request, int $id) { // Check API key $apiKey = $request->getHeader('X-API-Key'); if (!validateApiKey($apiKey)) { http_response_code(401); echo json_encode(['error' => 'Unauthorized']); die(); } $element = \CIBlockElement::GetByID($id)->GetNext(); header('Content-Type: application/json'); echo json_encode(['product' => $element]); die(); } ); Importance of API Versioning
For long-term integration, version the API in the URL (/api/v1/, /api/v2/). Changes in v2 do not break clients on v1. Generate documentation via OpenAPI/Swagger: a YAML file with the schema published at /api/docs. Certified specialists ensure the documentation is always up to date.
Mandatory Pagination in REST API
Pagination is mandatory for methods returning lists. Without it, you risk exceeding memory and execution time limits. Pagination reduces server load by 3 times compared to fetching all data. We implement page-based pagination:
// Standard pagination for a catalog REST method function getProductsList(int $page = 1, int $limit = 50): array { $offset = ($page - 1) * $limit; $result = \CIBlockElement::GetList( ['ID' => 'ASC'], ['IBLOCK_ID' => CATALOG_IBLOCK_ID, 'ACTIVE' => 'Y'], false, ['nTopCount' => $limit, 'iNumPage' => $page], ['ID', 'NAME', 'DETAIL_TEXT', 'PREVIEW_PICTURE', 'PROPERTY_*'] ); $items = []; while ($item = $result->GetNext()) { $items[] = $item; } $total = \CIBlockElement::GetList( [], ['IBLOCK_ID' => CATALOG_IBLOCK_ID, 'ACTIVE' => 'Y'], [] ); return [ 'items' => $items, 'pagination' => [ 'page' => $page, 'limit' => $limit, 'total' => $total, 'pages' => ceil($total / $limit), ], ]; } Authentication and Security
For machine-to-machine integrations (external system → Bitrix), use API keys stored in b_option. Rotate keys every 90 days. OAuth application with short-lived tokens is 5 times more secure than a webhook with a fixed token when dealing with confidential data. Requests must include:
- HTTPS — all integrations over TLS 1.2+.
- IP restriction at nginx level:
allow 192.168.1.0/24; deny all;for endpoints called only from the corporate network. - Rate limiting:
limit_req_zonein nginx, 100 requests/minute per IP.
Official REST API documentation
What Is Tagged Caching and Why Is It Needed?
REST API without caching means direct database load on every request. Tagged caching allows cache invalidation by tags when data changes. Use \Bitrix\Main\Data\Cache:
$cache = \Bitrix\Main\Data\Cache::createInstance(); $cacheKey = 'product_' . $productId . '_' . LANGUAGE_ID; if ($cache->initCache(1800, $cacheKey, '/api/products/')) { return $cache->getVars(); } $cache->startDataCache(); $data = fetchProductData($productId); $cache->endDataCache($data); return $data; A TTL of 30 minutes for the catalog provides a reasonable balance between freshness and load.
What Our Work Includes
We offer a comprehensive turnkey integration development:
- API schema design and documentation (OpenAPI/Swagger).
- Implementation of CRUD methods for all necessary entities.
- Authentication setup (OAuth 2.0, API keys, webhooks).
- Pagination, filtering, and caching integration.
- Writing automated tests and integration documentation.
- Training your developers on API usage.
| Task | Effort |
|---|---|
| Schema design and documentation | 4–8 h |
| CRUD implementation (per entity) | 4–6 h |
| Authentication and security | 4–6 h |
| Pagination, filtering, caching | 4–6 h |
| Tests and integration documentation | 6–8 h |
Timelines and cost are calculated individually. If you need a reliable 1C-Bitrix integration with your CRM, ERP, or online store, contact us. Get a consultation — our engineers will propose the optimal solution. Order integration development now — it will save your resources.

