landing.block.getrepository
Получить список блоков из репозитория
Описание
Метод landing.block.getrepository возвращает доступные разделы репозитория блоков или данные одного раздела.
Параметры
section
string
необязательный
Код раздела репозитория, например text.
Если параметр не передан, метод вернет все доступные разделы. В этом случае ключами объекта result будут коды разделов.
Кроме стандартных разделов, в ответ могут появляться разделы партнерских приложений и служебные разделы. Чтобы получить актуальные коды разделов, вызовите метод без section.
Если раздел с таким кодом не найден или передана пустая строка, метод вернет false без ошибки
scope
string
необязательный
Дополнительный верхнеуровневый параметр REST-вызова, который влияет на тип сайта, для которого собирается репозиторий.
Для сайтов типов PAGE, STORE и SMN параметр передавать не нужно. Для GROUP, KNOWLEDGE и MAINPAGE передайте соответствующий scope.
Подробно правила выбора значения описаны в статье Работа с типами сайтов и скоупами.
Если scope не передан, метод использует текущий тип сайта, а если его нельзя определить из контекста, работает как для типа PAGE
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"section": "text"
}' \
"https://**put.your-domain-here**/rest/**user_id**/**webhook_code**/landing.block.getrepository.json"
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"section": "text",
"auth": "**put_access_token_here**"
}' \
"https://**put.your-domain-here**/rest/landing.block.getrepository.json"
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
type BlockItem = {
id: string | null
name: string
namespace: string
new: boolean
version: string | null
type: string[]
section: string | string[]
description: string | null
preview: string
restricted: boolean
repo_id: number | string | boolean
app_code: string | boolean
requires_updates: boolean
}
// Shape of the payload returned in result (match the "response handling" section of the page)
type RepositorySection = {
name: string
meta: Record<string, unknown> | unknown[]
new: boolean
type: string | string[] | null
specialType: string | null
separator: boolean
app_code: string | boolean
items: Record<string, BlockItem>
}
try {
const response = await $b24.actions.v2.call.make<RepositorySection | false>({
method: 'landing.block.getrepository',
params: {
section: 'text',
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
if (result !== false) {
console.info('Section name:', result.name, 'Blocks count:', Object.keys(result.items).length)
}
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function getRepository() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'landing.block.getrepository',
params: {
section: 'text',
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
if (result !== false) {
console.info('Section name:', result.name, 'Blocks count:', Object.keys(result.items).length)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', getRepository)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
try:
bitrix_response = client.landing.block.getrepository(
section="text",
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Ошибка Bitrix API",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
print(f"Непредвиденная ошибка: {error}")
try {
$response = $b24Service
->core
->call(
'landing.block.getrepository',
[
'section' => 'text',
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . var_export($result, true);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error getting repository blocks: ' . $e->getMessage();
}
BX24.callMethod(
'landing.block.getrepository',
{
section: 'text'
},
function(result)
{
if (result.error())
{
console.error(result.error());
}
else
{
console.info(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'landing.block.getrepository',
[
'section' => 'text',
]
);
if (isset($result['error']))
{
echo 'Ошибка: ' . $result['error_description'];
}
else
{
echo '<pre>';
print_r($result['result']);
echo '</pre>';
}
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "landing.block.getrepository", b24.Params{
"section": "text",
})
if err != nil {
return fmt.Errorf("landing.block.getrepository: %w", err)
}
var item struct {
Name string `json:"name"`
New bool `json:"new"`
Separator bool `json:"separator"`
AppCode bool `json:"app_code"`
}
if err := json.Unmarshal(res.Result, &item); err != nil {
return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println(item.Name, item.New)
Ответ
HTTP-статус: 200
{
"result": {
"name": "Текст",
"meta": {
"ai_text_placeholder": "text for website, family business, sale of flowers",
"ai_text_max_tokens": 150
},
"new": false,
"type": null,
"specialType": null,
"separator": false,
"app_code": false,
"items": {
"03.1.three_cols_big_with_text_and_titles": {
"id": null,
"name": "Текст в 3 колонки на всю ширину страницы на цветном фоне",
"namespace": "bitrix",
"new": false,
"version": null,
"type": [],
"section": [
"columns",
"text"
],
"system": false,
"description": "Три колонки с заголовками и текстом",
"preview": "//example.bitrix24.ru/bitrix/blocks/bitrix/03.1.three_cols_big_with_text_and_titles/preview.jpg",
"restricted": false,
"repo_id": false,
"app_code": false,
"only_for_license": "",
"requires_updates": false
},
"repo_405": {
"id": null,
"new": false,
"name": "Блок \"Текст + изображение\" с кнопкой, текст справа, изображение слева",
"description": null,
"namespace": "krayt.monotovar",
"type": [],
"section": [
"about",
"text",
"image"
],
"preview": "https://krayt.moscow/upload/iblock/5aa/5aabf5b9241876561d5db49c482dcd96.png",
"restricted": true,
"repo_id": "405",
"app_code": "krayt.monotovar",
"requires_updates": false
}
}
},
"time": {
"start": 1774521670,
"finish": 1774521670.823288,
"duration": 0.8232879638671875,
"processing": 0,
"date_start": "2026-03-26T13:41:10+03:00",
"date_finish": "2026-03-26T13:41:10+03:00",
"operating_reset_at": 1774522270,
"operating": 0
}
}
Возвращаемые данные
result
object
Результат запроса.
Если section не передан, result содержит объект, где ключами служат коды разделов, а значениями - объекты разделов (подробное описание).
Если section передан и найден, result содержит один объект раздела (подробное описание)
Если section передан, но такого раздела нет, метод вернет false без ошибки
time
time
Информация о времени выполнения запроса
Обработка ошибок
HTTP-статус: 400
{
"error": "ACCESS_DENIED",
"error_description": "Недостаточно прав."
}
| Код | Описание | Значение |
|---|---|---|
ACCESS_DENIED |
У пользователя нет доступа к разделу «Сайты и магазины» |

