scrapfly_sdk/result/classify.rs
1//! Classify request + result types.
2//!
3//! Mirrors the `POST /classify` wire contract. See
4//! <https://scrapfly.io/docs/scrape-api/classify>.
5
6use std::collections::HashMap;
7
8use serde::{Deserialize, Serialize};
9
10/// Describes an HTTP response to classify.
11#[derive(Debug, Clone, Serialize)]
12pub struct ClassifyRequest {
13 /// Final URL the response came from.
14 pub url: String,
15 /// HTTP status code (100-599) of the response.
16 pub status_code: u16,
17 /// Response headers (case-insensitive).
18 #[serde(skip_serializing_if = "Option::is_none")]
19 pub headers: Option<HashMap<String, String>>,
20 /// Response body as text. Binary bodies should be passed as empty/None.
21 #[serde(skip_serializing_if = "Option::is_none")]
22 pub body: Option<String>,
23 /// HTTP method the caller used. Defaults to `GET` server-side.
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub method: Option<String>,
26}
27
28/// `POST /classify` response.
29#[derive(Debug, Clone, Deserialize, Default)]
30pub struct ClassifyResult {
31 /// `true` when Scrapfly detected an anti-bot block on the upstream response.
32 #[serde(default)]
33 pub blocked: bool,
34 /// Name of the anti-bot product that matched, when one was detected.
35 #[serde(default)]
36 pub antibot: Option<String>,
37 /// API credits charged for this call.
38 #[serde(default)]
39 pub cost: u32,
40}