data_for_seo/api/keywords_data/
mod.rs

1mod google_ads;
2
3use crate::{DataForSeoApiResponse, DataForSeoClient};
4use serde::{Deserialize, Serialize};
5
6pub use google_ads::*;
7pub struct KeywordsDataApi<'a> {
8    client: &'a DataForSeoClient,
9}
10
11impl DataForSeoClient {
12    /// https://docs.dataforseo.com/v3/keywords_data/overview/?bash
13    pub fn keywords_data(&self) -> KeywordsDataApi {
14        KeywordsDataApi { client: self }
15    }
16}
17
18impl KeywordsDataApi<'_> {
19    pub async fn locations(&self) -> DataForSeoApiResponse<KeywordsDataApiLocation> {
20        self.client
21            .http_get("https://api.dataforseo.com/v3/keywords_data/locations", &{})
22            .await
23    }
24    pub async fn locations_se(&self, se: &str) -> DataForSeoApiResponse<KeywordsDataApiLocation> {
25        self.client
26            .http_get(
27                format!(
28                    "https://api.dataforseo.com/v3/keywords_data/{}/locations",
29                    se
30                )
31                .as_str(),
32                &{},
33            )
34            .await
35    }
36    pub async fn locations_country(
37        &self,
38        country: &str,
39    ) -> DataForSeoApiResponse<KeywordsDataApiLocation> {
40        self.client
41            .http_get(
42                format!(
43                    "https://api.dataforseo.com/v3/keywords_data/locations/{}",
44                    country
45                )
46                .as_str(),
47                &{},
48            )
49            .await
50    }
51    pub async fn locations_country_se(
52        &self,
53        se: &str,
54        country: &str,
55    ) -> DataForSeoApiResponse<KeywordsDataApiLocation> {
56        self.client
57            .http_get(
58                format!(
59                    "https://api.dataforseo.com/v3/keywords_data/{}/locations/{}",
60                    se, country
61                )
62                .as_str(),
63                &{},
64            )
65            .await
66    }
67    pub async fn task_ready(&self) -> DataForSeoApiResponse<KeywordsDataApiTaskReadyResult> {
68        self.client
69            .http_get(
70                "https://api.dataforseo.com/v3/keywords_data/tasks_ready",
71                &{},
72            )
73            .await
74    }
75    pub async fn task_ready_se(
76        &self,
77        se: &str,
78    ) -> DataForSeoApiResponse<KeywordsDataApiTaskReadyResult> {
79        self.client
80            .http_get(
81                format!(
82                    "https://api.dataforseo.com/v3/keywords_data/{}/tasks_ready",
83                    se
84                )
85                .as_str(),
86                &{},
87            )
88            .await
89    }
90    pub async fn task_fixed(&self) -> DataForSeoApiResponse<KeywordsDataApiTaskReadyResult> {
91        self.client
92            .http_get(
93                "https://api.dataforseo.com/v3/keywords_data/tasks_fixed",
94                &{},
95            )
96            .await
97    }
98    pub async fn task_fixed_se(
99        &self,
100        se: &str,
101    ) -> DataForSeoApiResponse<KeywordsDataApiTaskReadyResult> {
102        self.client
103            .http_get(
104                format!(
105                    "https://api.dataforseo.com/v3/keywords_data/{}/tasks_fixed",
106                    se
107                )
108                .as_str(),
109                &{},
110            )
111            .await
112    }
113}
114
115#[derive(Debug, Default, Serialize, Deserialize, Clone)]
116pub struct KeywordsDataApiTaskReadyResult {
117    id: Option<String>,
118    se: Option<String>,
119    se_type: Option<String>,
120    date_posted: Option<String>,
121    tag: Option<String>,
122    endpoint_regular: Option<String>,
123    endpoint_advanced: Option<String>,
124    endpoint_html: Option<String>,
125}
126
127#[derive(Debug, Default, Serialize, Deserialize, Clone)]
128pub struct KeywordsDataApiLocation {
129    pub location_code: Option<i32>,
130    pub location_name: Option<String>,
131    pub location_code_parent: Option<i32>,
132    pub country_iso_code: Option<String>,
133    pub location_type: Option<String>,
134}