Skip to main content

data_for_seo/entity/ai_optimization/
common.rs

1//! Shared models used across the AI Optimization sub-APIs.
2//!
3//! See <https://docs.dataforseo.com/v3/ai_optimization/overview/>.
4
5use serde::{Deserialize, Serialize};
6
7/// A language available for a location.
8#[derive(Debug, Default, Serialize, Deserialize, Clone)]
9pub struct AiOptimizationLanguage {
10    /// Full name of the language (e.g. `"English"`).
11    pub language_name: Option<String>,
12    /// ISO 639-1 language code (e.g. `"en"`).
13    pub language_code: Option<String>,
14}
15
16/// A supported location together with the languages available for it.
17///
18/// Returned by the `locations_and_languages` endpoints of AI Keyword Data and
19/// LLM Mentions.
20#[derive(Debug, Default, Serialize, Deserialize, Clone)]
21pub struct AiOptimizationLocationLanguage {
22    /// DataForSEO location code (e.g. `2840` for the United States).
23    pub location_code: Option<i32>,
24    /// Full name of the location (e.g. `"United States"`).
25    pub location_name: Option<String>,
26    /// Languages supported for this location.
27    pub available_languages: Option<Vec<AiOptimizationLanguage>>,
28}
29
30/// A supported location for the LLM Scraper (standard SERP location shape).
31#[derive(Debug, Default, Serialize, Deserialize, Clone)]
32pub struct AiOptimizationScraperLocation {
33    /// DataForSEO location code.
34    pub location_code: Option<i32>,
35    /// Full name of the location.
36    pub location_name: Option<String>,
37    /// Location code of the parent location, if any.
38    pub location_code_parent: Option<i32>,
39    /// ISO 3166-1 alpha-2 country code the location belongs to.
40    pub country_iso_code: Option<String>,
41    /// Type of the location (e.g. `"Country"`, `"City"`).
42    pub location_type: Option<String>,
43}
44
45/// Monthly search-volume data point.
46///
47/// Covers both AI Keyword Data (`ai_monthly_searches`) and LLM Mentions
48/// (`monthly_searches`); only the relevant fields are populated per endpoint.
49#[derive(Debug, Default, Serialize, Deserialize, Clone)]
50pub struct AiOptimizationMonthlySearch {
51    /// Year the data point refers to.
52    pub year: Option<i32>,
53    /// Month the data point refers to (`1`–`12`).
54    pub month: Option<i32>,
55    /// AI search volume for the month.
56    pub ai_search_volume: Option<f64>,
57    /// Classic search volume for the month, when provided.
58    pub search_volume: Option<i64>,
59}
60
61/// A single queued task returned by a `tasks_ready` endpoint.
62///
63/// See <https://docs.dataforseo.com/v3/ai_optimization/chat_gpt/llm_responses/tasks_ready/>.
64#[derive(Debug, Default, Serialize, Deserialize, Clone)]
65pub struct AiOptimizationTaskReady {
66    /// Task identifier used to collect the result via `task_get`.
67    pub id: Option<String>,
68    /// Search engine the task belongs to.
69    pub se: Option<String>,
70    /// Function name of the task.
71    pub function: Option<String>,
72    /// Relative endpoint to fetch the completed result.
73    pub endpoint: Option<String>,
74    /// Relative endpoint to fetch the parsed (advanced) result, for scraper tasks.
75    pub endpoint_advanced: Option<String>,
76    /// Relative endpoint to fetch the raw HTML result, for scraper tasks.
77    pub endpoint_html: Option<String>,
78    /// UTC timestamp at which the task was queued.
79    pub date_posted: Option<String>,
80    /// User-defined identifier echoed from the task request.
81    pub tag: Option<String>,
82}