Skip to main content

data_for_seo/entity/on_page/
instant_pages.rs

1use crate::entity::OnPageDataApiCrawlStatus;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5/// OnPage Instant Pages result: on-the-fly page analysis without a prior task.
6/// See <https://docs.dataforseo.com/v3/on_page/instant_pages/>.
7#[derive(Debug, Default, Serialize, Deserialize, Clone)]
8pub struct OnPageDataApiInstantPages {
9    /// Status of the crawling session (`in_progress`, `finished`).
10    pub crawl_progress: Option<String>,
11    /// Details of the crawling session; `null` for instant pages.
12    pub crawl_status: Option<OnPageDataApiCrawlStatus>,
13    /// IP address the crawler used to initiate the session.
14    pub crawl_gateway_address: Option<String>,
15    /// Total number of relevant items in the database.
16    pub total_items_count: Option<i64>,
17    /// Number of items in the `items` array.
18    pub items_count: Option<i64>,
19    /// Array of analyzed pages.
20    pub items: Option<Vec<OnPageDataApiInstantPagesItem>>,
21}
22
23/// A single analyzed page in an Instant Pages result.
24/// See <https://docs.dataforseo.com/v3/on_page/instant_pages/>.
25#[derive(Debug, Default, Serialize, Deserialize, Clone)]
26pub struct OnPageDataApiInstantPagesItem {
27    /// Type of returned resource (`html`, `broken`, `redirect`, `script`, `image`, `stylesheet`).
28    pub resource_type: Option<String>,
29    /// HTTP response code of the page.
30    pub status_code: Option<i32>,
31    /// Location header value; redirect target URL.
32    pub location: Option<String>,
33    /// URL of the analyzed page.
34    pub url: Option<String>,
35    /// Meta information extracted from the page.
36    pub meta: Option<OnPageDataApiInstantPagesMeta>,
37    /// Page load timing metrics.
38    pub page_timing: Option<OnPageDataApiInstantPagesPageTiming>,
39    /// Page optimization score on a 100-point scale.
40    pub onpage_score: Option<f64>,
41    /// Total DOM (Document Object Model) size of the page.
42    pub total_dom_size: Option<i64>,
43    /// Result of executing the specified custom JavaScript; shape depends on the script.
44    pub custom_js_response: Option<Value>,
45    /// Error message if custom JavaScript execution failed.
46    pub custom_js_client_exception: Option<String>,
47    /// Resource loading errors and warnings for the page.
48    pub resource_errors: Option<OnPageDataApiInstantPagesResourceErrors>,
49    /// Whether the page contains broken resources.
50    pub broken_resources: Option<bool>,
51    /// Whether the page contains broken links.
52    pub broken_links: Option<bool>,
53    /// Whether a duplicate title tag exists.
54    pub duplicate_title: Option<bool>,
55    /// Whether a duplicate description exists.
56    pub duplicate_description: Option<bool>,
57    /// Whether duplicate content exists.
58    pub duplicate_content: Option<bool>,
59    /// Number of clicks from the homepage to reach this page.
60    pub click_depth: Option<i32>,
61    /// Resource size, in bytes.
62    pub size: Option<i64>,
63    /// Page size after encoding, in bytes.
64    pub encoded_size: Option<i64>,
65    /// Compressed page size, in bytes.
66    pub total_transfer_size: Option<i64>,
67    /// Date and time when the resource was fetched, in UTC (`yyyy-mm-dd hh:mm:ss +00:00`).
68    pub fetch_time: Option<String>,
69    /// Cache-control directives for the page.
70    pub cache_control: Option<OnPageDataApiInstantPagesCacheControl>,
71    /// On-page check results keyed by check name.
72    pub checks: Option<Value>,
73    /// Compression algorithm applied to the content.
74    pub content_encoding: Option<String>,
75    /// Media type used to display the page (e.g. `text/html`).
76    pub media_type: Option<String>,
77    /// Server version information.
78    pub server: Option<String>,
79    /// Whether the page is a single resource.
80    pub is_resource: Option<bool>,
81    /// Page URL length, in characters.
82    pub url_length: Option<i32>,
83    /// Relative URL length, in characters.
84    pub relative_url_length: Option<i32>,
85    /// Last-modification dates reported for the page.
86    pub last_modified: Option<OnPageDataApiInstantPagesLastModified>,
87}
88
89/// Meta information extracted from an analyzed page.
90/// See <https://docs.dataforseo.com/v3/on_page/instant_pages/>.
91#[derive(Debug, Default, Serialize, Deserialize, Clone)]
92pub struct OnPageDataApiInstantPagesMeta {
93    /// Page title.
94    pub title: Option<String>,
95    /// Code page of the document (e.g. `65001` for UTF-8).
96    pub charset: Option<i32>,
97    /// Whether meta robots allow crawlers to follow the page links.
98    pub follow: Option<bool>,
99    /// Value of the meta generator tag.
100    pub generator: Option<String>,
101    /// HTML header tags (h1–h6) found on the page.
102    pub htags: Option<Value>,
103    /// Content of the meta description tag.
104    pub description: Option<String>,
105    /// Page favicon URL.
106    pub favicon: Option<String>,
107    /// Content of the meta keywords tag.
108    pub meta_keywords: Option<String>,
109    /// Canonical page URL.
110    pub canonical: Option<String>,
111    /// Number of internal links on the page.
112    pub internal_links_count: Option<i64>,
113    /// Number of external links on the page.
114    pub external_links_count: Option<i64>,
115    /// Number of internal links pointing to the page.
116    pub inbound_links_count: Option<i64>,
117    /// Number of images on the page.
118    pub images_count: Option<i64>,
119    /// Total size of images on the page, in bytes.
120    pub images_size: Option<i64>,
121    /// Number of scripts on the page.
122    pub scripts_count: Option<i64>,
123    /// Total size of scripts on the page, in bytes.
124    pub scripts_size: Option<i64>,
125    /// Number of stylesheets on the page.
126    pub stylesheets_count: Option<i64>,
127    /// Total size of stylesheets on the page, in bytes.
128    pub stylesheets_size: Option<i64>,
129    /// Title tag length, in characters.
130    pub title_length: Option<i32>,
131    /// Description tag length, in characters.
132    pub description_length: Option<i32>,
133    /// Number of scripts that block page rendering.
134    pub render_blocking_scripts_count: Option<i64>,
135    /// Number of stylesheets that block page rendering.
136    pub render_blocking_stylesheets_count: Option<i64>,
137    /// Cumulative Layout Shift (CLS) Core Web Vitals metric.
138    pub cumulative_layout_shift: Option<f64>,
139    /// Content of the meta title tag in the head section.
140    pub meta_title: Option<String>,
141    /// Readability and content-consistency metrics for the page.
142    pub content: Option<OnPageDataApiInstantPagesContent>,
143    /// Deprecated HTML tags found on the page.
144    pub deprecated_tags: Option<Vec<String>>,
145    /// Duplicate meta tags found on the page.
146    pub duplicate_meta_tags: Option<Vec<String>>,
147    /// Spellcheck results (Hunspell-based).
148    pub spell: Option<Value>,
149    /// Open Graph and Twitter card tags found on the page.
150    pub social_media_tags: Option<Value>,
151}
152
153/// Readability and content-consistency metrics for an analyzed page.
154/// See <https://docs.dataforseo.com/v3/on_page/instant_pages/>.
155#[derive(Debug, Default, Serialize, Deserialize, Clone)]
156pub struct OnPageDataApiInstantPagesContent {
157    /// Total size of plain text on the page, in bytes.
158    pub plain_text_size: Option<i64>,
159    /// Ratio of `plain_text_size` to overall page `size`.
160    pub plain_text_rate: Option<f64>,
161    /// Number of words in the page text.
162    pub plain_text_word_count: Option<i64>,
163    /// Automated Readability Index score for the page text.
164    pub automated_readability_index: Option<f64>,
165    /// Coleman-Liau readability index for the page text.
166    pub coleman_liau_readability_index: Option<f64>,
167    /// Dale-Chall readability index for the page text.
168    pub dale_chall_readability_index: Option<f64>,
169    /// Flesch-Kincaid readability index for the page text.
170    pub flesch_kincaid_readability_index: Option<f64>,
171    /// SMOG readability index for the page text.
172    pub smog_readability_index: Option<f64>,
173    /// Consistency of the meta description with page content (0 to 1).
174    pub description_to_content_consistency: Option<f64>,
175    /// Consistency of the meta title with page content (0 to 1).
176    pub title_to_content_consistency: Option<f64>,
177    /// Consistency of the meta keywords with page content (0 to 1).
178    pub meta_keywords_to_content_consistency: Option<f64>,
179}
180
181/// Page load timing metrics, in milliseconds.
182/// See <https://docs.dataforseo.com/v3/on_page/instant_pages/>.
183#[derive(Debug, Default, Serialize, Deserialize, Clone)]
184pub struct OnPageDataApiInstantPagesPageTiming {
185    /// Time until the user can interact with the page, in milliseconds.
186    pub time_to_interactive: Option<i64>,
187    /// Time until the page and its subresources finish loading, in milliseconds.
188    pub dom_complete: Option<i64>,
189    /// Largest Contentful Paint Core Web Vitals metric, in milliseconds.
190    pub largest_contentful_paint: Option<f64>,
191    /// First Input Delay Core Web Vitals metric, in milliseconds.
192    pub first_input_delay: Option<f64>,
193    /// Time to establish a connection to the server, in milliseconds.
194    pub connection_time: Option<i64>,
195    /// Time to establish a secure connection, in milliseconds.
196    pub time_to_secure_connection: Option<i64>,
197    /// Time to send the request to the server, in milliseconds.
198    pub request_sent_time: Option<i64>,
199    /// Time to first byte (TTFB), in milliseconds.
200    pub waiting_time: Option<i64>,
201    /// Time for the browser to receive the response, in milliseconds.
202    pub download_time: Option<i64>,
203    /// Total time for the complete response from the server, in milliseconds.
204    pub duration_time: Option<i64>,
205    /// Time to start downloading the HTML resource, in milliseconds.
206    pub fetch_start: Option<i64>,
207    /// Time to finish downloading the HTML resource, in milliseconds.
208    pub fetch_end: Option<i64>,
209}
210
211/// Cache-control directives for an analyzed page.
212/// See <https://docs.dataforseo.com/v3/on_page/instant_pages/>.
213#[derive(Debug, Default, Serialize, Deserialize, Clone)]
214pub struct OnPageDataApiInstantPagesCacheControl {
215    /// Whether the page or resource is cacheable.
216    pub cachable: Option<bool>,
217    /// Browser cache lifetime (time to live), in milliseconds.
218    pub ttl: Option<i64>,
219}
220
221/// Resource loading errors and warnings for an analyzed page.
222/// See <https://docs.dataforseo.com/v3/on_page/instant_pages/>.
223#[derive(Debug, Default, Serialize, Deserialize, Clone)]
224pub struct OnPageDataApiInstantPagesResourceErrors {
225    /// Parsing errors, each with line, column, message, and status code.
226    pub errors: Option<Vec<Value>>,
227    /// Warnings (e.g. node nesting, DOM size, HTML depth) with line, column, message, and status code.
228    pub warnings: Option<Vec<Value>>,
229}
230
231/// Last-modification dates reported for an analyzed page, in UTC.
232/// See <https://docs.dataforseo.com/v3/on_page/instant_pages/>.
233#[derive(Debug, Default, Serialize, Deserialize, Clone)]
234pub struct OnPageDataApiInstantPagesLastModified {
235    /// Last-modification date from the HTTP header; `null` if unavailable.
236    pub header: Option<String>,
237    /// Last-modification date from the sitemap; `null` if unavailable.
238    pub sitemap: Option<String>,
239    /// Last-modification date from a meta tag; `null` if unavailable.
240    pub meta_tag: Option<String>,
241}