--- title: "Pozostałe: Landing pages · statystyki URL-i (`getUrlsStatistics`)" source: https://docs.senuto.com/modules/rank_tracker/rt-landing-pages-getUrlsStatistics api: POST /api/rank_tracker/reports/landing_pages/getUrlsStatistics --- # Pozostałe: Landing pages · statystyki URL-i (`getUrlsStatistics`) **`POST /api/rank_tracker/reports/landing_pages/getUrlsStatistics`** Zwraca stronicowaną listę statystyk adresów URL (landing pages) projektu Rank Tracker w zadanym zakresie dat. Wymagane są `project_id` oraz zakres `date_min`–`date_max` w formacie `YYYY-MM-DD` (walidator `UrlsStatisticsValidator`). --- ## Żądanie `POST` `/api/rank_tracker/reports/landing_pages/getUrlsStatistics` Nagłówki: `Authorization: Bearer `, `Content-Type: application/json`. ### Struktura żądania **Podstawowy** ```jsonc filename="żądanie-podstawowe.jsonc" { "project_id": null, "date_min": "2026-06-20", "date_max": "2026-06-29" } ``` **Rozszerzony** ```jsonc filename="żądanie-rozszerzone.jsonc" { "project_id": null, "date_min": "2026-06-20", "date_max": "2026-06-29", "limit": 2, "page": 1 } ``` **cURL** ```bash curl --location --request POST 'https://api.senuto.com/api/rank_tracker/reports/landing_pages/getUrlsStatistics' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer $YOUR_TOKEN_HERE' \ --data-raw '{ "project_id": null, "date_min": "2026-06-20", "date_max": "2026-06-29", "limit": 2 }' ``` ### Parametry ```ts type GetUrlsStatisticsRequest = { /** * **Wymagane**. ID projektu Rank Tracker. Musi należeć do użytkownika, * inaczej zwracane jest `418` z `Unauthorized access`. * Realny `project_id` pobierzesz z `POST /api/rank_tracker/management/projects/getMyActiveProjects`. */ project_id: number; /** * **Wymagane**. Początek zakresu dat w formacie `YYYY-MM-DD`. * Brak pola → `418` z `{"date_min":{"_required":"This field is required"}}`. */ date_min: string; /** * **Wymagane**. Koniec zakresu dat w formacie `YYYY-MM-DD`. * **Uwaga (bug):** gdy `date_min > date_max`, komunikat walidacji `DateRangeRules` jest odwrócony. */ date_max: string; /** * Filtrowanie listy adresów URL. Rejestr filtrów tego endpointu jest **wąski** — * dozwolone klucze: `url` oraz alias `statistics.url.current`. * ⚠️ **Uwaga:** ten endpoint (backend MySQL) na **nieznany lub źle sformułowany** filtr zwraca * `HTTP 500` (nie `418`) — używaj wyłącznie kluczy z listy. */ filtering?: Array<{ filters: Array<{ key: string; match?: string; value: string | number; complement?: boolean }>; conjunction?: 'and' | 'or'; }>; /** * Rozmiar strony paginacji. Odbija się w `pagination.limit`. * @default 10 */ limit?: number; /** * Numer strony paginacji. * @default 1 */ page?: number; } export default GetUrlsStatisticsRequest ``` > **Ostrzeżenie:** > **Pułapki potwierdzone na produkcji:** > > - Brak `date_min`/`date_max` → `418` z `{"date_min":{"_required":"This field is required"},"date_max":{"_required":"This field is required"}}`. > - **Znany bug:** przy `date_min > date_max` komunikat walidacji `DateRangeRules` jest **odwrócony** — wskazuje niewłaściwe pole zakresu. > - `pagination.count` jest zwracane jako **string**, pozostałe pola paginacji są liczbami. > - **Ten sam wiersz podaje metryki dwoma typami:** na najwyższym poziomie `visibility`, `top3`, > `top10`, `top50`, `sum_searches` i `last_position` to **stringi**, a w obiekcie `statistics` > te same wartości są **liczbami** (poza `searches`, które zostaje stringiem). Rzutuj typy > przed obliczeniami. ## Odpowiedź Po pomyślnym żądaniu otrzymujesz `data` (tablicę statystyk URL-i) oraz `pagination`. Projekt, który w podanym zakresie dat nie ma pozycjonujących się adresów, zwraca pustą tablicę. **Skrócona** ```json filename="przykładowa-odpowiedź (skrócona)" { "success": true, "data": [ { "uid": "a0a93179e90261866c955748815a6b27", "url": "https://example.com/produkt/", "visibility": "7.52", "top3": "1", "top10": "1", "top50": "1", "sum_searches": "70", "best_keyword": "nazwa produktu", "last_position": "3", "page_path": "//example.com/produkt/" } ], "pagination": { "page_count": 1, "current_page": 1, "has_next_page": false, "has_prev_page": false, "count": "1", "limit": 3 } } ``` **Pełna** ```json filename="przykładowa-odpowiedź (200)" { "success": true, "data": [ { "uid": "a0a93179e90261866c955748815a6b27", "url": "https://example.com/produkt/", "visibility": "7.52", "top3": "1", "top10": "1", "top50": "1", "sum_searches": "70", "best_keyword": "nazwa produktu", "last_position": "3", "statistics": { "position": { "current": 3 }, "visibility": { "current": 7.52 }, "searches": { "current": "70" }, "url": { "current": "https://example.com/produkt/" }, "top3": { "current": 1 }, "top10": { "current": 1 }, "top50": { "current": 1 } }, "page_path": "//example.com/produkt/" } ], "pagination": { "page_count": 1, "current_page": 1, "has_next_page": false, "has_prev_page": false, "count": "1", "limit": 3 } } ``` ### Struktura odpowiedzi ```ts type GetUrlsStatisticsResponse = { /** `true` przy powodzeniu; przy błędzie `false` i koperta z `error` */ success: boolean; /** Statystyki adresów docelowych. */ data: Array<{ /** Identyfikator adresu w raporcie. */ uid: string; url: string; /** Ścieżka adresu bez schematu, w formie `//domena/sciezka`. */ page_path: string; /** **Uwaga na typy:** te pola wracają jako **stringi**, nie liczby. */ visibility: string; top3: string; top10: string; top50: string; sum_searches: string; last_position: string; /** Fraza, na której adres wypada najwyżej. */ best_keyword: string; /** Te same metryki w formie zagnieżdżonej — tu `position`, `visibility`, `top3`, * `top10` i `top50` są **liczbami**, a `searches` pozostaje stringiem. */ statistics: { position: { current: number }; visibility: { current: number }; searches: { current: string }; url: { current: string }; top3: { current: number }; top10: { current: number }; top50: { current: number }; }; }>; /** Metadane paginacji */ pagination: { page_count: number; current_page: number; has_next_page: boolean; has_prev_page: boolean; /** **Uwaga:** string, nie liczba (np. `"0"`) */ count: string; limit: number; }; } export default GetUrlsStatisticsResponse ``` ## Błędy ```ts type ErrorResponse = { success: false; data: { error: { /** np. invalid_data, unknown */ type: string; message: string; /** pole -> reguła -> komunikat (dla invalid_data) */ params?: Record>; }; }; } export default ErrorResponse ``` > **Błąd:** > **`418`** jest zwracane przy błędach walidacji (`invalid_data`) — nie tylko przy ograniczaniu liczby żądań. Brak dat → `418` z `{"date_min":{"_required":"This field is required"},"date_max":{"_required":"This field is required"}}`. Cudzy lub nieistniejący `project_id` zwraca `418` z `Unauthorized access`, a nie `404`. Pamiętaj o odwróconym komunikacie `DateRangeRules` przy `date_min > date_max`. ## Powiązane akcje - `getUrlsStatistics` — statystyki URL-i (landing pages) w zakresie dat (ta strona); jedyna zbadana akcja kontrolera `LandingPages`