1515 async_to_streamed_response_wrapper ,
1616)
1717from ..._base_client import make_request_options
18- from ...types .sessions import captcha_solve_image_params
18+ from ...types .sessions import captcha_solve_params , captcha_solve_image_params
19+ from ...types .sessions .captcha_solve_response import CaptchaSolveResponse
1920from ...types .sessions .captcha_status_response import CaptchaStatusResponse
2021from ...types .sessions .captcha_solve_image_response import CaptchaSolveImageResponse
2122
@@ -42,6 +43,59 @@ def with_streaming_response(self) -> CaptchasResourceWithStreamingResponse:
4243 """
4344 return CaptchasResourceWithStreamingResponse (self )
4445
46+ def solve (
47+ self ,
48+ session_id : str ,
49+ * ,
50+ page_id : str | Omit = omit ,
51+ task_id : str | Omit = omit ,
52+ url : str | Omit = omit ,
53+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
54+ # The extra values given here take precedence over values defined on the client or passed to this method.
55+ extra_headers : Headers | None = None ,
56+ extra_query : Query | None = None ,
57+ extra_body : Body | None = None ,
58+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
59+ ) -> CaptchaSolveResponse :
60+ """Solves captcha(s) for the session.
61+
62+ If pageId, url, or taskId is provided, solves
63+ that specific captcha. If no parameters are provided, solves all detected
64+ captchas. Use this when autoCaptchaSolving is disabled in stealthConfig.
65+
66+ Args:
67+ page_id: The page ID where the captcha is located
68+
69+ task_id: The task ID of the specific captcha to solve
70+
71+ url: The URL where the captcha is located
72+
73+ extra_headers: Send extra headers
74+
75+ extra_query: Add additional query parameters to the request
76+
77+ extra_body: Add additional JSON properties to the request
78+
79+ timeout: Override the client-level default timeout for this request, in seconds
80+ """
81+ if not session_id :
82+ raise ValueError (f"Expected a non-empty value for `session_id` but received { session_id !r} " )
83+ return self ._post (
84+ f"/v1/sessions/{ session_id } /captchas/solve" ,
85+ body = maybe_transform (
86+ {
87+ "page_id" : page_id ,
88+ "task_id" : task_id ,
89+ "url" : url ,
90+ },
91+ captcha_solve_params .CaptchaSolveParams ,
92+ ),
93+ options = make_request_options (
94+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
95+ ),
96+ cast_to = CaptchaSolveResponse ,
97+ )
98+
4599 def solve_image (
46100 self ,
47101 session_id : str ,
@@ -146,6 +200,59 @@ def with_streaming_response(self) -> AsyncCaptchasResourceWithStreamingResponse:
146200 """
147201 return AsyncCaptchasResourceWithStreamingResponse (self )
148202
203+ async def solve (
204+ self ,
205+ session_id : str ,
206+ * ,
207+ page_id : str | Omit = omit ,
208+ task_id : str | Omit = omit ,
209+ url : str | Omit = omit ,
210+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
211+ # The extra values given here take precedence over values defined on the client or passed to this method.
212+ extra_headers : Headers | None = None ,
213+ extra_query : Query | None = None ,
214+ extra_body : Body | None = None ,
215+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
216+ ) -> CaptchaSolveResponse :
217+ """Solves captcha(s) for the session.
218+
219+ If pageId, url, or taskId is provided, solves
220+ that specific captcha. If no parameters are provided, solves all detected
221+ captchas. Use this when autoCaptchaSolving is disabled in stealthConfig.
222+
223+ Args:
224+ page_id: The page ID where the captcha is located
225+
226+ task_id: The task ID of the specific captcha to solve
227+
228+ url: The URL where the captcha is located
229+
230+ extra_headers: Send extra headers
231+
232+ extra_query: Add additional query parameters to the request
233+
234+ extra_body: Add additional JSON properties to the request
235+
236+ timeout: Override the client-level default timeout for this request, in seconds
237+ """
238+ if not session_id :
239+ raise ValueError (f"Expected a non-empty value for `session_id` but received { session_id !r} " )
240+ return await self ._post (
241+ f"/v1/sessions/{ session_id } /captchas/solve" ,
242+ body = await async_maybe_transform (
243+ {
244+ "page_id" : page_id ,
245+ "task_id" : task_id ,
246+ "url" : url ,
247+ },
248+ captcha_solve_params .CaptchaSolveParams ,
249+ ),
250+ options = make_request_options (
251+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
252+ ),
253+ cast_to = CaptchaSolveResponse ,
254+ )
255+
149256 async def solve_image (
150257 self ,
151258 session_id : str ,
@@ -234,6 +341,9 @@ class CaptchasResourceWithRawResponse:
234341 def __init__ (self , captchas : CaptchasResource ) -> None :
235342 self ._captchas = captchas
236343
344+ self .solve = to_raw_response_wrapper (
345+ captchas .solve ,
346+ )
237347 self .solve_image = to_raw_response_wrapper (
238348 captchas .solve_image ,
239349 )
@@ -246,6 +356,9 @@ class AsyncCaptchasResourceWithRawResponse:
246356 def __init__ (self , captchas : AsyncCaptchasResource ) -> None :
247357 self ._captchas = captchas
248358
359+ self .solve = async_to_raw_response_wrapper (
360+ captchas .solve ,
361+ )
249362 self .solve_image = async_to_raw_response_wrapper (
250363 captchas .solve_image ,
251364 )
@@ -258,6 +371,9 @@ class CaptchasResourceWithStreamingResponse:
258371 def __init__ (self , captchas : CaptchasResource ) -> None :
259372 self ._captchas = captchas
260373
374+ self .solve = to_streamed_response_wrapper (
375+ captchas .solve ,
376+ )
261377 self .solve_image = to_streamed_response_wrapper (
262378 captchas .solve_image ,
263379 )
@@ -270,6 +386,9 @@ class AsyncCaptchasResourceWithStreamingResponse:
270386 def __init__ (self , captchas : AsyncCaptchasResource ) -> None :
271387 self ._captchas = captchas
272388
389+ self .solve = async_to_streamed_response_wrapper (
390+ captchas .solve ,
391+ )
273392 self .solve_image = async_to_streamed_response_wrapper (
274393 captchas .solve_image ,
275394 )
0 commit comments