{"id":42457050,"url":"https://github.com/bitrix-tools/crest","last_synced_at":"2026-01-28T09:01:25.131Z","repository":{"id":47214619,"uuid":"198233392","full_name":"bitrix-tools/crest","owner":"bitrix-tools","description":"Tiny PHP SDK to call Bitrix24 REST methods via webhooks and OAuth 2.0","archived":false,"fork":false,"pushed_at":"2024-01-24T14:44:51.000Z","size":22,"stargazers_count":148,"open_issues_count":11,"forks_count":77,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-08-08T16:43:58.710Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitrix-tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-22T13:54:15.000Z","updated_at":"2025-07-17T11:43:19.000Z","dependencies_parsed_at":"2023-02-15T06:16:22.842Z","dependency_job_id":null,"html_url":"https://github.com/bitrix-tools/crest","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/bitrix-tools/crest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitrix-tools%2Fcrest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitrix-tools%2Fcrest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitrix-tools%2Fcrest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitrix-tools%2Fcrest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitrix-tools","download_url":"https://codeload.github.com/bitrix-tools/crest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitrix-tools%2Fcrest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28843110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T07:39:25.367Z","status":"ssl_error","status_checked_at":"2026-01-28T07:39:24.487Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-28T09:01:09.653Z","updated_at":"2026-01-28T09:01:25.125Z","avatar_url":"https://github.com/bitrix-tools.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @bitrix/crest \n[English](#contenten) | [Русский](#contentru)\n\n\n\u003cdiv id=\"contenten\"\u003e\u003c/div\u003e\n@bitrix/crest — small PHPSDK used for Bitrix24 REST API for webhooks, local or public applications.\n\n# Contents\n1. [Description](#description)\n2. [Calling using inbound webhook](#usingwebhook)\n3. [Calling from local application](#localapp)\n4. [Calling from public application](#publicapp)\n\n\n## \u003cdiv id=\"description\"\u003e\u003c/div\u003eDescription\n\n\u003cul\u003e\n\u003cli\u003eProvided examples use cURL module to run REST requests. You need to learn how to enable cURL module on your server.\n\u003cli\u003eYour web server must have valid SSL certificate.\n\u003cli\u003eExamples use base SDK as CRest class for running requests and extending authentication tokens. Download files from repository and implement necessary authorization updates in settings.php file and place it on your server, inserting an example you need from documentation.\n\u003cli\u003eWhen SDK errors occur, you can open file checkserver.php in browser; it performs minimum server settings check to enable CRest class operation.\n\u003cli\u003eWhen project uses CRest class and encoding is not UTF-8, there are 2 additional actions:\n\u003cbr/\u003e\u003cbr/\u003eOpen files from archive and update the encoding to the required one.\n\u003cbr/\u003eDeclare the constant C_REST_CURRENT_ENCODING in the settings.php file. For example, when project has encoding windows-1251, the constant must look as follows:\u003c/li\u003e\u003c/ul\u003e\n   \n```php\ndefine('C_REST_CURRENT_ENCODING','windows-1251');\n```\n\n## \u003cdiv id=\"usingwebhook\"\u003e\u003c/div\u003eCalling REST using inbound webhook\n\nIndicate webhook URL in define C_REST_WEB_HOOK_URL inside the settings.php file:\n\n```php\ndefine('C_REST_WEB_HOOK_URL','https://xxx.bitrix24.ru/rest/1/douasdqdsxSWgc3mgc1/');\n```\n\nInsert example text into the index.php file:\n\n```php\nrequire_once('src/crest.php');\n\n// put an example below\necho '\u003cPRE\u003e';\nprint_r(CRest::call(\n   'crm.lead.add',\n   [\n      'fields' =\u003e[\n          'TITLE' =\u003e 'Lead name',//Title*[string]\n          'NAME' =\u003e 'Name',//Name[string]\n          'LAST_NAME' =\u003e 'Last name',//Last name[string]\n      ]\n   ])\n);\n\necho '\u003c/PRE\u003e';\n```\n\nIndicate example URL in the browser address bar https://example.com/index.php to see the example results.\n\n\n## \u003cdiv id=\"localapp\"\u003e\u003c/div\u003eCalling REST from local application\n\nInsert example text into the index.php file:\n\n```php\nrequire_once('src/crest.php');\n\n// put an example below\necho '\u003cPRE\u003e';\nprint_r(CRest::call(\n   'crm.lead.add',\n   [\n      'fields' =\u003e[\n          'TITLE' =\u003e 'Lead name',//Title*[string]\n          'NAME' =\u003e 'Name',//Name[string]\n          'LAST_NAME' =\u003e 'Last name',//Last name[string]\n      ]\n   ])\n);\n\necho '\u003c/PRE\u003e';\n```\n\nIndicate your app URL https://example.com/index.php as well as installation script URL https://example.com/install.php inside the local app details form.\nIndicate parameters client_id and client_secret for OAuth 2.0 authorization in define C_REST_CLIENT_ID and C_REST_CLIENT_SECRET inside the settings.php file.\nTake these values from the local app details form.\n\u003cbr\u003e\nIn the list of local applications, click on your local app and select “Reinstall”. It’s required for install.php to operate correctly after you have indicated correct values C_REST_CLIENT_ID and C_REST_CLIENT_SECRET.\nAfter installation is complete, you will see example results. When the example demonstrates widget embedding into other Bitrix24 tools, switch to these tools.\n\n## \u003cdiv id=\"publicapp\"\u003e\u003c/div\u003eCalling REST from public application\n\nInsert example text into the index.php file:\n\n```php\nrequire_once('src/crest.php');\n\n// put an example below\necho '\u003cPRE\u003e';\nprint_r(CRest::call(\n   'crm.lead.add',\n   [\n      'fields' =\u003e[\n          'TITLE' =\u003e 'Lead name',//Title*[string]\n          'NAME' =\u003e 'Name',//Name[string]\n          'LAST_NAME' =\u003e 'Last name',//Last name[string]\n      ]\n   ])\n);\n\necho '\u003c/PRE\u003e';\n```\n\nAdd a public application inside the partner’s account to get client_id and client_secret as well as when saving an application. Indicate parameters client_id and client_secret OAuth 2.0 authorization in define C_REST_CLIENT_ID and C_REST_CLIENT_SECRET in the settings.php file.\nSelect and indicate your application URL https://example.com/index.php and installation script URL https://example.com/install.php inside the app details form. After saving the version, open the version details and install your app to any available Bitrix24 by clicking on \"Install\". After installation is complete, you will see example results (when the example demonstrates widget embedding into other Bitrix24 tools, switch to these tools). For actual public app operation, you must inherit CRest class by redefining methods getSettingData/setSettingData that get/save authentication tokens in text file. These methods are not designed for application working on several Bitrix24 simultaneously. \n\u003cbr\u003e\u003cbr\u003e\n\u003chr\u003e\n\u003chr\u003e\n\u003cbr\u003e\n\n\u003cdiv id=\"contentru\"\u003e\u003c/div\u003e\n@bitrix/crest — небольшой PHPSDK для использования REST API Битрикс24 в локальных, \nтиражных приложениях или через вебхуки\n\n# Содержание\n1. [Описание](#introduction)\n2. [Вызов при помощи входящего вебхука](#webhook)\n3. [Вызов из локального приложения](#local)\n4. [Вызов из тиражного приложения](#public)\n\n\n## \u003cdiv id=\"introduction\"\u003e\u003c/div\u003eОписание\n\n\u003cul\u003e\n\u003cli\u003eПримеры используют модуль cURL для выполнения REST-запросов. Узнайте, как включить модуль cURL на своем сервере.\n\u003cli\u003eНа вашем веб-сервере должен быть установлен валидный SSL-сертификат.\n\u003cli\u003eПримеры используют базовый SDK в виде класса CRest для выполнения запросов и продления токенов авторизации. Скачайте файлы из репозитория внесите необходимые правки, связанные с авторизацией в файл settings.php и разместите на своем сервере, вставив нужный вам пример из документации.\n\u003cli\u003eПри возникновении проблем с работой SDK вы можете открыть через браузер файл checkserver.php, который произведёт минимальную проверку настроек сервера для работы класса CRest.\n\u003cli\u003eЕсли в проекте используется класс CRest и кодировка отличается от utf8, то необходимо сделать 2 дополнительных действия:\n\u003cbr/\u003e\u003cbr/\u003eОткрыть файлы из архива и изменить их кодировку на необходимую.\n\u003cbr/\u003eВ файле settings.php объявить константу C_REST_CURRENT_ENCODING. Например, если проект в кодировке windows-1251 константа выглядеть должна так:\u003c/li\u003e\u003c/ul\u003e\n   \n```php\ndefine('C_REST_CURRENT_ENCODING','windows-1251');\n```\n\n## \u003cdiv id=\"webhook\"\u003e\u003c/div\u003eВызов REST с использованием входящего вебхука\n\nУкажите URL вебхука в define C_REST_WEB_HOOK_URL в файле settings.php:\n\n```php\ndefine('C_REST_WEB_HOOK_URL','https://xxx.bitrix24.ru/rest/1/douasdqdsxSWgc3mgc1/');\n```\n\nВставьте текст примера в файл index.php:\n\n```php\nrequire_once('src/crest.php');\n\n// put an example below\necho '\u003cPRE\u003e';\nprint_r(CRest::call(\n   'crm.lead.add',\n   [\n      'fields' =\u003e[\n          'TITLE' =\u003e 'Название лида',//Заголовок*[string]\n          'NAME' =\u003e 'Имя',//Имя[string]\n          'LAST_NAME' =\u003e 'Фамилия',//Фамилия[string]\n      ]\n   ])\n);\n\necho '\u003c/PRE\u003e';\n```\n\nУкажите URL к примеру в адресной строке браузера https://example.com/index.php, чтобы увидеть результат работы примера.\n\n\n## \u003cdiv id=\"local\"\u003e\u003c/div\u003eВызов REST из локального приложения\n\nВставьте текст примера в файл index.php:\n\n```php\nrequire_once('src/crest.php');\n\n// put an example below\necho '\u003cPRE\u003e';\nprint_r(CRest::call(\n   'crm.lead.add',\n   [\n      'fields' =\u003e[\n          'TITLE' =\u003e 'Название лида',//Заголовок*[string]\n          'NAME' =\u003e 'Имя',//Имя[string]\n          'LAST_NAME' =\u003e 'Фамилия',//Фамилия[string]\n      ]\n   ])\n);\n\necho '\u003c/PRE\u003e';\n```\n\nВ карточке локального приложения укажите URL своего приложения https://example.com/index.php и URL скрипта установки https://example.com/install.php.\nУкажите значения параметров client_id и client_secret для авторизации OAuth 2.0 в define C_REST_CLIENT_ID и C_REST_CLIENT_SECRET в файле settings.php, взяв эти значения из карточки локального приложения.\n\u003cbr\u003e\nВ списке локальных приложений нажмите правой кнопкой мыши на своё локальное приложение и выберите пункт \"Переустановить\". Это нужно чтобы корректно сработал install.php после того, как вы вставили корректные значения C_REST_CLIENT_ID и C_REST_CLIENT_SECRET.\nПосле установки вы увидите результат работы примера. Если пример демонстрирует встраивание виджетов в другие инструменты Битрикс24, необходимо перейти в эти инструменты.\n\n\n## \u003cdiv id=\"public\"\u003e\u003c/div\u003eВызов REST из тиражного приложения\n\nВставьте текст примера в файл index.php\n\n```php\nrequire_once('src/crest.php');\n\n// put an example below\necho '\u003cPRE\u003e';\nprint_r(CRest::call(\n   'crm.lead.add',\n   [\n      'fields' =\u003e[\n          'TITLE' =\u003e 'Название лида',//Заголовок*[string]\n          'NAME' =\u003e 'Имя',//Имя[string]\n          'LAST_NAME' =\u003e 'Фамилия',//Фамилия[string]\n      ]\n   ])\n);\n\necho '\u003c/PRE\u003e';\n```\n\nДобавьте тиражное приложение в партнерском кабинете для получения client_id и client_secret и при сохранении приложения.\nУкажите значения параметров client_id и client_secret для авторизации OAuth 2.0 в define C_REST_CLIENT_ID и C_REST_CLIENT_SECRET в файле settings.php.\n\n\u003cbr\u003e\n\nВ карточке приложения добавьте версию и укажите URL своего приложения https://example.com/index.php и URL скрипта установки https://example.com/install.php в карточке версии.\nПосле сохранения версии откройте карточку версии и, нажав на ссылку \"Установить на своем Битрикс24\", установите свое приложение на любой доступный вам Битрикс24.\nПосле установки вы увидите результат работы примера (в случае, если пример демонстрирует встраивание виджетов в другие инструменты Битрикс24, необходимо перейти в эти инструменты).\nДля реального тиражного приложения необходимо пронаследовать класс CRest, переопределив методы getSettingData/setSettingData, которые занимается получением/сохранением токенов авторизации в текстовый файл. Эти методы не предназначены для эксплуатации приложения на нескольких Битрикс24 одновременно.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitrix-tools%2Fcrest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitrix-tools%2Fcrest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitrix-tools%2Fcrest/lists"}