Layero Metrika API
The metrika API from Layero — 5 operation(s) for metrika.
The metrika API from Layero — 5 operation(s) for metrika.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/layero-ru:layero-ru-metrika-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Layero Metrika API
version: 0.1.0
tags:
- name: metrika
paths:
/projects/{project_id}/integrations/metrika:
get:
tags:
- metrika
summary: Get Metrika Integration
operationId: get_metrika_integration_projects__project_id__integrations_metrika_get
parameters:
- name: project_id
in: path
required: true
schema:
type: string
format: uuid
title: Project Id
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/MetrikaIntegrationOut'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
delete:
tags:
- metrika
summary: Disconnect Metrika
description: 'Drop the integration row. The Metrika counter itself stays alive on
Yandex — it belongs to the user''s account.'
operationId: disconnect_metrika_projects__project_id__integrations_metrika_delete
parameters:
- name: project_id
in: path
required: true
schema:
type: string
format: uuid
title: Project Id
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
responses:
'204':
description: Successful Response
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/projects/{project_id}/integrations/metrika/connect:
post:
tags:
- metrika
summary: Connect Metrika
description: 'Start the Metrika OAuth flow. Returns the Yandex authorize URL.
`project_editor` gates the project at role>=editor; `current_user` is
its already-resolved nested dependency, so we get the caller''s user_id
for the signed state without an extra auth round-trip.
Body: `{branch_name: str | None}`. None means default_branch. The
chosen branch is baked into the signed state so the callback knows
which env''s hostname to register as the counter''s `site2` AND which
branch the integration row should track.'
operationId: connect_metrika_projects__project_id__integrations_metrika_connect_post
parameters:
- name: project_id
in: path
required: true
schema:
type: string
format: uuid
title: Project Id
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/app__api__routes__yandex_metrika__ConnectIn'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
additionalProperties: true
title: Response Connect Metrika Projects Project Id Integrations Metrika Connect Post
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/integrations/metrika/callback:
get:
tags:
- metrika
summary: Metrika Callback
description: 'OAuth redirect target. Top-level path (not under /projects) because
the redirect_uri must be a single fixed value registered on the app.'
operationId: metrika_callback_integrations_metrika_callback_get
parameters:
- name: code
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Code
- name: state
in: query
required: true
schema:
type: string
title: State
- name: error
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Error
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/projects/{project_id}/integrations/metrika/session-recording:
put:
tags:
- metrika
summary: Set Metrika Session Recording
description: 'Включить или выключить запись сессий (Вебвизор) у подключённой Метрики.
Три действия, в таком порядке:
1. флаг в базе — от него зависит `webvisor` в теге следующей сборки;
2. `arch_enabled` у счётчика в аккаунте клиента (Management API);
3. пересборка отслеживаемой ветки, чтобы тег сменился без пуша.
Флаг пишется первым намеренно: выключение — это просьба владельца
перестать писать сессии, и сбой Метрики не должен её отменять. Второй и
третий шаги best-effort, их итог возвращается в ответе.'
operationId: set_metrika_session_recording_projects__project_id__integrations_metrika_session_recording_put
parameters:
- name: project_id
in: path
required: true
schema:
type: string
format: uuid
title: Project Id
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SessionRecordingIn'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/SessionRecordingOut'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/projects/{project_id}/integrations/metrika/stats:
get:
tags:
- metrika
summary: Metrika Stats
description: 'Proxy Metrika Reporting API into the dashboard.
No local cache table — we fetch live from Metrika on each request,
behind a 5-minute in-process cache (see `app.services.metrika_data`)
that absorbs the frontend''s refetchInterval without burning the
5000/day per-token quota. State machine in the response:
* disconnected — no integration row / no counter_id yet.
* no_data_yet — counter is wired, Metrika just hasn''t seen visits.
* ready — totals.visits > 0, the dashboard renders normally.
* stale — Metrika API errored but we have a previous cached
payload; UI shows a warning + the old numbers.
* error — Metrika API errored and no cache, nothing to draw.'
operationId: metrika_stats_projects__project_id__integrations_metrika_stats_get
parameters:
- name: project_id
in: path
required: true
schema:
type: string
format: uuid
title: Project Id
- name: period
in: query
required: false
schema:
type: string
pattern: ^(7d|30d|90d)$
default: 7d
title: Period
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
additionalProperties: true
title: Response Metrika Stats Projects Project Id Integrations Metrika Stats Get
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
components:
schemas:
HTTPValidationError:
properties:
detail:
items:
$ref: '#/components/schemas/ValidationError'
type: array
title: Detail
type: object
title: HTTPValidationError
SessionRecordingOut:
properties:
session_recording:
type: boolean
title: Session Recording
counter_updated:
type: boolean
title: Counter Updated
redeployed:
type: boolean
title: Redeployed
type: object
required:
- session_recording
- counter_updated
- redeployed
title: SessionRecordingOut
description: 'Итог переключения записи сессий.
`counter_updated` — удалось ли поменять настройку у самого счётчика в
Метрике. False — флаг и тег поменялись, а переключатель в Метрике владельцу
придётся перевести вручную: панель говорит об этом прямо.
`redeployed` — запущена ли пересборка, чтобы тег на сайте сменился.'
app__api__routes__yandex_metrika__ConnectIn:
properties:
branch_name:
anyOf:
- type: string
- type: 'null'
title: Branch Name
session_recording:
type: boolean
title: Session Recording
default: false
type: object
title: ConnectIn
MetrikaIntegrationOut:
properties:
available:
type: boolean
title: Available
connected:
type: boolean
title: Connected
counter_id:
anyOf:
- type: integer
- type: 'null'
title: Counter Id
yandex_login:
anyOf:
- type: string
- type: 'null'
title: Yandex Login
status:
type: string
title: Status
site_url:
anyOf:
- type: string
- type: 'null'
title: Site Url
metrika_url:
anyOf:
- type: string
- type: 'null'
title: Metrika Url
tracked_branch_name:
anyOf:
- type: string
- type: 'null'
title: Tracked Branch Name
available_branches:
items:
type: string
type: array
title: Available Branches
injection_mode:
type: string
title: Injection Mode
snippet:
anyOf:
- type: string
- type: 'null'
title: Snippet
session_recording:
type: boolean
title: Session Recording
default: false
type: object
required:
- available
- connected
- status
- available_branches
- injection_mode
title: MetrikaIntegrationOut
description: 'Состояние привязки Метрики (AGENT-03).
Обе ветки хендлера — с интеграцией и без — возвращают один и тот же
набор полей, поэтому модель одна. Формат не меняется: `response_model`
фильтрует лишнее, и расхождение сломало бы страницу аналитики.'
SessionRecordingIn:
properties:
enabled:
type: boolean
title: Enabled
type: object
required:
- enabled
title: SessionRecordingIn
ValidationError:
properties:
loc:
items:
anyOf:
- type: string
- type: integer
type: array
title: Location
msg:
type: string
title: Message
type:
type: string
title: Error Type
input:
title: Input
ctx:
type: object
title: Context
type: object
required:
- loc
- msg
- type
title: ValidationError