data_for_seo/api/keywords_data/
mod.rs1mod bing;
2mod clickstream_data;
3mod dataforseo_trends;
4mod google_ads;
5mod google_trends;
6
7use crate::{DataForSeoApiResponse, DataForSeoClient};
8use serde::{Deserialize, Serialize};
9
10pub use bing::*;
11pub use clickstream_data::*;
12pub use dataforseo_trends::*;
13pub use google_ads::*;
14pub use google_trends::*;
15
16pub struct KeywordsDataApi<'a> {
18 client: &'a DataForSeoClient,
19}
20
21impl DataForSeoClient {
22 pub fn keywords_data(&self) -> KeywordsDataApi<'_> {
25 KeywordsDataApi { client: self }
26 }
27}
28
29impl KeywordsDataApi<'_> {
30 pub async fn locations(&self) -> DataForSeoApiResponse<KeywordsDataApiLocation> {
32 self.client.http_get("/v3/keywords_data/locations").await
33 }
34 pub async fn locations_se(&self, se: &str) -> DataForSeoApiResponse<KeywordsDataApiLocation> {
36 self.client
37 .http_get(format!("/v3/keywords_data/{}/locations", se).as_str())
38 .await
39 }
40 pub async fn locations_country(
42 &self,
43 country: &str,
44 ) -> DataForSeoApiResponse<KeywordsDataApiLocation> {
45 self.client
46 .http_get(format!("/v3/keywords_data/locations/{}", country).as_str())
47 .await
48 }
49 pub async fn locations_country_se(
51 &self,
52 se: &str,
53 country: &str,
54 ) -> DataForSeoApiResponse<KeywordsDataApiLocation> {
55 self.client
56 .http_get(format!("/v3/keywords_data/{}/locations/{}", se, country).as_str())
57 .await
58 }
59 pub async fn task_ready(&self) -> DataForSeoApiResponse<KeywordsDataApiTaskReadyResult> {
61 self.client.http_get("/v3/keywords_data/tasks_ready").await
62 }
63 pub async fn task_ready_se(
65 &self,
66 se: &str,
67 ) -> DataForSeoApiResponse<KeywordsDataApiTaskReadyResult> {
68 self.client
69 .http_get(format!("/v3/keywords_data/{}/tasks_ready", se).as_str())
70 .await
71 }
72 pub async fn task_fixed(&self) -> DataForSeoApiResponse<KeywordsDataApiTaskReadyResult> {
74 self.client.http_get("/v3/keywords_data/tasks_fixed").await
75 }
76 pub async fn task_fixed_se(
78 &self,
79 se: &str,
80 ) -> DataForSeoApiResponse<KeywordsDataApiTaskReadyResult> {
81 self.client
82 .http_get(format!("/v3/keywords_data/{}/tasks_fixed", se).as_str())
83 .await
84 }
85}
86
87#[derive(Debug, Default, Serialize, Deserialize, Clone)]
90pub struct KeywordsDataApiTaskReadyResult {
91 pub id: Option<String>,
93 pub se: Option<String>,
95 pub se_type: Option<String>,
97 pub date_posted: Option<String>,
99 pub tag: Option<String>,
101 pub endpoint_regular: Option<String>,
103 pub endpoint_advanced: Option<String>,
105 pub endpoint_html: Option<String>,
107}
108
109#[derive(Debug, Default, Serialize, Deserialize, Clone)]
112pub struct KeywordsDataApiLocation {
113 pub location_code: Option<i32>,
115 pub location_name: Option<String>,
117 pub location_code_parent: Option<i32>,
119 pub country_iso_code: Option<String>,
121 pub location_type: Option<String>,
123}