Skip to main content

data_for_seo/entity/dataforseo_labs/
amazon.rs

1//! Amazon-specific item models for the DataForSEO Labs API.
2
3use crate::entity::{DataForSeoLabsKeywordData, DataForSeoLabsMonthlySearch};
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7/// One keyword an Amazon product (ASIN) ranks for.
8/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/ranked_keywords/live/>.
9#[derive(Debug, Default, Serialize, Deserialize, Clone)]
10pub struct DataForSeoLabsAmazonRankedKeywordItem {
11    /// Search engine type (e.g. `"google"`).
12    pub se_type: Option<String>,
13    /// The ranked SERP position the target holds for this keyword.
14    pub ranked_serp_element: Option<DataForSeoLabsAmazonRankedSerpElement>,
15    /// Keyword metrics for the returned keyword.
16    pub keyword_data: Option<DataForSeoLabsKeywordData>,
17}
18
19/// A ranked position on the Amazon SERP, wrapping the product item.
20/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/ranked_keywords/live/>.
21#[derive(Debug, Default, Serialize, Deserialize, Clone)]
22pub struct DataForSeoLabsAmazonRankedSerpElement {
23    /// Search engine type (e.g. `"google"`).
24    pub se_type: Option<String>,
25    /// The SERP element occupying this ranked position.
26    pub serp_item: Option<DataForSeoLabsAmazonSerpItem>,
27    /// URL used to check the SERP.
28    pub check_url: Option<String>,
29    /// Timestamp when this data was last updated (UTC).
30    pub last_updated_time: Option<String>,
31}
32
33/// A single product listing on the Amazon SERP.
34/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/ranked_keywords/live/>.
35#[derive(Debug, Default, Serialize, Deserialize, Clone)]
36pub struct DataForSeoLabsAmazonSerpItem {
37    /// Search engine type (e.g. `"google"`).
38    pub se_type: Option<String>,
39    /// Type of SERP element (serialized as `type`).
40    #[serde(rename = "type")]
41    pub item_type: Option<String>,
42    /// Rank within elements of the same type.
43    pub rank_group: Option<i64>,
44    /// Absolute rank among all SERP elements.
45    pub rank_absolute: Option<i64>,
46    /// Domain of the result.
47    pub domain: Option<String>,
48    /// Title of the result.
49    pub title: Option<String>,
50    /// URL of the result (for an id-list entry, the endpoint the task was posted to).
51    pub url: Option<String>,
52    /// Amazon product identifier (ASIN).
53    pub asin: Option<String>,
54    /// Lowest listed price, in `currency`.
55    pub price_from: Option<f64>,
56    /// Highest listed price, in `currency`.
57    pub price_to: Option<f64>,
58    /// ISO currency code of the prices.
59    pub currency: Option<String>,
60    /// Star rating of the product or app.
61    pub rating: Option<DataForSeoLabsAmazonRating>,
62    /// Whether the product carries the Best Seller badge.
63    pub is_best_seller: Option<bool>,
64    /// Whether the product carries the Amazon's Choice badge.
65    pub is_amazon_choice: Option<bool>,
66}
67
68/// Star rating of an Amazon product.
69/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/ranked_keywords/live/>.
70#[derive(Debug, Default, Serialize, Deserialize, Clone)]
71pub struct DataForSeoLabsAmazonRating {
72    /// Type of the rating.
73    pub rating_type: Option<String>,
74    /// Rating value (e.g. average number of stars).
75    pub value: Option<f64>,
76    /// Number of ratings.
77    pub votes_count: Option<i64>,
78    /// Maximum possible rating value.
79    pub rating_max: Option<i64>,
80}
81
82/// A keyword with its Amazon search volume.
83/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/bulk_search_volume/live/>.
84#[derive(Debug, Default, Serialize, Deserialize, Clone)]
85pub struct DataForSeoLabsAmazonSearchVolumeItem {
86    /// Search engine type (e.g. `"google"`).
87    pub se_type: Option<String>,
88    /// Keyword the data relates to.
89    pub keyword: Option<String>,
90    /// Google Ads keyword metrics.
91    pub keyword_info: Option<DataForSeoLabsAmazonKeywordInfo>,
92}
93
94/// Amazon keyword metrics (a reduced set compared to Google).
95/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/bulk_search_volume/live/>.
96#[derive(Debug, Default, Serialize, Deserialize, Clone)]
97pub struct DataForSeoLabsAmazonKeywordInfo {
98    /// Search engine type (e.g. `"google"`).
99    pub se_type: Option<String>,
100    /// Timestamp when this data was last updated (UTC).
101    pub last_updated_time: Option<String>,
102    /// Average monthly search volume.
103    pub search_volume: Option<i64>,
104    /// Search volume for each of the preceding months.
105    pub monthly_searches: Option<Vec<DataForSeoLabsMonthlySearch>>,
106}
107
108/// One keyword related to a seed keyword on Amazon.
109/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/related_keywords/live/>.
110#[derive(Debug, Default, Serialize, Deserialize, Clone)]
111pub struct DataForSeoLabsAmazonRelatedKeywordItem {
112    /// Search engine type (e.g. `"google"`).
113    pub se_type: Option<String>,
114    /// Keyword metrics for the returned keyword.
115    pub keyword_data: Option<DataForSeoLabsKeywordData>,
116    /// Keyword expansion depth (0-4); higher values return more keywords.
117    pub depth: Option<i64>,
118    /// Keywords related to this keyword.
119    pub related_keywords: Option<Vec<String>>,
120}
121
122/// A competing Amazon product (ASIN) and its ranking metrics.
123/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/product_competitors/live/>.
124#[derive(Debug, Default, Serialize, Deserialize, Clone)]
125pub struct DataForSeoLabsAmazonProductCompetitorItem {
126    /// Search engine type (e.g. `"google"`).
127    pub se_type: Option<String>,
128    /// Amazon product identifier (ASIN).
129    pub asin: Option<String>,
130    /// Average SERP position across intersecting keywords.
131    pub avg_position: Option<f64>,
132    /// Sum of SERP positions across intersecting keywords.
133    pub sum_position: Option<i64>,
134    /// Number of keywords the targets have in common.
135    pub intersections: Option<i64>,
136    /// Metrics limited to keywords shared with the target.
137    pub competitor_metrics: Option<DataForSeoLabsAmazonMetrics>,
138    /// Metrics across all of the app's keywords.
139    pub full_metrics: Option<DataForSeoLabsAmazonMetrics>,
140}
141
142/// Ranking metrics of an Amazon product in one location/language.
143/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/product_rank_overview/live/>.
144#[derive(Debug, Default, Serialize, Deserialize, Clone)]
145pub struct DataForSeoLabsAmazonProductRankOverviewItem {
146    /// Search engine type (e.g. `"google"`).
147    pub se_type: Option<String>,
148    /// Location code (e.g. `2840`); alternative to `location_name`.
149    pub location_code: Option<i32>,
150    /// Language code (e.g. `"en"`); alternative to `language_name`.
151    pub language_code: Option<String>,
152    /// Ranking and traffic metrics, grouped by SERP feature type.
153    pub metrics: Option<DataForSeoLabsAmazonMetrics>,
154}
155
156/// Amazon ranking metrics grouped by SERP feature type.
157/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/product_competitors/live/>.
158#[derive(Debug, Default, Serialize, Deserialize, Clone)]
159pub struct DataForSeoLabsAmazonMetrics {
160    /// Metrics for Amazon organic results.
161    pub amazon_serp: Option<DataForSeoLabsAmazonMetricsInfo>,
162    /// Metrics for Amazon sponsored results.
163    pub amazon_paid: Option<DataForSeoLabsAmazonMetricsInfo>,
164}
165
166/// Amazon ranking metrics for one SERP feature type.
167/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/product_competitors/live/>.
168#[derive(Debug, Default, Serialize, Deserialize, Clone)]
169pub struct DataForSeoLabsAmazonMetricsInfo {
170    /// Number of SERPs where the target ranks #1.
171    pub pos_1: Option<i64>,
172    /// Number of SERPs where the target ranks #2-3.
173    pub pos_2_3: Option<i64>,
174    /// Number of SERPs where the target ranks #4-10.
175    pub pos_4_10: Option<i64>,
176    /// Number of SERPs where the target ranks #11-100.
177    pub pos_11_100: Option<i64>,
178    /// Number of SERPs containing the target for this feature type.
179    pub count: Option<i64>,
180    /// Average monthly search volume.
181    pub search_volume: Option<i64>,
182}
183
184/// A keyword and the Amazon SERP element each analyzed product holds for it.
185/// `intersection_result` is keyed by the asins-map keys from the request.
186/// See <https://docs.dataforseo.com/v3/dataforseo_labs/amazon/product_keyword_intersections/live/>.
187#[derive(Debug, Default, Serialize, Deserialize, Clone)]
188pub struct DataForSeoLabsAmazonProductKeywordIntersectionItem {
189    /// Search engine type (e.g. `"google"`).
190    pub se_type: Option<String>,
191    /// Keyword metrics for the returned keyword.
192    pub keyword_data: Option<DataForSeoLabsKeywordData>,
193    /// SERP element each analyzed target holds for the keyword, keyed by target.
194    pub intersection_result: Option<HashMap<String, DataForSeoLabsAmazonSerpItem>>,
195}