data_for_seo/api/serp/
mod.rs1use crate::{DataForSeoApiResponse, DataForSeoClient};
2use serde::{Deserialize, Serialize};
3
4mod baidu;
5mod bing;
6mod google;
7mod naver;
8mod seznam;
9mod yahoo;
10mod youtube;
11
12pub use baidu::*;
13pub use bing::*;
14pub use google::*;
15pub use naver::*;
16pub use seznam::*;
17pub use yahoo::*;
18pub use youtube::*;
19
20pub struct SerpApi<'a> {
22 client: &'a DataForSeoClient,
23}
24
25impl DataForSeoClient {
26 pub fn serp(&self) -> SerpApi<'_> {
29 SerpApi { client: self }
30 }
31}
32
33impl SerpApi<'_> {
34 pub async fn locations(&self) -> DataForSeoApiResponse<SerpApiLocation> {
36 self.client.http_get("/v3/serp/locations").await
37 }
38 pub async fn locations_se(&self, se: &str) -> DataForSeoApiResponse<SerpApiLocation> {
40 self.client
41 .http_get(format!("/v3/serp/{}/locations", se).as_str())
42 .await
43 }
44 pub async fn locations_country(&self, country: &str) -> DataForSeoApiResponse<SerpApiLocation> {
46 self.client
47 .http_get(format!("/v3/serp/locations/{}", country).as_str())
48 .await
49 }
50 pub async fn locations_country_se(
52 &self,
53 se: &str,
54 country: &str,
55 ) -> DataForSeoApiResponse<SerpApiLocation> {
56 self.client
57 .http_get(format!("/v3/serp/{}/locations/{}", se, country).as_str())
58 .await
59 }
60 pub async fn task_ready(&self) -> DataForSeoApiResponse<SerpApiTaskReadyResult> {
62 self.client.http_get("/v3/serp/tasks_ready").await
63 }
64 pub async fn task_ready_se(&self, se: &str) -> DataForSeoApiResponse<SerpApiTaskReadyResult> {
66 self.client
67 .http_get(format!("/v3/serp/{}/tasks_ready", se).as_str())
68 .await
69 }
70 pub async fn task_fixed(&self) -> DataForSeoApiResponse<SerpApiTaskReadyResult> {
72 self.client.http_get("/v3/serp/tasks_fixed").await
73 }
74 pub async fn task_fixed_se(&self, se: &str) -> DataForSeoApiResponse<SerpApiTaskReadyResult> {
76 self.client
77 .http_get(format!("/v3/serp/{}/tasks_fixed", se).as_str())
78 .await
79 }
80}
81
82#[derive(Debug, Default, Serialize, Deserialize, Clone)]
85pub struct SerpApiTaskReadyResult {
86 pub id: Option<String>,
88 pub se: Option<String>,
90 pub se_type: Option<String>,
92 pub date_posted: Option<String>,
94 pub tag: Option<String>,
96 pub endpoint_regular: Option<String>,
98 pub endpoint_advanced: Option<String>,
100 pub endpoint_html: Option<String>,
102}
103
104#[derive(Debug, Default, Serialize, Deserialize, Clone)]
106pub struct SerpApiLocation {
107 pub location_code: Option<i32>,
109 pub location_name: Option<String>,
111 pub location_code_parent: Option<i32>,
113 pub country_iso_code: Option<String>,
115 pub location_type: Option<String>,
117}