bytekit-sdk 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bytekit/__init__.py +8 -0
- bytekit/api/__init__.py +1 -0
- bytekit/api/account/__init__.py +1 -0
- bytekit/api/account/get_account.py +157 -0
- bytekit/api/bulk/__init__.py +1 -0
- bytekit/api/bulk/create_bulk.py +204 -0
- bytekit/api/bulk/delete_bulk.py +177 -0
- bytekit/api/bulk/get_bulk.py +157 -0
- bytekit/api/bulk/list_bulk_screenshots.py +152 -0
- bytekit/api/fetch/__init__.py +1 -0
- bytekit/api/fetch/get_fetch.py +254 -0
- bytekit/api/fetch/post_fetch.py +178 -0
- bytekit/api/fetch_bulk/__init__.py +1 -0
- bytekit/api/fetch_bulk/create_fetch_bulk.py +180 -0
- bytekit/api/fetch_bulk/get_fetch_bulk.py +157 -0
- bytekit/api/monitors/__init__.py +1 -0
- bytekit/api/monitors/create_monitor.py +180 -0
- bytekit/api/monitors/delete_monitor.py +155 -0
- bytekit/api/monitors/get_monitor.py +157 -0
- bytekit/api/monitors/list_monitor_captures.py +188 -0
- bytekit/api/monitors/list_monitors.py +193 -0
- bytekit/api/monitors/update_monitor.py +191 -0
- bytekit/api/scrape/__init__.py +1 -0
- bytekit/api/scrape/create_scrape.py +197 -0
- bytekit/api/scrape/get_scrape.py +231 -0
- bytekit/api/scrape_bulk/__init__.py +1 -0
- bytekit/api/scrape_bulk/create_scrape_bulk.py +188 -0
- bytekit/api/scrape_bulk/get_scrape_bulk.py +157 -0
- bytekit/api/screenshots/__init__.py +1 -0
- bytekit/api/screenshots/create_screenshot.py +208 -0
- bytekit/api/screenshots/get_screenshot.py +177 -0
- bytekit/api/search/__init__.py +1 -0
- bytekit/api/search/create_search.py +225 -0
- bytekit/api/sitemap/__init__.py +1 -0
- bytekit/api/sitemap/create_sitemap.py +192 -0
- bytekit/api/sitemap/get_sitemap.py +157 -0
- bytekit/api/usage/__init__.py +1 -0
- bytekit/api/usage/get_usage.py +126 -0
- bytekit/api/usage/get_usage_by_endpoint.py +215 -0
- bytekit/api/usage/get_usage_daily.py +203 -0
- bytekit/api/webhooks/__init__.py +1 -0
- bytekit/api/webhooks/list_webhook_deliveries.py +214 -0
- bytekit/api/webhooks/retry_webhook_delivery.py +165 -0
- bytekit/client.py +418 -0
- bytekit/errors.py +18 -0
- bytekit/models/__init__.py +401 -0
- bytekit/models/account_bearer_response.py +207 -0
- bytekit/models/account_bearer_response_api_key.py +134 -0
- bytekit/models/account_bearer_response_api_key_environment.py +8 -0
- bytekit/models/account_bearer_response_auto_topup.py +83 -0
- bytekit/models/account_bearer_response_plan.py +150 -0
- bytekit/models/account_bearer_response_subscription.py +85 -0
- bytekit/models/account_bearer_response_subscription_plan.py +99 -0
- bytekit/models/account_bearer_response_subscription_status.py +10 -0
- bytekit/models/account_session_response.py +164 -0
- bytekit/models/account_session_response_notifications.py +51 -0
- bytekit/models/account_session_response_plan.py +150 -0
- bytekit/models/bandwidth_balance.py +91 -0
- bytekit/models/capture_response.py +216 -0
- bytekit/models/capture_response_outcome.py +10 -0
- bytekit/models/clip.py +83 -0
- bytekit/models/cookie.py +90 -0
- bytekit/models/create_bulk_body.py +155 -0
- bytekit/models/create_bulk_body_defaults.py +423 -0
- bytekit/models/create_bulk_body_defaults_device.py +9 -0
- bytekit/models/create_bulk_body_defaults_device_scale_factor_type_1.py +9 -0
- bytekit/models/create_bulk_body_defaults_device_scale_factor_type_2_type_1.py +9 -0
- bytekit/models/create_bulk_body_defaults_device_scale_factor_type_3_type_1.py +9 -0
- bytekit/models/create_bulk_body_defaults_formats_item.py +12 -0
- bytekit/models/create_bulk_body_defaults_type.py +9 -0
- bytekit/models/create_bulk_body_defaults_viewport_type_0.py +67 -0
- bytekit/models/create_bulk_body_defaults_wait_until.py +10 -0
- bytekit/models/create_bulk_body_items_item.py +380 -0
- bytekit/models/create_bulk_body_items_item_device.py +9 -0
- bytekit/models/create_bulk_body_items_item_formats_item.py +12 -0
- bytekit/models/create_bulk_body_items_item_scenario.py +10 -0
- bytekit/models/create_bulk_body_items_item_type.py +9 -0
- bytekit/models/create_bulk_body_items_item_viewport_type_0.py +67 -0
- bytekit/models/create_bulk_body_items_item_wait_until.py +10 -0
- bytekit/models/create_bulk_response_202.py +164 -0
- bytekit/models/create_bulk_response_202_status.py +10 -0
- bytekit/models/create_fetch_bulk_body.py +161 -0
- bytekit/models/create_fetch_bulk_body_defaults.py +91 -0
- bytekit/models/create_fetch_bulk_body_defaults_format.py +9 -0
- bytekit/models/create_fetch_bulk_body_metadata.py +44 -0
- bytekit/models/create_fetch_bulk_body_urls_item_type_1.py +102 -0
- bytekit/models/create_fetch_bulk_body_urls_item_type_1_format.py +9 -0
- bytekit/models/create_fetch_bulk_response_202.py +44 -0
- bytekit/models/create_scrape_bulk_body.py +179 -0
- bytekit/models/create_scrape_bulk_body_custom.py +52 -0
- bytekit/models/create_scrape_bulk_body_defaults.py +167 -0
- bytekit/models/create_scrape_bulk_body_defaults_formats_item.py +12 -0
- bytekit/models/create_scrape_bulk_body_defaults_headers.py +44 -0
- bytekit/models/create_scrape_bulk_body_items_item.py +226 -0
- bytekit/models/create_scrape_bulk_body_items_item_custom.py +50 -0
- bytekit/models/create_scrape_bulk_body_items_item_formats_item.py +12 -0
- bytekit/models/create_scrape_bulk_body_items_item_headers.py +44 -0
- bytekit/models/create_scrape_bulk_body_items_item_metadata.py +44 -0
- bytekit/models/create_scrape_bulk_response_202.py +166 -0
- bytekit/models/create_scrape_bulk_response_202_status.py +10 -0
- bytekit/models/create_search_body.py +140 -0
- bytekit/models/create_search_body_date_range.py +13 -0
- bytekit/models/create_search_body_type.py +10 -0
- bytekit/models/create_search_response_200.py +119 -0
- bytekit/models/create_search_response_200_results_item.py +161 -0
- bytekit/models/create_search_response_200_results_item_image.py +113 -0
- bytekit/models/create_search_response_502.py +46 -0
- bytekit/models/create_search_response_502_error.py +8 -0
- bytekit/models/credit_balance.py +91 -0
- bytekit/models/delete_bulk_response_200.py +164 -0
- bytekit/models/delete_bulk_response_200_status.py +11 -0
- bytekit/models/error.py +83 -0
- bytekit/models/error_error.py +100 -0
- bytekit/models/error_status.py +8 -0
- bytekit/models/fetch_request.py +276 -0
- bytekit/models/fetch_request_cache_ttl_type_1.py +8 -0
- bytekit/models/fetch_request_custom.py +48 -0
- bytekit/models/fetch_request_format.py +9 -0
- bytekit/models/fetch_request_markdown_images.py +11 -0
- bytekit/models/fetch_request_markdown_links.py +11 -0
- bytekit/models/fetch_request_markdown_mode.py +10 -0
- bytekit/models/get_bulk_response_200.py +164 -0
- bytekit/models/get_bulk_response_200_status.py +11 -0
- bytekit/models/get_fetch_bulk_response_200.py +44 -0
- bytekit/models/get_fetch_cache_ttl_type_1.py +8 -0
- bytekit/models/get_fetch_format.py +9 -0
- bytekit/models/get_scrape_bulk_response_200.py +164 -0
- bytekit/models/get_scrape_bulk_response_200_status.py +11 -0
- bytekit/models/get_usage_by_endpoint_response_200.py +114 -0
- bytekit/models/get_usage_by_endpoint_response_200_rows_item.py +90 -0
- bytekit/models/get_usage_by_endpoint_response_200_rows_item_endpoint.py +17 -0
- bytekit/models/get_usage_by_endpoint_response_200_totals.py +67 -0
- bytekit/models/get_usage_daily_response_200.py +97 -0
- bytekit/models/get_usage_daily_response_200_data_item.py +219 -0
- bytekit/models/get_usage_response_200.py +344 -0
- bytekit/models/get_usage_response_200_plan_type.py +10 -0
- bytekit/models/list_bulk_screenshots_response_200.py +44 -0
- bytekit/models/list_monitor_captures_response_200.py +101 -0
- bytekit/models/list_monitors_response_200.py +101 -0
- bytekit/models/list_monitors_status.py +12 -0
- bytekit/models/list_webhook_deliveries_response_200.py +101 -0
- bytekit/models/list_webhook_deliveries_status.py +11 -0
- bytekit/models/metadata.py +44 -0
- bytekit/models/monitor_create_request.py +219 -0
- bytekit/models/monitor_create_request_interval_type.py +11 -0
- bytekit/models/monitor_create_request_notify_on.py +9 -0
- bytekit/models/monitor_create_request_options.py +44 -0
- bytekit/models/monitor_create_request_scrape_options.py +44 -0
- bytekit/models/monitor_create_request_type.py +9 -0
- bytekit/models/monitor_create_request_webhook_headers.py +44 -0
- bytekit/models/monitor_create_response.py +423 -0
- bytekit/models/monitor_response.py +411 -0
- bytekit/models/monitor_response_interval_type.py +11 -0
- bytekit/models/monitor_response_metadata_type_0.py +44 -0
- bytekit/models/monitor_response_status.py +12 -0
- bytekit/models/monitor_response_type.py +9 -0
- bytekit/models/monitor_response_webhook_headers_type_0.py +44 -0
- bytekit/models/monitor_update_request.py +223 -0
- bytekit/models/monitor_update_request_interval_type.py +11 -0
- bytekit/models/monitor_update_request_notify_on.py +9 -0
- bytekit/models/monitor_update_request_options.py +44 -0
- bytekit/models/monitor_update_request_scrape_options.py +44 -0
- bytekit/models/monitor_update_request_status.py +9 -0
- bytekit/models/monitor_update_request_webhook_headers.py +44 -0
- bytekit/models/scrape_error_envelope.py +113 -0
- bytekit/models/scrape_error_envelope_error.py +93 -0
- bytekit/models/scrape_error_envelope_error_code.py +18 -0
- bytekit/models/scrape_error_envelope_schema_version.py +8 -0
- bytekit/models/scrape_error_envelope_status.py +8 -0
- bytekit/models/scrape_formats.py +183 -0
- bytekit/models/scrape_markdown_tokens.py +75 -0
- bytekit/models/scrape_metadata.py +262 -0
- bytekit/models/scrape_queued_envelope.py +124 -0
- bytekit/models/scrape_queued_envelope_schema_version.py +8 -0
- bytekit/models/scrape_queued_envelope_status.py +8 -0
- bytekit/models/scrape_request.py +485 -0
- bytekit/models/scrape_request_cache_ttl_type_1.py +8 -0
- bytekit/models/scrape_request_custom.py +48 -0
- bytekit/models/scrape_request_events_item.py +10 -0
- bytekit/models/scrape_request_formats_item.py +12 -0
- bytekit/models/scrape_request_headers.py +44 -0
- bytekit/models/scrape_request_markdown_images.py +11 -0
- bytekit/models/scrape_request_markdown_links.py +11 -0
- bytekit/models/scrape_request_markdown_mode.py +10 -0
- bytekit/models/scrape_request_token_encoding.py +9 -0
- bytekit/models/scrape_request_x_internal_scrape_path.py +8 -0
- bytekit/models/scrape_scored_image.py +128 -0
- bytekit/models/scrape_scored_link.py +94 -0
- bytekit/models/scrape_stats.py +75 -0
- bytekit/models/scrape_success_envelope.py +345 -0
- bytekit/models/scrape_success_envelope_cache.py +10 -0
- bytekit/models/scrape_success_envelope_custom.py +48 -0
- bytekit/models/scrape_success_envelope_schema_version.py +8 -0
- bytekit/models/scrape_success_envelope_status.py +8 -0
- bytekit/models/scrape_table.py +96 -0
- bytekit/models/scrape_table_kind.py +10 -0
- bytekit/models/scrape_warning.py +88 -0
- bytekit/models/scrape_warning_code.py +17 -0
- bytekit/models/screenshot_request.py +445 -0
- bytekit/models/screenshot_request_device.py +9 -0
- bytekit/models/screenshot_request_device_scale_factor_type_1.py +9 -0
- bytekit/models/screenshot_request_device_scale_factor_type_2_type_1.py +9 -0
- bytekit/models/screenshot_request_device_scale_factor_type_3_type_1.py +9 -0
- bytekit/models/screenshot_request_format.py +9 -0
- bytekit/models/screenshot_request_headers.py +44 -0
- bytekit/models/screenshot_request_wait_until.py +10 -0
- bytekit/models/screenshot_response.py +264 -0
- bytekit/models/screenshot_response_status.py +11 -0
- bytekit/models/sitemap_request.py +210 -0
- bytekit/models/sitemap_request_process_type_0.py +90 -0
- bytekit/models/sitemap_request_process_type_0_options.py +44 -0
- bytekit/models/sitemap_request_strategy.py +10 -0
- bytekit/models/sitemap_response.py +418 -0
- bytekit/models/sitemap_response_cache.py +10 -0
- bytekit/models/sitemap_response_metadata_type_0.py +44 -0
- bytekit/models/sitemap_response_process_type_0.py +44 -0
- bytekit/models/sitemap_response_sources_type_0.py +44 -0
- bytekit/models/sitemap_response_status.py +11 -0
- bytekit/models/viewport.py +67 -0
- bytekit/models/webhook_delivery_response.py +270 -0
- bytekit/models/webhook_delivery_response_event_type.py +14 -0
- bytekit/models/webhook_delivery_response_status.py +11 -0
- bytekit/py.typed +0 -0
- bytekit/types.py +54 -0
- bytekit_sdk-0.3.0.dist-info/METADATA +141 -0
- bytekit_sdk-0.3.0.dist-info/RECORD +227 -0
- bytekit_sdk-0.3.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from collections.abc import Mapping
|
|
3
|
+
from typing import (
|
|
4
|
+
Any,
|
|
5
|
+
TypeVar,
|
|
6
|
+
Union,
|
|
7
|
+
cast,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from attrs import define as _attrs_define
|
|
11
|
+
from attrs import field as _attrs_field
|
|
12
|
+
from dateutil.parser import isoparse
|
|
13
|
+
|
|
14
|
+
from ..models.create_scrape_bulk_response_202_status import (
|
|
15
|
+
CreateScrapeBulkResponse202Status,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
T = TypeVar("T", bound="CreateScrapeBulkResponse202")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@_attrs_define
|
|
22
|
+
class CreateScrapeBulkResponse202:
|
|
23
|
+
"""
|
|
24
|
+
Attributes:
|
|
25
|
+
id (str): Example: bulk_01j9abc123.
|
|
26
|
+
status (CreateScrapeBulkResponse202Status):
|
|
27
|
+
total (int):
|
|
28
|
+
completed (int):
|
|
29
|
+
failed (int):
|
|
30
|
+
created_at (datetime.datetime):
|
|
31
|
+
completed_at (Union[None, datetime.datetime]):
|
|
32
|
+
total_credits_charged (int):
|
|
33
|
+
estimated_credits (Union[None, int]): Estimated credits at submission time. Null in GET responses.
|
|
34
|
+
webhook_url (str): Webhook endpoint URL (HTTPS only; http:// rejected with 400 invalid_url, reason
|
|
35
|
+
scheme_unsupported)
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
id: str
|
|
39
|
+
status: CreateScrapeBulkResponse202Status
|
|
40
|
+
total: int
|
|
41
|
+
completed: int
|
|
42
|
+
failed: int
|
|
43
|
+
created_at: datetime.datetime
|
|
44
|
+
completed_at: Union[None, datetime.datetime]
|
|
45
|
+
total_credits_charged: int
|
|
46
|
+
estimated_credits: Union[None, int]
|
|
47
|
+
webhook_url: str
|
|
48
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
49
|
+
|
|
50
|
+
def to_dict(self) -> dict[str, Any]:
|
|
51
|
+
id = self.id
|
|
52
|
+
|
|
53
|
+
status = self.status.value
|
|
54
|
+
|
|
55
|
+
total = self.total
|
|
56
|
+
|
|
57
|
+
completed = self.completed
|
|
58
|
+
|
|
59
|
+
failed = self.failed
|
|
60
|
+
|
|
61
|
+
created_at = self.created_at.isoformat()
|
|
62
|
+
|
|
63
|
+
completed_at: Union[None, str]
|
|
64
|
+
if isinstance(self.completed_at, datetime.datetime):
|
|
65
|
+
completed_at = self.completed_at.isoformat()
|
|
66
|
+
else:
|
|
67
|
+
completed_at = self.completed_at
|
|
68
|
+
|
|
69
|
+
total_credits_charged = self.total_credits_charged
|
|
70
|
+
|
|
71
|
+
estimated_credits: Union[None, int]
|
|
72
|
+
estimated_credits = self.estimated_credits
|
|
73
|
+
|
|
74
|
+
webhook_url = self.webhook_url
|
|
75
|
+
|
|
76
|
+
field_dict: dict[str, Any] = {}
|
|
77
|
+
field_dict.update(self.additional_properties)
|
|
78
|
+
field_dict.update(
|
|
79
|
+
{
|
|
80
|
+
"id": id,
|
|
81
|
+
"status": status,
|
|
82
|
+
"total": total,
|
|
83
|
+
"completed": completed,
|
|
84
|
+
"failed": failed,
|
|
85
|
+
"created_at": created_at,
|
|
86
|
+
"completed_at": completed_at,
|
|
87
|
+
"total_credits_charged": total_credits_charged,
|
|
88
|
+
"estimated_credits": estimated_credits,
|
|
89
|
+
"webhook_url": webhook_url,
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
return field_dict
|
|
94
|
+
|
|
95
|
+
@classmethod
|
|
96
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
97
|
+
d = dict(src_dict)
|
|
98
|
+
id = d.pop("id")
|
|
99
|
+
|
|
100
|
+
status = CreateScrapeBulkResponse202Status(d.pop("status"))
|
|
101
|
+
|
|
102
|
+
total = d.pop("total")
|
|
103
|
+
|
|
104
|
+
completed = d.pop("completed")
|
|
105
|
+
|
|
106
|
+
failed = d.pop("failed")
|
|
107
|
+
|
|
108
|
+
created_at = isoparse(d.pop("created_at"))
|
|
109
|
+
|
|
110
|
+
def _parse_completed_at(data: object) -> Union[None, datetime.datetime]:
|
|
111
|
+
if data is None:
|
|
112
|
+
return data
|
|
113
|
+
try:
|
|
114
|
+
if not isinstance(data, str):
|
|
115
|
+
raise TypeError()
|
|
116
|
+
completed_at_type_0 = isoparse(data)
|
|
117
|
+
|
|
118
|
+
return completed_at_type_0
|
|
119
|
+
except: # noqa: E722
|
|
120
|
+
pass
|
|
121
|
+
return cast(Union[None, datetime.datetime], data)
|
|
122
|
+
|
|
123
|
+
completed_at = _parse_completed_at(d.pop("completed_at"))
|
|
124
|
+
|
|
125
|
+
total_credits_charged = d.pop("total_credits_charged")
|
|
126
|
+
|
|
127
|
+
def _parse_estimated_credits(data: object) -> Union[None, int]:
|
|
128
|
+
if data is None:
|
|
129
|
+
return data
|
|
130
|
+
return cast(Union[None, int], data)
|
|
131
|
+
|
|
132
|
+
estimated_credits = _parse_estimated_credits(d.pop("estimated_credits"))
|
|
133
|
+
|
|
134
|
+
webhook_url = d.pop("webhook_url")
|
|
135
|
+
|
|
136
|
+
create_scrape_bulk_response_202 = cls(
|
|
137
|
+
id=id,
|
|
138
|
+
status=status,
|
|
139
|
+
total=total,
|
|
140
|
+
completed=completed,
|
|
141
|
+
failed=failed,
|
|
142
|
+
created_at=created_at,
|
|
143
|
+
completed_at=completed_at,
|
|
144
|
+
total_credits_charged=total_credits_charged,
|
|
145
|
+
estimated_credits=estimated_credits,
|
|
146
|
+
webhook_url=webhook_url,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
create_scrape_bulk_response_202.additional_properties = d
|
|
150
|
+
return create_scrape_bulk_response_202
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def additional_keys(self) -> list[str]:
|
|
154
|
+
return list(self.additional_properties.keys())
|
|
155
|
+
|
|
156
|
+
def __getitem__(self, key: str) -> Any:
|
|
157
|
+
return self.additional_properties[key]
|
|
158
|
+
|
|
159
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
160
|
+
self.additional_properties[key] = value
|
|
161
|
+
|
|
162
|
+
def __delitem__(self, key: str) -> None:
|
|
163
|
+
del self.additional_properties[key]
|
|
164
|
+
|
|
165
|
+
def __contains__(self, key: str) -> bool:
|
|
166
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import (
|
|
3
|
+
Any,
|
|
4
|
+
TypeVar,
|
|
5
|
+
Union,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
from attrs import define as _attrs_define
|
|
9
|
+
from attrs import field as _attrs_field
|
|
10
|
+
|
|
11
|
+
from ..models.create_search_body_date_range import CreateSearchBodyDateRange
|
|
12
|
+
from ..models.create_search_body_type import CreateSearchBodyType
|
|
13
|
+
from ..types import UNSET, Unset
|
|
14
|
+
|
|
15
|
+
T = TypeVar("T", bound="CreateSearchBody")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@_attrs_define
|
|
19
|
+
class CreateSearchBody:
|
|
20
|
+
"""
|
|
21
|
+
Attributes:
|
|
22
|
+
query (str): The search query.
|
|
23
|
+
type_ (Union[Unset, CreateSearchBodyType]): Which search index to query. `web` (default) returns ranked organic
|
|
24
|
+
results; `news` returns news articles in the same `results` array, additionally populating `source` and `image`
|
|
25
|
+
on each item; `images` returns image results, populating `source`, `domain`, and a fuller `image` object (full-
|
|
26
|
+
image dimensions plus a thumbnail URL and dimensions) while omitting `snippet` and `date`. Billing is identical
|
|
27
|
+
for all three.
|
|
28
|
+
Default: CreateSearchBodyType.WEB.
|
|
29
|
+
limit (Union[Unset, int]): Maximum number of organic results to return. Results are fetched in pages of 10, so
|
|
30
|
+
the call costs `ceil(limit / 10)` credits (capped at 10).
|
|
31
|
+
Default: 10.
|
|
32
|
+
country (Union[Unset, str]): Two-letter country code to localize results (e.g. `us`, `de`), normalized to
|
|
33
|
+
lowercase. Defaults to `us`.
|
|
34
|
+
Default: 'us'.
|
|
35
|
+
language (Union[Unset, str]): Two-letter ISO-639-1 language code for results (e.g. `en`, `fr`), normalized to
|
|
36
|
+
lowercase. Defaults to `en`.
|
|
37
|
+
Default: 'en'.
|
|
38
|
+
date_range (Union[Unset, CreateSearchBodyDateRange]): Restrict results to a recency window: `any` (default, no
|
|
39
|
+
time filter), `hour` (past hour), `day` (past 24 hours), `week` (past week), `month` (past month), or `year`
|
|
40
|
+
(past year). Applies identically to every `type`; billing is unchanged.
|
|
41
|
+
Default: CreateSearchBodyDateRange.ANY.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
query: str
|
|
45
|
+
type_: Union[Unset, CreateSearchBodyType] = CreateSearchBodyType.WEB
|
|
46
|
+
limit: Union[Unset, int] = 10
|
|
47
|
+
country: Union[Unset, str] = "us"
|
|
48
|
+
language: Union[Unset, str] = "en"
|
|
49
|
+
date_range: Union[Unset, CreateSearchBodyDateRange] = CreateSearchBodyDateRange.ANY
|
|
50
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
51
|
+
|
|
52
|
+
def to_dict(self) -> dict[str, Any]:
|
|
53
|
+
query = self.query
|
|
54
|
+
|
|
55
|
+
type_: Union[Unset, str] = UNSET
|
|
56
|
+
if not isinstance(self.type_, Unset):
|
|
57
|
+
type_ = self.type_.value
|
|
58
|
+
|
|
59
|
+
limit = self.limit
|
|
60
|
+
|
|
61
|
+
country = self.country
|
|
62
|
+
|
|
63
|
+
language = self.language
|
|
64
|
+
|
|
65
|
+
date_range: Union[Unset, str] = UNSET
|
|
66
|
+
if not isinstance(self.date_range, Unset):
|
|
67
|
+
date_range = self.date_range.value
|
|
68
|
+
|
|
69
|
+
field_dict: dict[str, Any] = {}
|
|
70
|
+
field_dict.update(self.additional_properties)
|
|
71
|
+
field_dict.update(
|
|
72
|
+
{
|
|
73
|
+
"query": query,
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
if type_ is not UNSET:
|
|
77
|
+
field_dict["type"] = type_
|
|
78
|
+
if limit is not UNSET:
|
|
79
|
+
field_dict["limit"] = limit
|
|
80
|
+
if country is not UNSET:
|
|
81
|
+
field_dict["country"] = country
|
|
82
|
+
if language is not UNSET:
|
|
83
|
+
field_dict["language"] = language
|
|
84
|
+
if date_range is not UNSET:
|
|
85
|
+
field_dict["date_range"] = date_range
|
|
86
|
+
|
|
87
|
+
return field_dict
|
|
88
|
+
|
|
89
|
+
@classmethod
|
|
90
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
91
|
+
d = dict(src_dict)
|
|
92
|
+
query = d.pop("query")
|
|
93
|
+
|
|
94
|
+
_type_ = d.pop("type", UNSET)
|
|
95
|
+
type_: Union[Unset, CreateSearchBodyType]
|
|
96
|
+
if isinstance(_type_, Unset):
|
|
97
|
+
type_ = UNSET
|
|
98
|
+
else:
|
|
99
|
+
type_ = CreateSearchBodyType(_type_)
|
|
100
|
+
|
|
101
|
+
limit = d.pop("limit", UNSET)
|
|
102
|
+
|
|
103
|
+
country = d.pop("country", UNSET)
|
|
104
|
+
|
|
105
|
+
language = d.pop("language", UNSET)
|
|
106
|
+
|
|
107
|
+
_date_range = d.pop("date_range", UNSET)
|
|
108
|
+
date_range: Union[Unset, CreateSearchBodyDateRange]
|
|
109
|
+
if isinstance(_date_range, Unset):
|
|
110
|
+
date_range = UNSET
|
|
111
|
+
else:
|
|
112
|
+
date_range = CreateSearchBodyDateRange(_date_range)
|
|
113
|
+
|
|
114
|
+
create_search_body = cls(
|
|
115
|
+
query=query,
|
|
116
|
+
type_=type_,
|
|
117
|
+
limit=limit,
|
|
118
|
+
country=country,
|
|
119
|
+
language=language,
|
|
120
|
+
date_range=date_range,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
create_search_body.additional_properties = d
|
|
124
|
+
return create_search_body
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def additional_keys(self) -> list[str]:
|
|
128
|
+
return list(self.additional_properties.keys())
|
|
129
|
+
|
|
130
|
+
def __getitem__(self, key: str) -> Any:
|
|
131
|
+
return self.additional_properties[key]
|
|
132
|
+
|
|
133
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
134
|
+
self.additional_properties[key] = value
|
|
135
|
+
|
|
136
|
+
def __delitem__(self, key: str) -> None:
|
|
137
|
+
del self.additional_properties[key]
|
|
138
|
+
|
|
139
|
+
def __contains__(self, key: str) -> bool:
|
|
140
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import (
|
|
3
|
+
TYPE_CHECKING,
|
|
4
|
+
Any,
|
|
5
|
+
TypeVar,
|
|
6
|
+
cast,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
from attrs import define as _attrs_define
|
|
10
|
+
from attrs import field as _attrs_field
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from ..models.create_search_response_200_results_item import (
|
|
14
|
+
CreateSearchResponse200ResultsItem,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
T = TypeVar("T", bound="CreateSearchResponse200")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@_attrs_define
|
|
22
|
+
class CreateSearchResponse200:
|
|
23
|
+
"""
|
|
24
|
+
Attributes:
|
|
25
|
+
id (str): Stable search identifier (prefixed `sr_`).
|
|
26
|
+
query (str): The query that was searched.
|
|
27
|
+
results (list['CreateSearchResponse200ResultsItem']): Ranked organic results merged across the fetched pages,
|
|
28
|
+
re-indexed so `position` runs contiguously from 1, and truncated to `limit`.
|
|
29
|
+
related_searches (list[str]): Related query suggestions surfaced by the search provider, merged and de-
|
|
30
|
+
duplicated across the fetched pages. Empty when the provider returns none.
|
|
31
|
+
credits_used (int): Credits consumed by this search call, equal to the number of pages fetched (`ceil(limit /
|
|
32
|
+
10)`, capped at 10).
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
id: str
|
|
36
|
+
query: str
|
|
37
|
+
results: list["CreateSearchResponse200ResultsItem"]
|
|
38
|
+
related_searches: list[str]
|
|
39
|
+
credits_used: int
|
|
40
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
41
|
+
|
|
42
|
+
def to_dict(self) -> dict[str, Any]:
|
|
43
|
+
id = self.id
|
|
44
|
+
|
|
45
|
+
query = self.query
|
|
46
|
+
|
|
47
|
+
results = []
|
|
48
|
+
for results_item_data in self.results:
|
|
49
|
+
results_item = results_item_data.to_dict()
|
|
50
|
+
results.append(results_item)
|
|
51
|
+
|
|
52
|
+
related_searches = self.related_searches
|
|
53
|
+
|
|
54
|
+
credits_used = self.credits_used
|
|
55
|
+
|
|
56
|
+
field_dict: dict[str, Any] = {}
|
|
57
|
+
field_dict.update(self.additional_properties)
|
|
58
|
+
field_dict.update(
|
|
59
|
+
{
|
|
60
|
+
"id": id,
|
|
61
|
+
"query": query,
|
|
62
|
+
"results": results,
|
|
63
|
+
"related_searches": related_searches,
|
|
64
|
+
"credits_used": credits_used,
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
return field_dict
|
|
69
|
+
|
|
70
|
+
@classmethod
|
|
71
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
72
|
+
from ..models.create_search_response_200_results_item import (
|
|
73
|
+
CreateSearchResponse200ResultsItem,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
d = dict(src_dict)
|
|
77
|
+
id = d.pop("id")
|
|
78
|
+
|
|
79
|
+
query = d.pop("query")
|
|
80
|
+
|
|
81
|
+
results = []
|
|
82
|
+
_results = d.pop("results")
|
|
83
|
+
for results_item_data in _results:
|
|
84
|
+
results_item = CreateSearchResponse200ResultsItem.from_dict(
|
|
85
|
+
results_item_data
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
results.append(results_item)
|
|
89
|
+
|
|
90
|
+
related_searches = cast(list[str], d.pop("related_searches"))
|
|
91
|
+
|
|
92
|
+
credits_used = d.pop("credits_used")
|
|
93
|
+
|
|
94
|
+
create_search_response_200 = cls(
|
|
95
|
+
id=id,
|
|
96
|
+
query=query,
|
|
97
|
+
results=results,
|
|
98
|
+
related_searches=related_searches,
|
|
99
|
+
credits_used=credits_used,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
create_search_response_200.additional_properties = d
|
|
103
|
+
return create_search_response_200
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def additional_keys(self) -> list[str]:
|
|
107
|
+
return list(self.additional_properties.keys())
|
|
108
|
+
|
|
109
|
+
def __getitem__(self, key: str) -> Any:
|
|
110
|
+
return self.additional_properties[key]
|
|
111
|
+
|
|
112
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
113
|
+
self.additional_properties[key] = value
|
|
114
|
+
|
|
115
|
+
def __delitem__(self, key: str) -> None:
|
|
116
|
+
del self.additional_properties[key]
|
|
117
|
+
|
|
118
|
+
def __contains__(self, key: str) -> bool:
|
|
119
|
+
return key in self.additional_properties
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from typing import (
|
|
3
|
+
TYPE_CHECKING,
|
|
4
|
+
Any,
|
|
5
|
+
TypeVar,
|
|
6
|
+
Union,
|
|
7
|
+
cast,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from attrs import define as _attrs_define
|
|
11
|
+
from attrs import field as _attrs_field
|
|
12
|
+
|
|
13
|
+
from ..types import UNSET, Unset
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from ..models.create_search_response_200_results_item_image import (
|
|
17
|
+
CreateSearchResponse200ResultsItemImage,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
T = TypeVar("T", bound="CreateSearchResponse200ResultsItem")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@_attrs_define
|
|
25
|
+
class CreateSearchResponse200ResultsItem:
|
|
26
|
+
"""
|
|
27
|
+
Attributes:
|
|
28
|
+
position (int): 1-based rank of the result.
|
|
29
|
+
title (str):
|
|
30
|
+
url (str):
|
|
31
|
+
snippet (str): Short text excerpt for the result. Present for `web` and `news` results; omitted for `images`
|
|
32
|
+
results.
|
|
33
|
+
date (Union[None, Unset, str]): Published date of the result. For `web` and `news` results the key is always
|
|
34
|
+
present but is `null` when the provider reports no date; omitted entirely for `images` results.
|
|
35
|
+
source (Union[Unset, str]): Publisher / source name. Present for `news` and `images` results, when the provider
|
|
36
|
+
reports one.
|
|
37
|
+
domain (Union[Unset, str]): Hosting-page domain of the result. Present only for `images` results, when the
|
|
38
|
+
provider reports one.
|
|
39
|
+
image (Union[Unset, CreateSearchResponse200ResultsItemImage]): Image attached to the result. For `news` results
|
|
40
|
+
this is the thumbnail (only `url`). For `images` results it is the full image, additionally carrying its
|
|
41
|
+
dimensions and a thumbnail URL + dimensions. Each field past `url` is present only when the provider reports it.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
position: int
|
|
45
|
+
title: str
|
|
46
|
+
url: str
|
|
47
|
+
snippet: str
|
|
48
|
+
date: Union[None, Unset, str] = UNSET
|
|
49
|
+
source: Union[Unset, str] = UNSET
|
|
50
|
+
domain: Union[Unset, str] = UNSET
|
|
51
|
+
image: Union[Unset, "CreateSearchResponse200ResultsItemImage"] = UNSET
|
|
52
|
+
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
53
|
+
|
|
54
|
+
def to_dict(self) -> dict[str, Any]:
|
|
55
|
+
position = self.position
|
|
56
|
+
|
|
57
|
+
title = self.title
|
|
58
|
+
|
|
59
|
+
url = self.url
|
|
60
|
+
|
|
61
|
+
snippet = self.snippet
|
|
62
|
+
|
|
63
|
+
date: Union[None, Unset, str]
|
|
64
|
+
if isinstance(self.date, Unset):
|
|
65
|
+
date = UNSET
|
|
66
|
+
else:
|
|
67
|
+
date = self.date
|
|
68
|
+
|
|
69
|
+
source = self.source
|
|
70
|
+
|
|
71
|
+
domain = self.domain
|
|
72
|
+
|
|
73
|
+
image: Union[Unset, dict[str, Any]] = UNSET
|
|
74
|
+
if not isinstance(self.image, Unset):
|
|
75
|
+
image = self.image.to_dict()
|
|
76
|
+
|
|
77
|
+
field_dict: dict[str, Any] = {}
|
|
78
|
+
field_dict.update(self.additional_properties)
|
|
79
|
+
field_dict.update(
|
|
80
|
+
{
|
|
81
|
+
"position": position,
|
|
82
|
+
"title": title,
|
|
83
|
+
"url": url,
|
|
84
|
+
"snippet": snippet,
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
if date is not UNSET:
|
|
88
|
+
field_dict["date"] = date
|
|
89
|
+
if source is not UNSET:
|
|
90
|
+
field_dict["source"] = source
|
|
91
|
+
if domain is not UNSET:
|
|
92
|
+
field_dict["domain"] = domain
|
|
93
|
+
if image is not UNSET:
|
|
94
|
+
field_dict["image"] = image
|
|
95
|
+
|
|
96
|
+
return field_dict
|
|
97
|
+
|
|
98
|
+
@classmethod
|
|
99
|
+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
100
|
+
from ..models.create_search_response_200_results_item_image import (
|
|
101
|
+
CreateSearchResponse200ResultsItemImage,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
d = dict(src_dict)
|
|
105
|
+
position = d.pop("position")
|
|
106
|
+
|
|
107
|
+
title = d.pop("title")
|
|
108
|
+
|
|
109
|
+
url = d.pop("url")
|
|
110
|
+
|
|
111
|
+
snippet = d.pop("snippet")
|
|
112
|
+
|
|
113
|
+
def _parse_date(data: object) -> Union[None, Unset, str]:
|
|
114
|
+
if data is None:
|
|
115
|
+
return data
|
|
116
|
+
if isinstance(data, Unset):
|
|
117
|
+
return data
|
|
118
|
+
return cast(Union[None, Unset, str], data)
|
|
119
|
+
|
|
120
|
+
date = _parse_date(d.pop("date", UNSET))
|
|
121
|
+
|
|
122
|
+
source = d.pop("source", UNSET)
|
|
123
|
+
|
|
124
|
+
domain = d.pop("domain", UNSET)
|
|
125
|
+
|
|
126
|
+
_image = d.pop("image", UNSET)
|
|
127
|
+
image: Union[Unset, CreateSearchResponse200ResultsItemImage]
|
|
128
|
+
if isinstance(_image, Unset):
|
|
129
|
+
image = UNSET
|
|
130
|
+
else:
|
|
131
|
+
image = CreateSearchResponse200ResultsItemImage.from_dict(_image)
|
|
132
|
+
|
|
133
|
+
create_search_response_200_results_item = cls(
|
|
134
|
+
position=position,
|
|
135
|
+
title=title,
|
|
136
|
+
url=url,
|
|
137
|
+
snippet=snippet,
|
|
138
|
+
date=date,
|
|
139
|
+
source=source,
|
|
140
|
+
domain=domain,
|
|
141
|
+
image=image,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
create_search_response_200_results_item.additional_properties = d
|
|
145
|
+
return create_search_response_200_results_item
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def additional_keys(self) -> list[str]:
|
|
149
|
+
return list(self.additional_properties.keys())
|
|
150
|
+
|
|
151
|
+
def __getitem__(self, key: str) -> Any:
|
|
152
|
+
return self.additional_properties[key]
|
|
153
|
+
|
|
154
|
+
def __setitem__(self, key: str, value: Any) -> None:
|
|
155
|
+
self.additional_properties[key] = value
|
|
156
|
+
|
|
157
|
+
def __delitem__(self, key: str) -> None:
|
|
158
|
+
del self.additional_properties[key]
|
|
159
|
+
|
|
160
|
+
def __contains__(self, key: str) -> bool:
|
|
161
|
+
return key in self.additional_properties
|