+
    Vik                    	  a  Ru tS0 t R t^ RIt^ RIt^ RIt^ RIHtHtHtH	t	H
t
HtHtHtHt ^ RIt^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt]P.                  ! R4      t] ^ k R t]! 4       t]! R4      t ! R R]P8                  4      t ! R	 R
]P8                  4      t ! R R]P8                  4      t ! R R]P8                  4      t  ! R R]P8                  ]],          4      t! ! R R]P8                  4      t" ! R R]P8                  4      t# ! R R]P8                  4      t$ ! R R]P8                  4      t% ! R R]P8                  4      t& ! R R]P8                  4      t' ! R R]P8                  4      t( ! R R ]P8                  4      t) ! R! R"]P8                  4      t* ! R# R$]P8                  4      t+ ! R% R&]P8                  4      t, ! R' R(]P8                  4      t- ! R) R*]P8                  4      t. ! R+ R,]P8                  4      t/ ! R- R.]P8                  4      t0 ! R/ R0]%4      t1 ! R1 R2]!],          ]],          4      t2 ! R3 R4]P8                  4      t3 ! R5 R6]P8                  4      t4 ! R7 R8]P8                  4      t5 ! R9 R:]P8                  4      t6 ! R; R<]P8                  4      t7 ! R= R>]P8                  4      t8 ! R? R@]P8                  4      t9 ! RA RB]P8                  4      t: ! RC RD]P8                  4      t; ! RE RF]P8                  4      t< ! RG RH]P8                  ]],          4      t= ! RI RJ]P8                  4      t> ! RK RL]P8                  4      t? ! RM RN]P8                  4      t@ ! RO RP]P8                  4      tA ! RQ RR]P8                  4      tB ! RS RT]P8                  4      tC ! RU RV]P8                  4      tD ! RW RX]P8                  4      tE ! RY RZ]P8                  4      tF ! R[ R\]P8                  4      tG ! R] R^]P8                  4      tH ! R_ R`]P8                  4      tI ! Ra Rb]P8                  4      tJ ! Rc Rd]P8                  4      tK ! Re Rf]P8                  4      tL ! Rg Rh]P8                  4      tM ! Ri Rj]P8                  4      tN ! Rk RL]P8                  4      t? ! Rl RF]P8                  4      t< ! Rm Rn4      tO ! Ro Rp4      tP ! Rq Rr]O4      tQ ! Rs Rt]P4      tRR# )va"  
Firecrawl v1 API Client - Legacy Implementation

This module provides the legacy v1 implementation of the Firecrawl SDK.
It contains the complete `V1FirecrawlApp` class with all v1 API methods and types
for backward compatibility. This is used by the unified client to provide
version-specific access patterns like app.v1.scrape_url().

Classes:
    - V1FirecrawlApp: Legacy v1 client for interacting with the Firecrawl API.
    - AsyncV1FirecrawlApp: Async version of the v1 client.
    - CrawlWatcher: WebSocket-based crawl monitoring for v1.
N)	AnyDictOptionalListUnionCallableLiteralTypeVarGeneric)datetime	firecrawlc                      ^ RI Hp  \        P                  P	                  \
        4      pV ! \        P                  P                  VR4      4      P                  4       p\        P                  ! RV\        P                  4      pV'       d    VP                  ^4      P                  4       # R#   \         d    \        R4        R# i ; i)    )Pathz__init__.pyz"^__version__ = ['\"]([^'\"]*)['\"]z&Failed to get version from __init__.pyN)pathlibr   ospathdirname__file__join	read_textresearchMgroupstrip	Exceptionprint)r   package_pathversion_fileversion_matchs       R/home/ubuntu/hermes-agent/venv/lib/python3.14/site-packages/firecrawl/v1/client.pyget_versionr"      s    	WW__X.l"'',,|]CDNNPlii E|UWUYUYZm	$$Q'--/
/ 
	 45s   B
B. B. .CCTc                   8   a  ] tR t^Pt o RtRtRtV 3R ltRtV t	R# )V1AgentOptionszConfiguration for the agent.FIRE-1Nc                P   < V ^8  d   Qh/ S[ R,          ;R&   S[S[,          ;R&   # )   r&   modelpromptr   r   str)format__classdict__s   "r!   __annotate__V1AgentOptions.__annotate__P   s&     8'  SM       )
__name__
__module____qualname____firstlineno____doc__r)   r*   __annotate_func____static_attributes____classdictcell__r.   s   @r!   r%   r%   P   s     &'E F  r1   r%   c                   4   a  ] tR t^Ut o RtRtV 3R ltRtV tR# )V1AgentOptionsExtract2Configuration for the agent in extract operations.r&   c                4   < V ^8  d   Qh/ S[ R,          ;R&   # r(   r&   r)   r   )r-   r.   s   "r!   r/   "V1AgentOptionsExtract.__annotate__U        8' r1   r2   N	r3   r4   r5   r6   r7   r)   r8   r9   r:   r;   s   @r!   r=   r=   U        <'E  r1   r=   c                   0   a  ] tR t^Yt o RtV 3R ltRtV tR# )V1ActionsResultz,Result of actions performed during scraping.c                R   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   # )r(   screenshotspdfs)r   r,   )r-   r.   s   "r!   r/   V1ActionsResult.__annotate__Y   s$     c  s)O r1   r2   Nr3   r4   r5   r6   r7   r8   r9   r:   r;   s   @r!   rG   rG   Y   s     6  r1   rG   c                   `   a  ] tR t^^t o RtRtRt]P                  ! RRR7      t	V 3R lt
RtV tR# )V1ChangeTrackingDataz&
Data for the change tracking format.
Njsonaliasc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[;R&   S[;R&   S[ S[S[S[3,          ,          ;R&   S[ S[,          ;R&   # )r(   previousScrapeAtchangeStatus
visibilitydiff
json_field)r   r,   r   r   )r-   r.   s   "r!   r/   !V1ChangeTrackingData.__annotate__^   sZ      sm*	 
   O  4S>
")  B r1   r2   )r3   r4   r5   r6   r7   rS   rV   pydanticFieldrW   r8   r9   r:   r;   s   @r!   rN   rN   ^   s0      '+ &*D (t6 BJ  r1   rN   c                      a  ] tR t^ht o RtRtRtRtRtRt	Rt
]P                  ! RRR7      tRtRtRtRtRtRtV 3R ltRtV tR# )V1FirecrawlDocumentz-Document retrieved or processed by Firecrawl.NrO   rP   c                  < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[S[,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R	&   S[ S[,          ;R
&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r(   urlmarkdownhtmlrawHtmllinksextractrW   
screenshotmetadataactionstitledescriptionchangeTracking)r   r,   r   r#   r   rG   rN   )r-   r.   s   "r!   r/    V1FirecrawlDocument.__annotate__h   s     	#  sm"  3-	 
 c]!  DI%  a[  @  $  sm"  o&-  C=  #%  129 r1   r2   )r3   r4   r5   r6   r7   r^   r_   r`   ra   rb   rc   rY   rZ   rW   rd   re   rf   rg   rh   ri   r8   r9   r:   r;   s   @r!   r\   r\   h   s[     7C"HD!G!%EG&nnT@J $J"H)-GE!%K59N  r1   r\   c                   8   a  ] tR t^xt o RtRtRtV 3R ltRtV t	R# )V1LocationConfigz$Location configuration for scraping.Nc                b   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[S[,          ,          ;R&   # )r(   country	languages)r   r,   r   )r-   r.   s   "r!   r/   V1LocationConfig.__annotate__x   s*     c]!  S	") r1   r2   )
r3   r4   r5   r6   r7   rn   ro   r8   r9   r:   r;   s   @r!   rl   rl   x   s     .!G%)I  r1   rl   c                   <   a  ] tR t^}t o RtRtRtRtV 3R ltRt	V t
R# )V1WebhookConfigzConfiguration for webhooks.Nc                   < V ^8  d   Qh/ S[ ;R&   S[S[S[ S[ 3,          ,          ;R&   S[S[S[ S[ 3,          ,          ;R&   S[S[S[R,          ,          ,          ;R&   # )r(   r^   headersre   events)	completedfailedpagestarted)r,   r   r   r   r   )r-   r.   s   "r!   r/   V1WebhookConfig.__annotate__}   s`     	H  d38n%,  tCH~&-	 
 T'"JKLMT r1   r2   )r3   r4   r5   r6   r7   rt   re   ru   r8   r9   r:   r;   s   @r!   rr   rr   }   s     %(,G)-HPTF  r1   rr   c                   d   a  ] tR t^t o RtRt]P                  ! RRR7      tRt	Rt
V 3R ltRtV tR# )V1ChangeTrackingOptionsz"Configuration for change tracking.NschemarP   c                   < V ^8  d   Qh/ S[ S[S[R,          ,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r(   modesschema_fieldr*   tag)zgit-diffrO   )r   r   r   r   r,   )r-   r.   s   "r!   r/   $V1ChangeTrackingOptions.__annotate__   sS     D!3456=  3-F  SM 	 
 
# r1   r2   )r3   r4   r5   r6   r7   r   rY   rZ   r   r*   r   r8   r9   r:   r;   s   @r!   r|   r|      s.     ,9=E"*..X"FL FC  r1   r|   c                   t   a  ] tR t^t o RtRtRtRtRtRt	Rt
RtRtRtRtRtRtRtRtRtRtRtV 3R ltRtV tR# )V1ScrapeOptions#Parameters for scraping operations.N0u  c                X  < V ^8  d   Qh/ S[ S[S[R,          ,          ,          ;R&   S[ S[S[S[3,          ,          ;R&   S[ S[S[,          ,          ;R&   S[ S[S[,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R	&   S[ S[,          ;R
&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[R,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r(   formatsrt   includeTagsexcludeTagsonlyMainContentwaitFortimeoutlocationmobileskipTlsVerificationremoveBase64ImagesblockAdsproxychangeTrackingOptionsmaxAgestoreInCacheparsePDF
r_   r`   ra   contentrb   rd   screenshot@fullPagerc   rO   ri   basicstealthenhancedauto)	r   r   r   r   r,   boolintrl   r|   )r-   r.   s   "r!   r/   V1ScrapeOptions.__annotate__   s]    d7  $_  `  a  b  i  d38n%,  $s)$+	 
 $s)$+  d^*  c]!  c]"  '(/  TN!  "$.  !-  tn#  GBCDK  $$;<C   SM ! " 4.'# $ tn#% r1   r2   )r3   r4   r5   r6   r7   r   rt   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r8   r9   r:   r;   s   @r!   r   r      sk     - eiG(,G'+K'+K&*O!G"G+/H!F*.)-#HGKE?C F#'L#H%  r1   r   c                   8   a  ] tR t^t o RtRtRtV 3R ltRtV t	R# )V1WaitActionz'Wait action to perform during scraping.Nc                l   < V ^8  d   Qh/ S[ R,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r(   waittypemillisecondsselector)r   r   r   r,   )r-   r.   s   "r!   r/   V1WaitAction.__annotate__   s6     
&/  3-&  sm"	 r1   r2   )
r3   r4   r5   r6   r7   r   r   r8   r9   r:   r;   s   @r!   r   r      s     1"&L"H	  r1   r   c                   8   a  ] tR t^t o RtRtRtV 3R ltRtV t	R# )V1ScreenshotActionz-Screenshot action to perform during scraping.Nc                l   < V ^8  d   Qh/ S[ R,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r(   rd   r   fullPagequality)r   r   r   r   )r-   r.   s   "r!   r/   V1ScreenshotAction.__annotate__   s7     
,
  tn#  c]!	 r1   r2   )
r3   r4   r5   r6   r7   r   r   r8   r9   r:   r;   s   @r!   r   r      s     7#H!G	  r1   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )V1ClickActionz(Click action to perform during scraping.c                @   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   # )r(   clickr   r   r   r,   )r-   r.   s   "r!   r/   V1ClickAction.__annotate__   s!     
'
  M r1   r2   NrL   r;   s   @r!   r   r           2  r1   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )V1WriteActionz(Write action to perform during scraping.c                @   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   # )r(   writer   textr   )r-   r.   s   "r!   r/   V1WriteAction.__annotate__   s!     
'
  I r1   r2   NrL   r;   s   @r!   r   r      r   r1   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )V1PressActionz(Press action to perform during scraping.c                @   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   # )r(   pressr   keyr   )r-   r.   s   "r!   r/   V1PressAction.__annotate__   s!     
'
  
H r1   r2   NrL   r;   s   @r!   r   r      r   r1   r   c                   4   a  ] tR t^t o RtRtV 3R ltRtV tR# )V1ScrollActionz)Scroll action to perform during scraping.Nc                j   < V ^8  d   Qh/ S[ R,          ;R&   S[ R,          ;R&   S[S[,          ;R&   # )r(   scrollr   	directionr   )updownr+   )r-   r.   s   "r!   r/   V1ScrollAction.__annotate__   s8     
(
  |$$  sm"	 r1   r2   )	r3   r4   r5   r6   r7   r   r8   r9   r:   r;   s   @r!   r   r      s     3 #H	  r1   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )V1ScrapeActionz)Scrape action to perform during scraping.c                4   < V ^8  d   Qh/ S[ R,          ;R&   # )r(   scraper   rA   )r-   r.   s   "r!   r/   V1ScrapeAction.__annotate__   s     
(
 r1   r2   NrL   r;   s   @r!   r   r      s     3  r1   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )V1ExecuteJavascriptActionz5Execute javascript action to perform during scraping.c                @   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   # )r(   executeJavascriptr   scriptr   )r-   r.   s   "r!   r/   &V1ExecuteJavascriptAction.__annotate__   s"     
%
&&  K r1   r2   NrL   r;   s   @r!   r   r      s     ?  r1   r   c                   <   a  ] tR t^t o RtRtRtRtV 3R ltRt	V t
R# )V1PDFActionz&PDF action to perform during scraping.Nc                   < V ^8  d   Qh/ S[ R,          ;R&   S[S[ R,          ,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r(   pdfr   r-   	landscapescale)A0A1A2A3A4A5A6LetterLegalTabloidLedger)r   r   r   float)r-   r.   s   "r!   r/   V1PDFAction.__annotate__   sN     
%.  Wmnov  ~$	 
 E?! r1   r2   )r3   r4   r5   r6   r7   r-   r   r   r8   r9   r:   r;   s   @r!   r   r      s     0rvF $I!E  r1   r   c                   4   a  ] tR t^t o RtRtV 3R ltRtV tR# )V1ExtractAgentr>   r&   c                4   < V ^8  d   Qh/ S[ R,          ;R&   # r@   rA   )r-   r.   s   "r!   r/   V1ExtractAgent.__annotate__   rC   r1   r2   NrD   r;   s   @r!   r   r      rE   r1   r   c                   d   a  ] tR t^t o RtRt]P                  ! RRR7      tRt	Rt
V 3R ltRtV tR# )V1JsonConfigzConfiguration for extraction.Nr}   rP   c                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r(   r*   r   systemPromptagent)r   r,   r   r   )r-   r.   s   "r!   r/   V1JsonConfig.__annotate__   sH     SM   3-F  3-&	 
 N#* r1   r2   )r3   r4   r5   r6   r7   r*   rY   rZ   r   r   r   r8   r9   r:   r;   s   @r!   r   r      s.     ' F"*..X"FL"&L&*E  r1   r   c                   D   a  ] tR t^t o RtRtRtRtRtRt	V 3R lt
RtV tR# )V1ScrapeParamsr   Nc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[S[S[S[S[S[S[S[	S[
S[S[3	,          ,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r(   rc   jsonOptionsrf   r   webhook)r   r   r   r   r   r   r   r   r   r   r   r   r   r%   rr   )r-   r.   s   "r!   r/   V1ScrapeParams.__annotate__   s     l#*  ,'.  d5/A=R_anp~  AO  Qj  lw  "w  x  y  z  A	 
 N#*  o&- r1   r2   )r3   r4   r5   r6   r7   rc   r   rf   r   r   r8   r9   r:   r;   s   @r!   r   r      s,     -&*G*.K }AG&*E)-G  r1   r   c                   <   a  ] tR t^t o RtRtRtRtV 3R ltRt	V t
R# )V1ScrapeResponsez"Response from scraping operations.TNc                ^   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r(   successwarningerror)r   r   r,   )r-   r.   s   "r!   r/   V1ScrapeResponse.__annotate__   s2       c]!  C=	 r1   r2   r3   r4   r5   r6   r7   r   r   r   r8   r9   r:   r;   s   @r!   r   r      s     ,G!GE	  r1   r   c                   D   a  ] tR t^t o RtRtRtRtRtRt	V 3R lt
RtV tR# )V1BatchScrapeResponsez&Response from batch scrape operations.NTc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[;R&   S[ S[,          ;R&   S[ S[S[,          ,          ;R&   # )r(   idr^   r   r   invalidURLs)r   r,   r   r   )r-   r.   s   "r!   r/   "V1BatchScrapeResponse.__annotate__   sY       
#  	 
 C=  $s)$+ r1   r2   )r3   r4   r5   r6   r7   r  r^   r   r   r  r8   r9   r:   r;   s   @r!   r  r     s(     0BCGE'+K  r1   r  c                   8   a  ] tR t^t o RtRtRtV 3R ltRtV t	R# )V1BatchScrapeStatusResponsez)Response from batch scrape status checks.TNc                   < V ^8  d   Qh/ S[ ;R&   S[R	,          ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[S[,          ;R&   S[S[,          ;R&   # 
r(   r   rv   statustotalcreditsUsed	expiresAtnextdata)scrapingrv   rw   	cancelledr   r   r   r   r   r,   r   r\   )r-   r.   s   "r!   r/   (V1BatchScrapeStatusResponse.__annotate__   y       BCC  N	 
 J      3-  "
## r1   r2   
r3   r4   r5   r6   r7   r   r  r8   r9   r:   r;   s   @r!   r	  r	     s     3G D  r1   r	  c                   t   a  ] tR t^t o RtRtRtRtRtRt	Rt
RtRtRtRtRtRtRtRtRtRtRtV 3R ltRtV tR# )V1CrawlParamsz#Parameters for crawling operations.Nc                ,  < V ^8  d   Qh/ S[ S[S[,          ,          ;R&   S[ S[S[,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R	&   S[ S[,          ;R
&   S[ S[S[S[3,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r(   includePathsexcludePathsmaxDepthmaxDiscoveryDepthlimitallowBackwardLinkscrawlEntireDomainallowExternalLinksignoreSitemapscrapeOptionsr   deduplicateSimilarURLsignoreQueryParametersregexOnFullURLdelaymaxConcurrencyallowSubdomains)r   r   r,   r   r   r   r   rr   )r-   r.   s   "r!   r/   V1CrawlParams.__annotate__   s:    49%,  49%,  sm"	 
  }+  C=  !-   ~,  !-  D>(  O,3  eC0129  %TN1  $D>0  TN)   C=! " SM(# $ d^*% r1   r2   )r3   r4   r5   r6   r7   r  r  r  r  r  r   r!  r"  r#  r$  r   r%  r&  r'  r(  r)  r*  r8   r9   r:   r;   s   @r!   r  r     sj     -(,L(,L"H'+E)-(,)-$(M/3M59G-1,0%)NE$(N&*O%  r1   r  c                   @   a  ] tR tRt o RtRtRtRtRtV 3R lt	Rt
V tR# )V1CrawlResponsei  z"Response from crawling operations.NTc                z   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[;R&   S[ S[,          ;R&   # )r(   r  r^   r   r   )r   r,   r   )r-   r.   s   "r!   r/   V1CrawlResponse.__annotate__  sC       
#  	 
 C= r1   r2   )r3   r4   r5   r6   r7   r  r^   r   r   r8   r9   r:   r;   s   @r!   r-  r-    s#     ,BCGE  r1   r-  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )V1CrawlStatusResponsei  z"Response from crawl status checks.TNc                   < V ^8  d   Qh/ S[ ;R&   S[R	,          ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[S[,          ;R&   S[S[,          ;R&   # r  r  )r-   r.   s   "r!   r/   "V1CrawlStatusResponse.__annotate__  r  r1   r2   r  r;   s   @r!   r1  r1    s     ,G D  r1   r1  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )V1CrawlErrori"  zA crawl error.Nc                v   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[ ;R&   S[S[ ,          ;R&   S[ ;R&   # )r(   r  	timestampr^   coder   )r,   r   r   )r-   r.   s   "r!   r/   V1CrawlError.__annotate__"  sJ     G  !(  
H	 
 3-  J r1   r2   )
r3   r4   r5   r6   r7   r7  r8  r8   r9   r:   r;   s   @r!   r5  r5  "  s     $(ID  r1   r5  c                   0   a  ] tR tRt o RtV 3R ltRtV tR# )V1CrawlErrorsResponsei*  z2Response from crawl/batch scrape error monitoring.c                R   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   # )r(   errorsrobotsBlocked)r   r5  r,   )r-   r.   s   "r!   r/   "V1CrawlErrorsResponse.__annotate__*  s&       9 r1   r2   NrL   r;   s   @r!   r;  r;  *  s     <  r1   r;  c                   P   a  ] tR tRt o RtRtRtRtRtRt	Rt
RtRtV 3R ltRtV tR# )V1MapParamsi/  z"Parameters for mapping operations.Nr   c                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )	r(   r   r#  includeSubdomainssitemapOnlyr  r   useIndexr   )r   r,   r   r   rl   )r-   r.   s   "r!   r/   V1MapParams.__annotate__/  s     SM   D>(   ~,	 
 $&  C=  c]"  tn#  '(/ r1   r2   )r3   r4   r5   r6   r7   r   r#  rC  rD  r  r   rE  r   r8   r9   r:   r;   s   @r!   rA  rA  /  s8     , F$(M(,"&KE"G#H+/H  r1   rA  c                   <   a  ] tR tRt o RtRtRtRtV 3R ltRt	V t
R# )V1MapResponsei:  z!Response from mapping operations.TNc                n   < V ^8  d   Qh/ S[ ;R&   S[S[S[,          ,          ;R&   S[S[,          ;R&   # )r(   r   rb   r   )r   r   r   r,   )r-   r.   s   "r!   r/   V1MapResponse.__annotate__:  s7       DI%  C=	 r1   r2   )r3   r4   r5   r6   r7   r   rb   r   r8   r9   r:   r;   s   @r!   rH  rH  :  s     +G!%EE	  r1   rH  c                   x   a  ] tR tRt o RtRt]P                  ! RRR7      tRt	Rt
RtRtRtRtRtV 3R ltRtV tR# )V1ExtractParamsi@  z0Parameters for extracting information from URLs.Nr}   rP   c                  < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R	&   # )
r(   r*   r   r   r"  enableWebSearchrC  originshowSourcesr$  )r   r,   r   r   r   )r-   r.   s   "r!   r/   V1ExtractParams.__annotate__@  s     SM   3-F  3-&	 
 !-  d^*   ~,  SM   $&  O,3 r1   r2   )r3   r4   r5   r6   r7   r*   rY   rZ   r   r   r"  rN  rC  rO  rP  r$  r8   r9   r:   r;   s   @r!   rL  rL  @  sI     : F"*..X"FL"&L)-&*O(, F"&K/3M  r1   rL  c                   T   a  ] tR tRt o RtRtRtRtRtRt	Rt
RtRtRtV 3R ltRtV tR# )V1ExtractResponseiL  z!Response from extract operations.NTc                *  < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[R
,          ,          ;R&   S[ S[,          ;R&   S[;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[S[S[3,          ,          ;R&   S[ S[,          ;R	&   # )r(   r  r  r  r   r  r   r   sourcesr  
processingrv   rw   )	r   r,   r   r   r   r#   r   r   r   )r-   r.   s   "r!   r/   V1ExtractResponse.__annotate__L  s       W@ABI  !(	 
   1+  C=  c]!  d38n%,  #% r1   r2   )r3   r4   r5   r6   r7   r  r  r  r   r  r   r   rU  r  r8   r9   r:   r;   s   @r!   rS  rS  L  s<     +BEIF$(IGDE!G(,G!%K  r1   rS  c                   P   a  ] tR tRt o ^tRtRtRtRtRt	Rt
RtRtV 3R ltRtV tR# )	V1SearchParamsiX  Nenusapii`  c                "  < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[,          ;R	&   S[S[,          ;R
&   # )r(   queryr  tbsfilterlangrn   r   rO  r   r$  )r,   r   r   r   )r-   r.   s   "r!   r/   V1SearchParams.__annotate__X  s     J C=  
#  SM 	 
 3-  c]!  sm"  SM!  c]"  O,3 r1   r2   )r3   r4   r5   r6   r  r`  ra  rb  rn   r   rO  r   r$  r8   r9   r:   r;   s   @r!   rZ  rZ  X  s9     EC FD!G"H!F"G/3M  r1   rZ  c                   <   a  ] tR tRt o RtRtRtRtV 3R ltRt	V t
R# )V1SearchResponseid  z Response from search operations.TNc                z   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # r(   r   r  r   r   )r   r   r\   r   r,   )r-   r.   s   "r!   r/   V1SearchResponse.__annotate__d  sE       "
##  c]!	 
 C= r1   r2   r  r;   s   @r!   re  re  d  s     *G!GE  r1   re  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )V1CreditUsageDataik  Nc                z   < V ^8  d   Qh/ S[ ;R&   S[S[ ,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r(   remaining_creditsplan_creditsbilling_period_startbilling_period_endr   r   r,   )r-   r.   s   "r!   r/   V1CreditUsageData.__annotate__k  sA      3-&  #3-.  !,	 r1   r2   )
r3   r4   r5   r6   rm  rn  ro  r8   r9   r:   r;   s   @r!   rj  rj  k  s     "&L*.(,	  r1   rj  c                   ,   a  ] tR tRt o V 3R ltRtV tR# )V1CreditUsageResponseiq  c                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # r(   r   r  )r   rj  )r-   r.   s   "r!   r/   "V1CreditUsageResponse.__annotate__q  s     M 
 r1   r2   Nr3   r4   r5   r6   r8   r9   r:   r;   s   @r!   rs  rs  q        r1   rs  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )V1TokenUsageDataiu  Nc                z   < V ^8  d   Qh/ S[ ;R&   S[S[ ,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r(   remaining_tokensplan_tokensrn  ro  rp  )r-   r.   s   "r!   r/   V1TokenUsageData.__annotate__u  sA      #%  #3-.  !,	 r1   r2   )
r3   r4   r5   r6   r}  rn  ro  r8   r9   r:   r;   s   @r!   rz  rz  u  s     !%K*.(,	  r1   rz  c                   ,   a  ] tR tRt o V 3R ltRtV tR# )V1TokenUsageResponsei{  c                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # ru  )r   rz  )r-   r.   s   "r!   r/   !V1TokenUsageResponse.__annotate__{  s     M 
 r1   r2   Nrw  r;   s   @r!   r  r  {  rx  r1   r  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )V1CreditUsageHistoricalPeriodi  Nc                z   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[;R&   # )r(   	startDateendDateapiKeyr  r   r,   r   )r-   r.   s   "r!   r/   *V1CreditUsageHistoricalPeriod.__annotate__  sA     }# c]!  SM   	 r1   r2   
r3   r4   r5   r6   r  r  r  r8   r9   r:   r;   s   @r!   r  r         #I!G F  r1   r  c                   ,   a  ] tR tRt o V 3R ltRtV tR# )V1CreditUsageHistoricalResponsei  c                B   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   # r(   r   periods)r   r   r  )r-   r.   s   "r!   r/   ,V1CreditUsageHistoricalResponse.__annotate__  s      M /00 r1   r2   Nrw  r;   s   @r!   r  r    rx  r1   r  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )V1TokenUsageHistoricalPeriodi  Nc                z   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[;R&   # )r(   r  r  r  
tokensUsedr  )r-   r.   s   "r!   r/   )V1TokenUsageHistoricalPeriod.__annotate__  s@     }# c]!  SM   O	 r1   r2   r  r;   s   @r!   r  r    r  r1   r  c                   ,   a  ] tR tRt o V 3R ltRtV tR# )V1TokenUsageHistoricalResponsei  c                B   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   # r  )r   r   r  )r-   r.   s   "r!   r/   +V1TokenUsageHistoricalResponse.__annotate__  s      M .// r1   r2   Nrw  r;   s   @r!   r  r    rx  r1   r  c                   @   a  ] tR tRt o Rt^
tRtRtRtV 3R lt	Rt
V tR# )V1GenerateLLMsTextParams  z3
Parameters for the LLMs.txt generation operation.
FTNc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r(   maxUrlsshowFullTextcache._V1GenerateLLMsTextParams__experimental_stream)r   r   r   )r-   r.   s   "r!   r/   %V1GenerateLLMsTextParams.__annotate__  sI      c]	 
 4.(  D>   $D>0 r1   r2   )r3   r4   r5   r6   r7   r  r  r  r  r8   r9   r:   r;   s   @r!   r  r    s(       G#(L E,0  r1   r  c                   H   a  ] tR tRt o Rt^tRt^tRtRt	Rt
V 3R ltRtV tR# )V1DeepResearchParamsi  z-
Parameters for the deep research operation.
i  Nc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r(   r  	timeLimitr  analysisPromptr   /_V1DeepResearchParams__experimental_streamSteps)r   r   r,   r   )r-   r.   s   "r!   r/   !V1DeepResearchParams.__annotate__  sk      sm	 
 }"  c]  SM(  3-&  !)5 r1   r2   )r3   r4   r5   r6   r7   r  r  r  r  r   r  r8   r9   r:   r;   s   @r!   r  r    s2       H"IG$(N"&L15  r1   r  c                   4   a  ] tR tRt o RtRtV 3R ltRtV tR# )V1DeepResearchResponsei  z,
Response from the deep research operation.
Nc                N   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[S[,          ;R&   # r(   r   r  r   r   r,   r   )r-   r.   s   "r!   r/   #V1DeepResearchResponse.__annotate__  s.      M	 
 	G  C= r1   r2   )	r3   r4   r5   r6   r7   r   r8   r9   r:   r;   s   @r!   r  r    s     
  E  r1   r  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )V1DeepResearchStatusResponsei  z3
Status response from the deep research operation.
Nc                $  < V ^8  d   Qh/ S[ ;R&   S[S[S[S[3,          ,          ;R&   S[;R&   S[S[,          ;R&   S[;R&   S[;R&   S[;R&   S[S[S[S[3,          ,          ;R&   S[S[S[S[3,          ,          ;R	&   S[S[,          ;R
&   # )r(   r   r  r  r   r  currentDepthr  
activitiesrU  	summaries)r   r   r   r,   r   r   r   )r-   r.   s   "r!   r/   )V1DeepResearchStatusResponse.__annotate__  s      M	 
 4S>
")  K  C=  N    M  T#s(^$$  $sCx.!!  Cy r1   r2   )
r3   r4   r5   r6   r7   r  r   r8   r9   r:   r;   s   @r!   r  r    s      &*DE  r1   r  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )V1GenerateLLMsTextResponsei  z-Response from LLMs.txt generation operations.TNc                N   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[S[,          ;R&   # r  r  )r-   r.   s   "r!   r/   'V1GenerateLLMsTextResponse.__annotate__  s-       	G  C=	 r1   r2   )
r3   r4   r5   r6   r7   r   r   r8   r9   r:   r;   s   @r!   r  r    s     7GE	  r1   r  c                   0   a  ] tR tRt o RtV 3R ltRtV tR# )$V1GenerateLLMsTextStatusResponseDatai  Nc                B   < V ^8  d   Qh/ S[ ;R&   S[S[ ,          ;R&   # )r(   llmstxtllmsfulltxt)r,   r   )r-   r.   s   "r!   r/   1V1GenerateLLMsTextStatusResponseData.__annotate__  s     L #% r1   r2   )r3   r4   r5   r6   r  r8   r9   r:   r;   s   @r!   r  r    s     !%K  r1   r  c                   <   a  ] tR tRt o RtRtRtRtV 3R ltRt	V t
R# ) V1GenerateLLMsTextStatusResponsei  z4Status response from LLMs.txt generation operations.TNc                   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[R,          ;R&   S[S[,          ;R&   S[;R&   # )r(   r   r  r  r   r  rV  )r   r   r  r   r,   )r-   r.   s   "r!   r/   -V1GenerateLLMsTextStatusResponse.__annotate__  sS       7
8?  788	 
 C=  N r1   r2   )r3   r4   r5   r6   r7   r   r  r   r8   r9   r:   r;   s   @r!   r  r    s     >G;?DE  r1   r  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )re  i  z%
Response from the search operation.
Nc                   < V ^8  d   Qh/ S[ ;R&   S[S[S[S[3,          ,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # rg  )r   r   r   r,   r   r   )r-   r.   s   "r!   r/   rh    sM      M	 
 tCH~
  c]!  C= r1   r2   )
r3   r4   r5   r6   r7   r   r   r8   r9   r:   r;   s   @r!   re  re    s     
 "GE  r1   c                   t   a  ] tR tRt o RtRt]P                  ! RRR7      tRt	Rt
RtRtRtRtV 3R ltRtV tR# )	rL  i  z'
Parameters for the extract operation.
Nr}   rP   Fc                  < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[S[S[3,          ,          ;R&   # )	r(   r*   r   system_promptallow_external_linksenable_web_searchrN  show_sourcesr   )r   r,   r   r   r   )r-   r.   s   "r!   r/   rQ    s      SM 	 
 3-F  C='  #4.0   ~-  d^+  4.(  DcN#* r1   r2   )r3   r4   r5   r6   r7   r*   rY   rZ   r   r  r  r  rN  r  r   r8   r9   r:   r;   s   @r!   rL  rL    sH      !F"*..X"FL#'M+0(-&+O#(L&*E  r1   c            *       V  a  ] tR tRt o RtRtRV 3R lR lltRRRRR	RR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR/V 3R lR lltRRR RR!RR"RR#RRRRRR$R/V 3R% lR& lltV 3R' lR( lt	V 3R) lR* lt
RV 3R, lR- lltRV 3R. lR/ lltR0RR1RR2RR3RRRR4RR5RR6RR7RR$RR8RR9RR:RR;RR<RR=RR>RRRR?^R@R/V 3RA lRB lltR0RR1RR2RR3RRRR4RR5RR6RR7RR$RR8RR9RR:RR;RR<RR=RR>RRRR@R/V 3RC lRD lltV 3RE lRF ltV 3RG lRH ltV 3RI lRJ ltR0RR1RR2RR3RRRR4RR5RR6RR7RR$RR8RR9RR:RR;RR<RR=RR>RRRR@R/V 3RK lRL lltRMRR7RRNRRORRRRRRPRRR/V 3RQ lRR lltRRRRR	RR
RRRRRRRRRRRRRRRRRRRRRRRRRRSRR?^R>RRRR@R/V 3RT lRU lltRRRRR	RR
RRRRRRRRRRRRRRRRRRRRRRRRRRSRR>RR@RRR/V 3RV lRW lltRRRRR	RR
RRRRRRRRRRRRRRRRRRRRRRRRRRSRR>RRRR@R/V 3RX lRY lltV 3RZ lR[ ltV 3R\ lR] ltRR^RR_RR`RR6R+RaR+RbR+RSR/V 3Rc lRd llltV 3Re lRf ltRR^RR_RR`RR6R+RaR+RbR+RSR/V 3Rg lRh llltRiRRjRRkRRlR/V 3Rm lRn lltRiRRjRRkRRlR/V 3Ro lRp lltV 3Rq lRr ltRV 3Rs lRt lltRV 3Ru lRv llt RV 3Rw lRx llt!RV 3Ry lRz llt"V 3R{ lR| lt#V 3R} lR~ lt$V 3R lR lt%R2RRRRiRRRR`RRRRRRR/V 3R lR llt&R2RRRRiRRRR`RRR/V 3R lR llt'V 3R lR lt(V 3R lR lt)R t*RR lt+R t,RR lt-R t.R t/R t0RR lt1RR lt2Rt3V t4R# )V1FirecrawlAppi  a  
Legacy v1 Firecrawl client for backward compatibility.

This class provides the complete v1 API implementation including:
- URL scraping with various formats and options
- Website crawling with monitoring capabilities
- Batch scraping operations
- Search functionality
- Data extraction with LLM integration
- Deep research capabilities
- LLMs.txt generation

This is used by the unified client to provide version-specific access
through app.v1.method_name() patterns.
a  Schema contains invalid structure for OpenAI: object type with no 'properties' defined but 'additionalProperties: true' (schema-less dictionary not supported by OpenAI). Please define specific properties for your object. Note: Recursive schemas using '$ref' are supported.Nc                J   < V ^8  d   QhRS[ S[,          RS[ S[,          RR/# )r(   api_keyapi_urlreturnN)r   r,   )r-   r.   s   "r!   r/   V1FirecrawlApp.__annotate__  s0     Q Q Qx} QX\ Qr1   c                ^   T;'       g    \         P                  ! R4      V n        T;'       g    \         P                  ! RR4      V n        RV P                  9   d/   V P                  f!   \        P                  R4       \        R4      h\        P                  RV P                   24       R# )	z
Initialize the V1FirecrawlApp instance with API key, API URL.

Args:
    api_key (Optional[str]): API key for authenticating with the Firecrawl API.
    api_url (Optional[str]): Base URL for the Firecrawl API.
FIRECRAWL_API_KEYFIRECRAWL_API_URLhttps://api.firecrawl.devzapi.firecrawl.devNz%No API key provided for cloud servicezNo API key providedz)Initialized V1FirecrawlApp with API URL: )r   getenvr  r  loggerr   
ValueErrordebug)selfr  r  s   &&&r!   __init__V1FirecrawlApp.__init__  s     @@")),?"@]]")),?A\"] $,,.4<<3GNNBC233@OPr1   r   rt   include_tagsexclude_tagsonly_main_contentwait_forr   r   r   r   skip_tls_verificationremove_base64_images	block_adsr   	parse_pdfrc   json_optionsrf   change_tracking_optionsmax_agestore_in_cachezero_data_retentionc          /        < V ^8  d   QhRS[ RS[S[S[R,          ,          ,          RS[S[S[ S[ 3,          ,          RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          /# )r(   r^   r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  r  rf   r  r  r  r  r  r   r   )r,   r   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r|   r   r   )r-   r.   s   "r!   r/   r    s    U7 U7U7 d7  ,g  $h  i  j	U7
 d38n-U7 #49-U7 #49-U7  (~U7 smU7 c]U7 /0U7 TNU7 $,D>U7 #+4.U7  ~U7  G$JKL!U7"  ~#U7$ l+%U7& #<0'U7( d57I=Zgiv  yG  IW  Yr  t  *  $@  A  B)U7* &..E%F+U7, c]-U7. %TN/U70 "*$1U72 *#.3U7r1   c                  V P                  VR4       V P                  4       pRVRR\         2/pV'       d   VVR&   V'       d   VVR&   V'       d   VVR&   V'       d   VVR&   Ve   VVR
&   V'       d   VVR&   V'       d   VVR&   V	'       d   V	P                  RRR7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   V'       d   VVR&   Ve   VVR&   Vex   V P	                  V4      p\        V\        4      '       d#   RV9   d   V P	                  VR,          4      VR&   \        V\        4      '       d   TMVP                  RRR7      VR&   Vex   V P	                  V4      p\        V\        4      '       d#   RV9   d   V P	                  VR,          4      VR&   \        V\        4      '       d   TMVP                  RRR7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  RRR7      NK0  	  upVR&   V'       d/   \        V\        4      '       d   TMVP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   VP                  V4       RV9   dG   VR,          '       d8   RVR,          9   d*   V P	                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P	                  VR,          R,          4      VR,          R&   \        P                  ! V P                   R2TTVe   VR,          ^,           MR	R 7      pVP                  ^8X  dl    VP                  4       pVP                  R!4      '       d   R"V9   d   \        R'/ VR",          B # R#V9   d   \        R$VR#,           24      h\        R$V 24      hV P!                  VR&4       R	# u upi   \         d    \        R%4      hi ; i)(ag  
Scrape and extract content from a URL.

Args:
  url (str): Target URL to scrape
  formats (Optional[List[Literal["markdown", "html", "rawHtml", "content", "links", "screenshot", "screenshot@fullPage", "extract", "json"]]]): Content types to retrieve (markdown/html/etc)
  headers (Optional[Dict[str, str]]): Custom HTTP headers
  include_tags (Optional[List[str]]): HTML tags to include
  exclude_tags (Optional[List[str]]): HTML tags to exclude
  only_main_content (Optional[bool]): Extract main content only
  wait_for (Optional[int]): Wait for a specific element to appear
  timeout (Optional[int]): Request timeout (ms)
  location (Optional[LocationConfig]): Location configuration
  mobile (Optional[bool]): Use mobile user agent
  skip_tls_verification (Optional[bool]): Skip TLS verification
  remove_base64_images (Optional[bool]): Remove base64 images
  block_ads (Optional[bool]): Block ads
  proxy (Optional[Literal["basic", "stealth", "auto"]]): Proxy type (basic/stealth)
  extract (Optional[JsonConfig]): Content extraction settings
  json_options (Optional[JsonConfig]): JSON extraction settings
  actions (Optional[List[Union[WaitAction, ScreenshotAction, ClickAction, WriteAction, PressAction, ScrollAction, ScrapeAction, ExecuteJavascriptAction, PDFAction]]]): Actions to perform
  change_tracking_options (Optional[ChangeTrackingOptions]): Change tracking settings
  zero_data_retention (Optional[bool]): Whether to delete data after scrape is done


Returns:
  ScrapeResponse with:
  * Requested content formats
  * Page metadata
  * Extraction results
  * Success/error status

Raises:
  Exception: If scraping fails

scrape_urlr^   rO  python-sdk@r   rt   r   r   Nr   r   r   Tby_aliasexclude_noner   r   r   r   r   r   r   r}   rc   r   rf   r   r   r   zeroDataRetention
/v1/scrape     @@rt   rO   r   r   r  r   Failed to scrape URL. Error: +Failed to parse Firecrawl response as JSON.z
scrape URLr2   )_validate_kwargs_prepare_headersversiondict_ensure_schema_dict
isinstanceupdaterequestspostr  status_coderO   getr   r   r  _handle_error)r  r^   r   rt   r  r  r  r  r   r   r   r  r  r  r   r  rc   r  rf   r  r  r  r  kwargs_headersscrape_paramsactionresponseresponse_jsons   &&$$$$$$$$$$$$$$$$$$$$$,     r!   r  V1FirecrawlApp.scrape_url  sc   | 	fl3((* 3G9-
 '.M)$'.M)$+7M-(+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'" (1M*%..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$"PZ[rtxPyPy5L  @W  @\  @\  fj  y}  @\  @~M12&-M(#%,:M.)*1DM-.V$%-	*B*BxS`ajSkGk151I1I-XaJbckJl1mM)$X.M)mM.J.Jx[hiv[wOw595M5Mm\iNjksNt5uM-(2 ==||nJ'-4-@Wv%)d	
 3&	O ( $$Y//Fm4K+DmF.CDD-#&CMRYDZC[$\]]#&CM?$STT x6K (UD  O MNNOs   !4O"$&O' O' $*O' 'O>r  r`  ra  rb  rn   scrape_optionsc                   < V ^8  d   QhRS[ RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[,          R	S[S[,          R
S[/
# )r(   r_  r  r`  ra  rb  rn   r   r   r  r  )r,   r   r   r   re  )r-   r.   s   "r!   r/   r    s     ]3 ]3]3 C=	]3
 #]3 SM]3 3-]3 c]]3 sm]3 c]]3 %_5]3 *]3r1   c               2   V P                  V
R4       / pVe   W+R&   Ve   W;R&   Ve   WKR&   Ve   W[R&   Ve   WkR&   Ve   W{R&   Ve   WR	&   V	e   V	P                  R
R
R7      VR&   VP                  V
4       VP                  R4      p\	        RRV/VB pVP                  R
R
R7      pR\
         2VR&   V'       d   WR&   \        P                  ! V P                   R2RRV P                   2/VR7      pVP                  ^8X  de    VP                  4       pVP                  R4      '       d   RV9   d   \        R/ VB # RV9   d   \        RVR,           24      h\        RV 24      hV P                  VR4       R#   \         d    \        R4      hi ; i)a  
Search for content using Firecrawl.

Args:
    query (str): Search query string
    limit (Optional[int]): Max results (default: 5)
    tbs (Optional[str]): Time filter (e.g. "qdr:d")
    filter (Optional[str]): Custom result filter
    lang (Optional[str]): Language code (default: "en")
    country (Optional[str]): Country code (default: "us") 
    location (Optional[str]): Geo-targeting
    timeout (Optional[int]): Request timeout in milliseconds
    scrape_options (Optional[ScrapeOptions]): Result scraping configuration
    **kwargs: Additional keyword arguments for future compatibility

Returns:
    SearchResponse: Response containing:
        * success (bool): Whether request succeeded
        * data (List[FirecrawlDocument]): Search results
        * warning (Optional[str]): Warning message if any
        * error (Optional[str]): Error message if any

Raises:
    Exception: If search fails or response cannot be parsed
r   Nr  r`  ra  rb  rn   r   r   Tr  r$  integrationr_  r  rO  
/v1/searchAuthorizationBearer rt   rO   r   r  r   zSearch failed. Error: r  r2   )r  r  r  r  rZ  r  r  r  r  r  r  rO   re  r   r  r  )r  r_  r  r`  ra  rb  rn   r   r   r  r  search_params_integrationfinal_paramsparams_dictr  r  s   &&$$$$$$$$,      r!   r   V1FirecrawlApp.search  s   N 	fh/  %*'"?#&% &,(#$(&!'.)$(0*%'.)$%-;-@-@$]a-@-bM/* 	V$$((7 &CEC]C"''D'I"-gY 7H)5& ==||nJ'$~&>?
 3&	O ( $$Y//Fm4K+<m<<-#&<]7=S<T$UVV#&<]O$LMM x2  O MNNOs   &E? /E? *E? ?Fc                    < V ^8  d   QhRS[ /# r(   r  rs  )r-   r.   s   "r!   r/   r    s     = ="7 =r1   c                   V P                  4       pV P                  V P                   R2V4      pVP                  ^8X  de    VP	                  4       pVP                  R4      '       d   RV9   d   \        R	/ VB # RV9   d   \        RVR,           24      h\        RV 24      hV P                  VR4       R#   \         d    \        R4      hi ; i)
z1Get current credit usage and billing period (v1)./v1/team/credit-usager   r  r   z#Failed to get credit usage. Error: r  zget credit usageNr2   )
r  _get_requestr  r  rO   r  rs  r   r  r  r  r  r  r  s   &   r!   get_credit_usageV1FirecrawlApp.get_credit_usage  s    ((*$$||n12

 3&	O ( $$Y//Fm4K0A=AA-#&I-X_J`Ia$bcc#&I-$YZZ x);<  O MNNO   &B9 )B9 ;*B9 9Cc                    < V ^8  d   QhRS[ /# r  r  )r-   r.   s   "r!   r/   r    s     < <!5 <r1   c                   V P                  4       pV P                  V P                   R2V4      pVP                  ^8X  de    VP	                  4       pVP                  R4      '       d   RV9   d   \        R	/ VB # RV9   d   \        RVR,           24      h\        RV 24      hV P                  VR4       R#   \         d    \        R4      hi ; i)
z0Get current token usage and billing period (v1)./v1/team/token-usager   r  r   z"Failed to get token usage. Error: r  zget token usageNr2   )
r  r   r  r  rO   r  r  r   r  r  r!  s   &   r!   get_token_usageV1FirecrawlApp.get_token_usage  s    ((*$$||n01

 3&	O ( $$Y//Fm4K/@-@@-#&HW^I_H`$abb#&H$XYY x):;  O MNNOr$  Fc                &   < V ^8  d   QhRS[ RS[/# r(   
by_api_keyr  )r   r  )r-   r.   s   "r!   r/   r  3  s      H Hd HGf Hr1   c                   V P                  4       pV P                   R2V'       d   RMR,           pV P                  W24      pVP                  ^8X  de    VP	                  4       pVP                  R4      '       d   RV9   d   \        R/ VB # RV9   d   \        RVR,           24      h\        RV 24      hV P                  VR	4       R
#   \         d    \        R4      hi ; i)z!Get historical credit usage (v1).z /v1/team/credit-usage/historical?byApiKey=true r   r  r   z.Failed to get historical credit usage. Error: r  zget credit usage historicalNr2   )
r  r  r   r  rO   r  r  r   r  r  r  r-  r  r^   r  r  s   &&    r!   get_credit_usage_historical*V1FirecrawlApp.get_credit_usage_historical3  s    ((*>?WaCSgij$$S33&	O ( $$Y//I4N:K]KK-#&TUbcjUkTl$mnn#&TUbTc$dee x)FG  O MNNO   &C ;C *C C"c                &   < V ^8  d   QhRS[ RS[/# r,  )r   r  )r-   r.   s   "r!   r/   r  G  s      G GT GFd Gr1   c                   V P                  4       pV P                   R2V'       d   RMR,           pV P                  W24      pVP                  ^8X  de    VP	                  4       pVP                  R4      '       d   RV9   d   \        R/ VB # RV9   d   \        RVR,           24      h\        RV 24      hV P                  VR	4       R
#   \         d    \        R4      hi ; i)z Get historical token usage (v1).z/v1/team/token-usage/historicalr/  r0  r   r  r   z-Failed to get historical token usage. Error: r  zget token usage historicalNr2   )
r  r  r   r  rO   r  r  r   r  r  r1  s   &&    r!   get_token_usage_historical)V1FirecrawlApp.get_token_usage_historicalG  s    ((*=>V`BRfhi$$S33&	O ( $$Y//I4N9JMJJ-#&STabiTjSk$lmm#&STaSb$cdd x)EF  O MNNOr4  include_pathsexclude_paths	max_depthmax_discovery_depthallow_backward_linkscrawl_entire_domainr  ignore_sitemapr   deduplicate_similar_urlsignore_query_parametersregex_on_full_urlr(  allow_subdomainsmax_concurrencypoll_intervalidempotency_keyc          ,        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[/# )r(   r^   r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rD  r  rE  rF  r  	r,   r   r   r   r   r   r   rr   r1  )r-   r.   s   "r!   r/   r  [  se    @< @<@<  S	*	@<
  S	*@< C=@< &c]@< }@< 'tn@< &d^@< 'tn@< !@< !1@< %_ 456@< #+4.@<  "*$!@<" $D>#@<$ }%@<& #4.'@<( "#)@<* &d^+@<,  }-@<. "#/@<2 
3@<r1   c                  V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   M	Ve   VVR	&   V	e   V	VR
&   V
e   V
VR&   Ve   VP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   VP                  V4       VP                  R4      p\	        R/ VB pVP                  RRR7      pVVR&   R\
         2VR&   V'       d   VVR&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d4    VP                  4       P                  R4      pT P                  TTT4      # V P                  VR4       R#    \        R4      h; i) a  
Crawl a website starting from a URL.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    delay (Optional[int]): Delay in seconds between scrapes
    allow_subdomains (Optional[bool]): Follow subdomains
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    poll_interval (Optional[int]): Seconds between status checks (default: 2)
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    CrawlStatusResponse with:
    * Crawling status and progress
    * Crawled page contents
    * Success/error information

Raises:
    Exception: If crawl fails
	crawl_urlNr  r  r  r  r  r!  r   r"  r#  Tr  r$  r   r%  r&  r'  r(  r*  r)  r  r  r^   r  rO  	/v1/crawlr  r  start crawl jobr2   )r  r  r  r  r  r  r  _post_requestr  r  rO   r   _monitor_job_statusr  )r  r^   r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rD  r  rE  rF  r  crawl_paramsr  r  r  rt   r  r  s   &&$$$$$$$$$$$$$$$$$$$$,       r!   rJ  V1FirecrawlApp.crawl_url[  sX   ~ 	fk2 $+8L($+8L( '0L$*0CL,-$)L!*0CL,-!-1EL-.+1EL-.%,:L)%,:,?,?\`,?,aL)&-L##/5ML12".4KL01(->L)*$)L!'.>L*+&-<L)**0CL,-F##''6 %4|4"''D'I E"-gY 7H)5K& ''8%%i&@+wW3&P]]_((. ++BGGx):;	P"MOOs   *F0 0F=c          *        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[/# )r(   r^   r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rD  r  rF  r  	r,   r   r   r   r   r   r   rr   r-  )r-   r.   s   "r!   r/   r    sV    z< z<z<  S	*	z<
  S	*z< C=z< &c]z< }z< 'tnz< &d^z< 'tnz< !z< !1z< %_ 456z< #+4.z<  "*$!z<" $D>#z<$ }%z<& #4.'z<( "#)z<* &d^+z<, "#-z<0 
1z<r1   c                  V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   M	Ve   VVR	&   V	e   V	VR
&   V
e   V
VR&   Ve   VP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   VP                  V4       \        R/ VB pVP                  RRR7      pVVR&   R\         2VR&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d    \        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i)a  
Start an asynchronous crawl job.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[V1ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, V1WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    delay (Optional[int]): Delay in seconds between scrapes
    allow_subdomains (Optional[bool]): Follow subdomains
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    V1CrawlResponse with:
    * success - Whether crawl started successfully
    * id - Unique identifier for the crawl job
    * url - Status check URL for the crawl
    * error - Error message if start failed

Raises:
    Exception: If crawl initiation fails
async_crawl_urlNr  r  r  r  r  r!  r   r"  r#  Tr  r$  r   r%  r&  r'  r(  r*  r)  r  r^   r  rO  rK  r  rL  r2   )r  r  r  r  r  r  rM  r  r  r-  rO   r   r  )r  r^   r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rD  r  rF  r  rO  r  r  rt   r  s   &&$$$$$$$$$$$$$$$$$$$,     r!   rT  V1FirecrawlApp.async_crawl_url  s%   | 	f&78 $+8L($+8L( '0L$*0CL,-$)L!*0CL,-!-1EL-.+1EL-.%,:L)%,:,?,?\`,?,aL)&-L##/5ML12".4KL01(->L)*$)L!'.>L*+&-<L)**0CL,-F# %4|4"''D'I E"-gY 7H ''8%%i&@+wW3&P&999 x):;P"MOOs   E9 9Fc                &   < V ^8  d   QhRS[ RS[/# r(   r  r  r,   r1  )r-   r.   s   "r!   r/   r  Y  s      Q? Q?S Q?-B Q?r1   c                   RV 2pV P                  4       pV P                  V P                   V 2V4      pVP                  ^8X  Ed    VP	                  4       pTR,          R8X  d   RT9   d   TR,          pRT9   d   \        TR,          4      ^ 8X  d   MTP                  R4      pT'       g   \        P                  R4       M| T P                  Ys4      pTP                  ^8w  d$   \        P                  RTP                   24       M6 TP	                  4       p	TP                  T	P                  R. 4      4       T	pK  YeR&   RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      /pRT9   d   TR,          TR&   RT9   d   TR,          TR&   \        RRRT9   d   RMR/TB # V P                  VR4       R
#    \        R4      h; i   \        R4      h; i  \
         d%   p
\        P                  R	T
 24        R
p
?
EK  R
p
?
ii ; i)a  
Check the status and results of a crawl job.

Args:
    id: Unique identifier for the crawl job

Returns:
    V1CrawlStatusResponse containing:

    Status Information:
    * status - Current state (scraping/completed/failed/cancelled)
    * completed - Number of pages crawled
    * total - Total pages to crawl
    * creditsUsed - API credits consumed
    * expiresAt - Data expiration timestamp
    
    Results:
    * data - List of crawled documents
    * next - URL for next page of results (if paginated)
    * success - Whether status check succeeded
    * error - Error message if failed

Raises:
    Exception: If status check fails

/v1/crawl/r  r  rv   r  r  Expected 'next' URL is missing.Failed to fetch next page: !Error during pagination request: Nr  r  r  r   r   FTcheck crawl statusr2   )r  r   r  r  rO   r   lenr  r  r   r   extendr1  r  r  r  endpointrt   r  status_datar  next_urlstatus_response	next_dataes   &&         r!   check_crawl_status!V1FirecrawlApp.check_crawl_statusY  sN   4  t$'')$$~hZ%@'J3&P&mmo 8$3[(&v.D K/{623q8!#.??6#:'"NN+LM!".2.?.?.RO.::cA &/J?KfKfJg-h i %`,;,@,@,B	 !KK	fb(AB*3K +/' +//(31[__[9{}=[__[9/H +%$/$8!$#.v#6 ( !(K!7T 
 x)=>aP"MOO$`&/2]&_ _  ) ""LL+LQC)PQ!"s=   	G= AH H #H =H
HH I(IIc                &   < V ^8  d   QhRS[ RS[/# rW  r,   r;  )r-   r.   s   "r!   r/   r    s     ? ?S ?-B ?r1   c                   V P                  4       pV P                  V P                   RV R2V4      pVP                  ^8X  d    \	        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i)a  
Returns information about crawl errors.

Args:
    id (str): The ID of the crawl job

Returns:
    V1CrawlErrorsResponse containing:
    * errors (List[Dict[str, str]]): List of errors with fields:
        - id (str): Error ID
        - timestamp (str): When the error occurred
        - url (str): URL that caused the error
        - error (str): Error message
    * robotsBlocked (List[str]): List of URLs blocked by robots.txt

Raises:
    Exception: If error check fails
rZ  /errorsr  zcheck crawl errorsNr2   r  r   r  r  r;  rO   r   r  r  r  rt   r  s   &&  r!   check_crawl_errors!V1FirecrawlApp.check_crawl_errors  s    & '')$$~Zt7%KWU3&P,?x}}?? x)=>P"MOO   A2 2A?c                <   < V ^8  d   QhRS[ RS[S[ S[3,          /# rW  r,   r   r   )r-   r.   s   "r!   r/   r    s#     = =s =tCH~ =r1   c                    V P                  4       pV P                  V P                   RV 2V4      pVP                  ^8X  d    VP	                  4       # V P                  VR4       R#    \        R4      h; i)-  
Cancel an asynchronous crawl job.

Args:
    id (str): The ID of the crawl job to cancel

Returns:
    Dict[str, Any] containing:
    * success (bool): Whether cancellation was successful
    * error (str, optional): Error message if cancellation failed

Raises:
    Exception: If cancellation fails
rZ  r  zcancel crawl jobN)r  _delete_requestr  r  rO   r   r  ro  s   &&  r!   cancel_crawlV1FirecrawlApp.cancel_crawl  sz     '')''4<<.
2$(GQ3&P}}& x);<P"MOOs   A( (A5c          *        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RR/# )r(   r^   r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rD  r  rF  r  V1CrawlWatcher)r,   r   r   r   r   r   r   rr   )r-   r.   s   "r!   r/   r    sV    S9 S9S9 $DI.	S9
 $DI.S9  }S9 "*#S9 C=S9 #+4.S9 "*$S9 #+4.S9 %TNS9 %_5S9 eC$89:S9 '/tnS9  &.d^!S9"  (~#S9$ C=%S9& 'tn'S9( &c])S9* "*$+S9, &c]-S90 
1S9r1   c               $   V P                   ! V3/ RVbRVbRVbRVbRVbRVbRVbRV	bR	V
bR
VbRVbRVbRVbRVbRVbRVbRVbRVbRVbVB pVP                  '       d)   VP                  '       d   \        VP                  V 4      # \	        R4      h)am  
Initiate a crawl job and return a CrawlWatcher to monitor the job via WebSocket.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[V1ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, V1WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    delay (Optional[int]): Delay in seconds between scrapes
    allow_subdomains (Optional[bool]): Follow subdomains
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    V1CrawlWatcher: An instance to monitor the crawl job via WebSocket

Raises:
    Exception: If crawl job fails to start
r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rD  r  rF  Crawl job failed to start)rT  r   r  r{  r   )r  r^   r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rD  r  rF  r  crawl_responses   &&$$$$$$$$$$$$$$$$$$$, r!   crawl_url_and_watch"V1FirecrawlApp.crawl_url_and_watch  s   r --
'
 (
  	

 !4
 
 "6
 !4
 "6
 *
 *
 
 &>
 %<
 0
  !
" .#
$ ,%
& !4'
( ,+
. !!!n&7&7&7!."3"3T::788r1   r   include_subdomainssitemap_only	use_indexc                   < V ^8  d   QhRS[ RS[S[ ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[/
# )r(   r^   r   r?  r  r  r  r   r  r   r  )r,   r   r   r   rl   rH  )r-   r.   s   "r!   r/   r  7  s     [0 [0[0 SM	[0
 %TN[0 !)[0 #4.[0 C=[0 c][0  ~[0 /0[0 '[0r1   c               6   V P                  V
R4       / pVe   W+R&   Ve   W;R&   Ve   WKR&   Ve   W[R&   Ve   WkR&   Ve   W{R&   Ve   WR	&   V	e   V	P                  R
R
R7      VR&   VP                  V
4       VP                  R4      p\	        R/ VB pVP                  R
R
R7      pWR&   R\
         2VR&   V'       d   WR&   \        P                  ! V P                   R2RRV P                   2/VR7      pVP                  ^8X  de    VP                  4       pVP                  R4      '       d   RV9   d   \        R/ VB # RV9   d   \        RVR,           24      h\        RV 24      hV P                  VR4       R#   \         d    \        R4      hi ; i)a  
Map and discover links from a URL.

Args:
    url (str): Target URL to map
    search (Optional[str]): Filter pattern for URLs
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    include_subdomains (Optional[bool]): Include subdomain links
    sitemap_only (Optional[bool]): Only use sitemap.xml
    limit (Optional[int]): Maximum URLs to return
    timeout (Optional[int]): Request timeout in milliseconds
    **kwargs: Additional parameters to pass to the API

Returns:
    V1MapResponse: Response containing:
        * success (bool): Whether request succeeded
        * links (List[str]): Discovered URLs
        * error (Optional[str]): Error message if any

Raises:
    Exception: If mapping fails or response cannot be parsed
map_urlNr   r#  rC  rD  r  r   rE  Tr  r   r  r^   r  rO  /v1/mapr  r  r  r   rb   r   zMap failed. Error: r  mapr2   )r  r  r  r  rA  r  r  r  r  r  r  rO   rH  r   r  r  )r  r^   r   r?  r  r  r  r   r  r   r  
map_paramsr  r  r  r  r  s   &&$$$$$$$$,      r!   r  V1FirecrawlApp.map_url7  s   H 	fi0 
 #)x %*8').@*+#(4}%"'w$+y! %.z"%-]]Dt]%TJz" 	&!!~~m4 #0Z0"''D'I E"-gY 7H)5& ==||nG$$~&>?
 3&	O ( $$Y//G}4L(9=99-#&9-:P9Q$RSS#&9-$IJJ x/  O MNNOs   
&F 1F *F Fr   c          .        < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# )r(   urlsr   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   rE  rD  r  rF  r  	r_   r`   ra   r   rb   rd   r   rc   rO   r   r   r,   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r%   r	  )r-   r.   s   "r!   r/   r    s    KC KC3iKC $w  (Q   R  S  T	KC
 $sCx.)KC tCy)KC tCy)KC $D>KC 3-KC #KC +,KC KC  (~KC 'tnKC D>KC   FGH!KC" ,'#KC$ |,%KC& $u\3E}Vcer  uC  ES  Un  p{  &{   |  }  ~'KC( ')KC*  }+KC, "#-KC. &d^/KC0 "#1KC4 
%5KCr1   c                  V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  R
R
R7      NK0  	  upVR&   Ve   VP                  R
R
R7      VR&   Ve   VVR&   Ve   VVR&   VP	                  V4       \        R / VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d4    VP                  4       P                  R4      pT P                  TTT4      # V P                  VR4       R# u upi    \        R4      h; i)!aH  
Batch scrape multiple URLs and monitor until completion.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    poll_interval (Optional[int]): Seconds between status checks (default: 2)
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    V1BatchScrapeStatusResponse with:
    * Scraping status and progress
    * Scraped content for each URL
    * Success/error information

Raises:
    Exception: If batch scrape fails
batch_scrape_urlsNr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r)  r  r  r  rO  /v1/batch/scraper  r  start batch scrape jobr2   )r  r  r  r   r  r   r  r  rM  r  r  rO   r  r   rN  r  )r  r  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   rE  rD  r  rF  r  r	  r
  r  r  r  r  s   &&$$$$$$$$$$$$$$$$$$$$$,      r!   r   V1FirecrawlApp.batch_scrape_urls  s   @ 	f&9: '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%*ZZDZ%QM'"&.=M*+*1DM-. 	V$ &66"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''8%%6F&GV]^3&P]]_((. ++BGGx)ABC (U:P"MOOs   4M& M+ +M8c          -        < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# )r(   r  r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   rD  rF  r  r  r  r   r   r,   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r%   r  )r-   r.   s   "r!   r/   r  !  s    JC JC3iJC $w  (Q   R  S  T	JC
 $sCx.)JC tCy)JC tCy)JC $D>JC 3-JC #JC +,JC JC  (~JC 'tnJC D>JC   FGH!JC" ,'#JC$ |,%JC& $u\3E}Vcer  uC  ES  Un  p{  &{   |  }  ~'JC( ')JC* "#+JC, "#-JC. &d^/JC2 
3JCr1   c                  V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  R
R
R7      NK0  	  upVR&   Ve   VP                  R
R
R7      VR&   Ve   VVR&   Ve   VVR&   VP	                  V4       \        R/ VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d    \        R/ VP                  4       B # V P                  VR4       R# u upi    \        R4      h; i) av  
Initiate a batch scrape job asynchronously.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    V1BatchScrapeResponse with:
    * success - Whether job started successfully
    * id - Unique identifier for the job
    * url - Status check URL
    * error - Error message if start failed

Raises:
    Exception: If job initiation fails
async_batch_scrape_urlsNr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r)  r  r  r  rO  r  r  r  r2   )r  r  r  r   r  r   r  r  rM  r  r  r  rO   r   r  )r  r  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   rD  rF  r  r  r	  r
  r  r  r  s   &&$$$$$$$$$$$$$$$$$$$$,     r!   r  &V1FirecrawlApp.async_batch_scrape_urls!  s   @ 	f&?@ '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%*ZZDZ%QM'"&.=M*+*1DM-. 	V$ &66"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''8%%6F&GV]^3&P,?x}}?? x)ABA (U:P"MOOs   4M M Mc          -        < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RR/# )r(   r  r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   rD  r  rF  r  r{  r  r   )r   r,   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r%   )r-   r.   s   "r!   r/   r    s    JC JC3iJC $w  (Q   R  S  T	JC
 $sCx.)JC tCy)JC tCy)JC $D>JC 3-JC #JC +,JC JC  (~JC 'tnJC D>JC   FGH!JC" ,'#JC$ |,%JC& $u\3E}Vcer  uC  ES  Un  p{  &{   |  }  ~'JC( ')JC* "#+JC, &d^-JC. "#/JC2 
3JCr1   c               N   V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  R
R
R7      NK0  	  upVR&   Ve   VP                  R
R
R7      VR&   Ve   VVR&   Ve   VVR&   VP	                  V4       \        R / VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d`    \        R / VP                  4       B pVP                  '       d)   VP                  '       d   \        VP                  V 4      # \!        R4      hV P#                  VR4       R# u upi    \!        R4      h; i)!a8  
Initiate a batch scrape job and return a CrawlWatcher to monitor the job via WebSocket.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    V1CrawlWatcher: An instance to monitor the batch scrape job via WebSocket

Raises:
    Exception: If batch scrape job fails to start
batch_scrape_urls_and_watchNr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r)  r  r  r  rO  r   Batch scrape job failed to startr  r  r2   )r  r  r  r   r  r   r  r  rM  r  r  r  rO   r   r  r{  r   r  )r  r  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   rD  r  rF  r  r	  r
  r  r  r  r~  s   &&$$$$$$$$$$$$$$$$$$$$,      r!   r  *V1FirecrawlApp.batch_scrape_urls_and_watch  s   x 	f&CD '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%*ZZDZ%QM'"&.=M*+*1DM-. 	V$ &66"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''8%%6F&GV]^3&P!6!I!I!)))n.?.?.?).*;*;TBB#$FGG x)ABI (UBP"MOOs   4N <N N 3N N$c                &   < V ^8  d   QhRS[ RS[/# rW  r,   r	  )r-   r.   s   "r!   r/   r  9  s      <F <FC <F4O <Fr1   c                   RV 2pV P                  4       pV P                  V P                   V 2V4      pVP                  ^8X  Ed    VP	                  4       pTR,          R8X  d   RT9   d   TR,          pRT9   d   \        TR,          4      ^ 8X  d   MTP                  R4      pT'       g   \        P                  R4       M| T P                  Ys4      pTP                  ^8w  d$   \        P                  RTP                   24       M6 TP	                  4       p	TP                  T	P                  R. 4      4       T	pK  YeR&   \        R/ RRT9   d   RMRRTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      /	B # V P                  VR4       R
#    \        R4      h; i   \        R4      h; i  \
         d$   p
\        P                  R	T
 24        R
p
?
K  R
p
?
ii ; i)a   
Check the status of a batch scrape job using the Firecrawl API.

Args:
    id (str): The ID of the batch scrape job.

Returns:
    V1BatchScrapeStatusResponse: The status of the batch scrape job.

Raises:
    Exception: If the status check request fails.
/v1/batch/scrape/r  r  rv   r  r  r[  r\  r]  Nr   r   FTr  r  r  zcheck batch scrape statusr2   )r  r   r  r  rO   r   r_  r  r  r   r   r`  r	  r  ra  s   &&         r!   check_batch_scrape_status(V1FirecrawlApp.check_batch_scrape_status9  s0    'rd+'')$$~hZ%@'J3&P&mmo 8$3[(&v.D K/{623q8!#.??6#:'"NN+LM!".2.?.?.RO.::cA &/J?KfKfJg-h i %`,;,@,@,B	 !KK	fb(AB*3K +/'. 
G{$:5+//(31[__[9{}=[__[9//1
2 
 
 x)DEQP"MOO$`&/2]&_ _  ) ""LL+LQC)PQ!"s=   	G7 AH H #H 7HHH I"I  Ic                &   < V ^8  d   QhRS[ RS[/# rW  rk  )r-   r.   s   "r!   r/   r  w  s      F FC F4I Fr1   c                   V P                  4       pV P                  V P                   RV R2V4      pVP                  ^8X  d    \	        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i)a  
Returns information about batch scrape errors.

Args:
    id (str): The ID of the crawl job.

Returns:
    V1CrawlErrorsResponse containing:
    * errors (List[Dict[str, str]]): List of errors with fields:
      * id (str): Error ID
      * timestamp (str): When the error occurred
      * url (str): URL that caused the error
      * error (str): Error message
    * robotsBlocked (List[str]): List of URLs blocked by robots.txt

Raises:
    Exception: If the error check request fails
r  rm  r  zcheck batch scrape errorsNr2   rn  ro  s   &&  r!   check_batch_scrape_errors(V1FirecrawlApp.check_batch_scrape_errorsw  s    & '')$$~5Frd'%RT[\3&P,?x}}?? x)DEP"MOOrr  r*   r}   r  r  r  c                  < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[S[S[3,          ,          R	S[S[,          /	# 
r(   r  r*   r}   r  r  r  r  r   r  r   r   r,   r   r   r   rS  )r-   r.   s   "r!   r/   r    s     ~P ~P49%~P SM	~P
 SM~P $C=~P #+4.~P  (~~P #4.~P DcN+~P +3/~Pr1   c                  ^ RI p
V
P                  R\        ^R7       V P                  V	R4       V P	                  4       pV'       g   V'       g   \        R4      hV'       g   V'       g   \        R4      hV'       d   V P                  V4      pRT;'       g    . RVR	VR
VRVRR\        4        2/pV'       d   W,R&   V'       d   WLR&   V'       d   WR&   VP                  V	4        V P                  V P                   R2VV4      pVP                  ^8X  Ed    VP                  4       pTR,          '       d   TP                  R4      pT'       g   \        R4      h T P                  T P                   RT 2T4      pTP                  ^8X  dY    TP                  4       pTR,          R8X  d   \!        R"/ TB # TR,          R#9   d    \        RTR,           RTR,           24      hMT P#                  TR4       \$        P&                  ! ^4       K  \        RTR,           24      hV P#                  VR4        \!        RR R!7      #    \        R4      h; i   \        R4      h; i  \         d   p\        \)        T4      R4      hRp?ii ; i)$a  
Extract structured information from URLs.

.. deprecated::
    The extract endpoint is in maintenance mode and its use is discouraged.
    Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor
    to find a replacement.

Args:
    urls (Optional[List[str]]): URLs to extract from
    prompt (Optional[str]): Custom extraction prompt
    schema (Optional[Any]): JSON schema/Pydantic model
    system_prompt (Optional[str]): System context
    allow_external_links (Optional[bool]): Follow external links
    enable_web_search (Optional[bool]): Enable web search
    show_sources (Optional[bool]): Include source URLs
    agent (Optional[Dict[str, Any]]): Agent configuration
    **kwargs: Additional parameters to pass to the API

Returns:
    V1ExtractResponse[Any] with:
    * success (bool): Whether request succeeded
    * data (Optional[Any]): Extracted data matching schema
    * error (Optional[str]): Error message if any

Raises:
    ValueError: If prompt/schema missing or extraction fails
NThe extract endpoint is in maintenance mode and its use is discouraged. Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
stacklevelrc   #Either prompt or schema is required!Either urls or prompt is requiredr  r"  rN  rP  r}   rO  r  r*   r   r   /v1/extractr  r   r  )Job ID not returned from extract request./v1/extract/r  rv   Extract job 	. Error: r   zextract-statusFailed to extract. Error:   FzInternal server error.r   r   r2   rw   r  )warningswarnDeprecationWarningr  r  r  r  r"   r  rM  r  r  rO   r   r  r   rS  r  timesleepr,   )r  r  r*   r}   r  r  r  r  r   r  r  rt   request_datar  r  job_idre  rc  rg  s   &&$$$$$$$,         r!   rc   V1FirecrawlApp.extract  s   P 	%  	 	
 	fi0'')fBCCF@AA--f5F DJJB "60<fKM?3
 %+"+8($)! 	F#)	*))<<.,H
 ##s*T#==?D 	??!XXd^F!'(STT *.*;*;#||nLA#+ +66#=`.=.B.B.D  +84C'8'G;'G G!,X!6:Q!Q&/,{8?T>UU^_jkr_s^t0u&v v "R !..@PQ

1#&@g$PQQ""8Y7 !6NOOCT#&QSS`&/2]&_ _  	*SVS))	*s[   '2I' I *I' 9I' >I' I !I' :A?I' II' I$$I' 'J2JJc                6   < V ^8  d   QhRS[ RS[S[,          /# r(   r  r  r,   rS  r   )r-   r.   s   "r!   r/   r    s!     %* %* %*1B31G %*r1   c                   ^ RI pVP                  R\        ^R7       V P                  4       p V P	                  V P
                   RV 2V4      pVP                  ^8X  d    \        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i  \         d   p\        \        T4      R4      hRp?ii ; i)	a  
Retrieve the status of an extract job.

.. deprecated::
    The extract endpoint is in maintenance mode and its use is discouraged.
    Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor
    to find a replacement.

Args:
    job_id (str): The ID of the extract job.

Returns:
    ExtractResponse[Any]: The status of the extract job.

Raises:
    ValueError: If there is an error retrieving the status.
Nr  r  r  r  zget extract statusr  r2   )r  r  r  r  r   r  r  rS  rO   r   r  r  r,   )r  r  r  rt   r  rg  s   &&    r!   get_extract_status!V1FirecrawlApp.get_extract_status  s    $ 	%  	 	
 '')
	*((DLL>fX)NPWXH##s*T,?x}}?? ""8-ABT#&QSS  	*SVS))	*s/   2B !B :B BB C)B>>Cc                  < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[S[S[3,          ,          R	S[S[,          /	# r  r  )r-   r.   s   "r!   r/   r  ;  s     O* O*49%O* SM	O*
 SMO* $C=O* #+4.O*  (~O* #4.O* DcN+O* 8I7MO*r1   c               0   ^ RI p	V	P                  R\        ^R7       V P                  4       p
TpV'       d   V P	                  V4      pRVRVRVRVRVR	R
\
         2/pV'       d   W+R&   V'       d   WKR&   V'       d   WR&    V P                  V P                   R2W4      pVP                  ^8X  d    \        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i  \         d   p\        \        T4      R4      hRp?ii ; i)a  
Initiate an asynchronous extract job.

.. deprecated::
    The extract endpoint is in maintenance mode and its use is discouraged.
    Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor
    to find a replacement.

Args:
    urls (List[str]): URLs to extract information from
    prompt (Optional[str]): Custom extraction prompt
    schema (Optional[Any]): JSON schema/Pydantic model
    system_prompt (Optional[str]): System context
    allow_external_links (Optional[bool]): Follow external links
    enable_web_search (Optional[bool]): Enable web search
    show_sources (Optional[bool]): Include source URLs
    agent (Optional[Dict[str, Any]]): Agent configuration
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests

Returns:
    ExtractResponse[Any] with:
    * success (bool): Whether request succeeded
    * data (Optional[Any]): Extracted data matching schema
    * error (Optional[str]): Error message if any

Raises:
    ValueError: If job initiation fails
Nr  r  r  r"  rN  rP  r}   rO  r  r*   r   r   r  r  zasync extractr  r2   )r  r  r  r  r  r  rM  r  r  rS  rO   r   r  r  r,   )r  r  r*   r}   r  r  r  r  r   r  rt   r  r  rg  s   &&$$$$$$$     r!   async_extractV1FirecrawlApp.async_extract;  s3   N 	%  	 	
 '')--f5F D "60<fG9-
 %+"+8($)!
	*))T\\N+*F^H##s*T,?x}}?? ""8_=T#&QSS  	*SVS))	*s0   0C0 3C  C0  C--C0 0D;DDmax_urlsshow_full_textr  experimental_streamc                ~   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# r(   r^   r  r  r  r  r  r,   r   r   r   r  )r-   r.   s   "r!   r/   r    s`     C CC sm	C
 %TNC D>C "*$C <\Cr1   c                  \        VVVVR7      pV P                  VVVVVR7      pVP                  '       d   VP                  '       g   \	        RRRRR7      # VP                  p V P                  V4      p	V	P                  R8X  d   V	# V	P                  R8X  d   V	# V	P                  R	8w  d   \	        RR
RRR7      # \        P                  ! ^4       Kp  )a  
Generate LLMs.txt for a given URL and poll until completion.

Args:
    url (str): Target URL to generate LLMs.txt from
    max_urls (Optional[int]): Maximum URLs to process (default: 10)
    show_full_text (Optional[bool]): Include full text in output (default: False)
    cache (Optional[bool]): Whether to use cached content if available (default: True)
    experimental_stream (Optional[bool]): Enable experimental streaming

Returns:
    GenerateLLMsTextStatusResponse with:
    * Generated LLMs.txt content
    * Full version if requested
    * Generation status
    * Success/error information

Raises:
    Exception: If generation fails
r  r  r  __experimental_stream)r  r  r  r  Fz#Failed to start LLMs.txt generationrw   r0  r   r   r  r  rv   rW  /LLMs.txt generation job terminated unexpectedly)	r  async_generate_llms_textr   r  r  check_generate_llms_text_statusr  r  r  )
r  r^   r  r  r  r  paramsr  r  r  s
   &&$$$$    r!   generate_llms_text!V1FirecrawlApp.generate_llms_text  s    8 *'"5	
 00) 3 1 
 x{{{3;	  99&AF}}+(*,.7!K# 	  JJqMr1   c                ~   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# r  r,   r   r   r   r  )r-   r.   s   "r!   r/   r    sX     8
 8
8
 sm	8

 %TN8
 D>8
 "*$8
 <V8
r1   c               
   \        VVVVR7      pV P                  4       pRV/VP                  RRR7      CpR\         2VR&    V P	                  V P
                   R2W4      p	V	P                  4       p
\        RV4       \        R	V
4       V
P                  R
4      '       d    \        R/ V
B # V P                  V
R4        \        RRR7      #    \        R4      h; i  \         d   p\        \        T4      4      hRp?ii ; i)a  
Initiate an asynchronous LLMs.txt generation operation.

Args:
    url (str): The target URL to generate LLMs.txt from. Must be a valid HTTP/HTTPS URL.
    max_urls (Optional[int]): Maximum URLs to process (default: 10)
    show_full_text (Optional[bool]): Include full text in output (default: False)
    cache (Optional[bool]): Whether to use cached content if available (default: True)
    experimental_stream (Optional[bool]): Enable experimental streaming

Returns:
    GenerateLLMsTextResponse: A response containing:
    * success (bool): Whether the generation initiation was successful
    * id (str): The unique identifier for the generation job
    * error (str, optional): Error message if initiation failed

Raises:
    Exception: If the generation job initiation fails.
r  r^   Tr  r  rO  /v1/llmstxt	json_datar  r   r  zstart LLMs.txt generationNFInternal server errorr  r2   )r  r  r  r  rM  r  rO   r   r  r  r   r  r  r,   )r  r^   r  r  r  r  r  rt   r  reqr  rg  s   &&$$$$      r!   r  'V1FirecrawlApp.async_generate_llms_text  s   6 *'"5	
 '')CQ6;;4;#PQ	 +G95	(	%$$~[%A9VCxxzH+y)*h'||I&&S5AAA ""8-HI *)
 	
S#$QRR  	%SV$$	%s1   AC #
C .C CC D)C==Dc                &   < V ^8  d   QhRS[ RS[/# rW  r,   r  )r-   r.   s   "r!   r/   r  	  s      $} $}# $}:Z $}r1   c                   V P                  4       p V P                  V P                   RV 2V4      pVP                  ^8X  d    VP	                  4       p\        R/ VB # VP                  R8X  d   \        R4      hV P                  VR4        \        RRR	R
R7      #   \         d   p\        R\        T4       24      hRp?ii ; i  \         d   p\        \        T4      4      hRp?ii ; i)a  
Check the status of a LLMs.txt generation operation.

Args:
    id (str): The unique identifier of the LLMs.txt generation job to check status for.

Returns:
    GenerateLLMsTextStatusResponse: A response containing:
    * success (bool): Whether the generation was successful
    * status (str): Status of generation ("processing", "completed", "failed")
    * data (Dict[str, str], optional): Generated text with fields:
      * llmstxt (str): Generated LLMs.txt content
      * llmsfulltxt (str, optional): Full version if requested
    * error (str, optional): Error message if generation failed
    * expiresAt (str): When the generated data expires

Raises:
    Exception: If the status check fails.
/v1/llmstxt/zFFailed to parse Firecrawl response as GenerateLLMsTextStatusResponse: N  z!LLMs.txt generation job not foundz check LLMs.txt generation statusFr  rw   r0  r  r2   )
r  r   r  r  rO   r  r   r,   r  r  )r  r  rt   r  r  rg  s   &&    r!   r  .V1FirecrawlApp.check_generate_llms_text_status	  s    ( '')	%((DLL>bT)JGTH##s*w (I;HiHH %%, CDD""8-OP 0E\emy{|| ! w#&lmpqrmslt$uvvw  	%SV$$	%s;   2C B  .C C)C  CC C,C''C,c                L   < V ^8  d   QhRS[ S[,          RS[S[S[3,          /# )r(   rF  r  )r   r,   r   )r-   r.   s   "r!   r/   r  1	  s)     
 
%c]
6:38n
r1   c                b    V'       d   RRRRV P                    2RV/# RRRRV P                    2/# )z
Prepare the headers for API requests.

Args:
    idempotency_key (Optional[str]): A unique key to ensure idempotency of requests.

Returns:
    Dict[str, str]: The headers including content type, authorization, and optionally idempotency key.
zContent-Typezapplication/jsonr  r  zx-idempotency-key)r  )r  rF  s   &&r!   r  V1FirecrawlApp._prepare_headers1	  sN      274<<.!9#_  .wt||n5
 	
r1   c                ~   < V ^8  d   QhRS[ RS[S[ S[3,          RS[S[ S[ 3,          RS[RS[RS[P                  /# r(   r^   r  rt   retriesbackoff_factorr  )r,   r   r   r   r   r  Response)r-   r.   s   "r!   r/   r  I	  s]       sCx. #s(^	
  " -5,=,=r1   c                    \        V4       F~  p\        P                  ! YTRV9   d#   VR,          e   VR,          R,          ^,           MRR7      pVP                  R8X  d'   \        P
                  ! V^V,          ,          4       K|  Vu # 	  X# )a  
Make a POST request with retries.

Args:
    url (str): The URL to send the POST request to.
    data (Dict[str, Any]): The JSON data to include in the POST request.
    headers (Dict[str, str]): The headers to include in the POST request.
    retries (int): Number of retries for the request.
    backoff_factor (float): Backoff factor for retries.

Returns:
    requests.Response: The response from the POST request.

Raises:
    requests.RequestException: If the request fails after the specified retries.
r   Nr  r    )ranger  r  r  r  r  )r  r^   r  rt   r  r  attemptr  s   &&&&&&  r!   rM  V1FirecrawlApp._post_requestI	  s    . W~G}}Sqz  C  rC  HL  MV  HW  HcPTU^P_bhPhklPl  im  oH##s*

>Q'\:; & r1   c          
      b   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[RS[P
                  /# r(   r^   rt   r  r  r  r,   r   r   r   r  r  )r-   r.   s   "r!   r/   r  h	  K       #s(^ 	
 "
 -5,=,=r1   c                    \        V4       FS  p\        P                  ! WR7      pVP                  R8X  d'   \        P
                  ! V^V,          ,          4       KQ  Vu # 	  X# )a  
Make a GET request with retries.

Args:
    url (str): The URL to send the GET request to.
    headers (Dict[str, str]): The headers to include in the GET request.
    retries (int): Number of retries for the request.
    backoff_factor (float): Backoff factor for retries.

Returns:
    requests.Response: The response from the GET request.

Raises:
    requests.RequestException: If the request fails after the specified retries.
rt   r  )r  r  r  r  r  r  r  r^   rt   r  r  r  r  s   &&&&&  r!   r   V1FirecrawlApp._get_requesth	  sO    * W~G||C9H##s*

>Q'\:; & r1   c          
      b   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[RS[P
                  /# r  r  )r-   r.   s   "r!   r/   r  	  r  r1   c                    \        V4       FS  p\        P                  ! WR7      pVP                  R8X  d'   \        P
                  ! V^V,          ,          4       KQ  Vu # 	  X# )a  
Make a DELETE request with retries.

Args:
    url (str): The URL to send the DELETE request to.
    headers (Dict[str, str]): The headers to include in the DELETE request.
    retries (int): Number of retries for the request.
    backoff_factor (float): Backoff factor for retries.

Returns:
    requests.Response: The response from the DELETE request.

Raises:
    requests.RequestException: If the request fails after the specified retries.
r  r  )r  r  deleter  r  r  r  s   &&&&&  r!   rw  V1FirecrawlApp._delete_request	  sO    * W~Gs<H##s*

>Q'\:; & r1   c                H   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[/# r(   r  rt   rE  r  r,   r   r   r1  )r-   r.   s   "r!   r/   r  	  sA     2J 2J2J #s(^2J 	2J $9	2Jr1   c                    V P                    RV 2pV P                  WB4      pVP                  ^8X  d    VP                  4       pTR,          R8X  d   RT9   d   TR,          pRT9   df   \        TR,          4      ^ 8X  d   MMT P                  TR,          T4      p TP                  4       pTP                  TP                  R. 4      4       Kl  YvR&   \        R
/ TB # \	        R4      hTR,          R9   d&   \        T^4      p\        P                  ! T4       EK  \	        RTR,           24      hV P                  VR	4       EKF     \	        R4      h; i   \	        R4      h; i)a  
Monitor the status of a crawl job until completion.

Args:
    id (str): The ID of the crawl job.
    headers (Dict[str, str]): The headers to include in the status check requests.
    poll_interval (int): Seconds between status checks.

Returns:
    CrawlStatusResponse: The crawl results if the job is completed successfully.

Raises:
    Exception: If the job fails or an error occurs during status checks.
rZ  r  r  rv   r  r  z,Crawl job completed but no data was returnedz)Crawl job failed or was stopped. Status: r^  r2   activepausedpendingqueuedwaitingr  )r  r   r  rO   r   r_  r`  r  r1  maxr  r  r  )r  r  rt   rE  r  re  rc  r  s   &&&&    r!   rN  "V1FirecrawlApp._monitor_job_status	  sk   & j5G"//AO**c1T"1"6"6"8K x(K7,*62$3";v#671< %.2.?.?F@SU\.]O`.=.B.B.D !KK(CD.2F+4C{CC'(VWW *.nn"%mA"6MJJ}-#&OP[\dPeOf$ghh""?4HI1T#&QSS`&/2]&_ _s   E E EE$c                >   < V ^8  d   QhRS[ P                  RS[RR/# r(   r  r
  r  N)r  r  r,   )r-   r.   s   "r!   r/   r  	  s4     #H #H''#H #H !#Hr1   c                    VP                  4       pVP                  RR4      pVP                  RR4      pT P                  TP                  Y$T4      p\        P                  P                  YqR7      h    TP                  R,          pTP                  4       '       d   RT 2pRTP                   2p LRTP                   2pR	p L  \
         d    R
TP                   2pR	p  Li ; i; i)a0  
Handle errors from API responses.

Args:
    response (requests.Response): The response object from the API request.
    action (str): Description of the action that was being performed.

Raises:
    Exception: An exception with a message containing the status code and error details from the response.
r   No error message provided.details%No additional error details provided.:Ni  Nz#Server returned non-JSON response: zFull response status: z+Server returned empty response with status zNo additional details availablez0Server returned unreadable response with status )r  )
rO   r  r   r   r  r  _get_error_messager  
exceptions	HTTPError)r  r  r
  r  error_messageerror_detailsresponse_textmessages   &&&     r!   r  V1FirecrawlApp._handle_error	  s    	B$MMOM)--g7STM)--i9`aM ))(*>*>Wde !!++G+GG#	B
B (d 3 &&((&I-$YM&<X=Q=Q<R$SM&QRZRfRfQg$hM$EM B"RS[SgSgRh i ABs/   4A3 3C+6=C5CC($C+'C((C+c          
      8   < V ^8  d   QhRS[ RS[RS[RS[RS[/# r(   r  r
  r  r  r  r   r,   )r-   r.   s   "r!   r/   r  	  s9     u uc u3 us ucf ukn ur1   c                    VR8X  d   RV RV RV 2# VR8X  d   RV RV RV 2# VR8X  d   RV R	V RV 2# VR
8X  d   RV RV RV 2# VR8X  d   RV RV RV 2# RV RV RV RV 2# )a  
Generate a standardized error message based on HTTP status code.

Args:
    status_code (int): The HTTP status code from the response
    action (str): Description of the action that was being performed
    error_message (str): The error message from the API response
    error_details (str): Additional error details from the API response
    
Returns:
    str: A formatted error message
i  zPayment Required: Failed to z. z - r  z!Website Not Supported: Failed to i  zRequest Timeout: Failed to z as the request timed out. i  zConflict: Failed to z due to a conflict. r  z!Internal Server Error: Failed to zUnexpected error during z: Status code r2   r  r  r
  r  r  s   &&&&&r!   r  !V1FirecrawlApp._get_error_message	  s     #1&M?#m_]]C6vhbsS`RabbC08STaSbbefsetuuC)&1Em_TWXeWfggC6vhbsS`Rabb-fX^K=PRS`Raaderdsttr1   
time_limitanalysis_prompt*_V1FirecrawlApp__experimental_stream_stepson_activity	on_sourcec                .  < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[,          RS[S[S[S[ S[3,          .R	3,          ,          R
S[S[S[S[ S[3,          .R	3,          ,          RS[/
# )r(   r_  r;  r#  r  r$  r  r%  r&  Nr'  r  r,   r   r   r   r   r   r   r  )r-   r.   s   "r!   r/   r  
  s     ^X ^X^X  }	^X
 !^X sm^X &c]^X $C=^X *2$^X "(DcN+;T+A"BC^X  $sCx.)94)? @A^X Nj^Xr1   c          	        / p
Ve   W*R&   Ve   W:R&   Ve   WJR&   Ve   WZR&   Ve   WjR&   Ve   WzR&   \        R/ V
B p
V P                  VVVVVVR7      pVP                  R	4      '       d   R
V9  d   V# VR
,          p^ p^ p V P                  V4      pV'       d7   RV9   d0   VR,          VR pV F  pV! V4       K  	  \	        VR,          4      pV	'       d7   RV9   d0   VR,          VR pV F  pV	! V4       K  	  \	        VR,          4      pVR,          R8X  d   V# VR,          R8X  d   \        RVP                  R4       24      hVR,          R8w  d   M\        P                  ! ^4       K  R	RRR/# )  
Initiates a deep research operation on a given query and polls until completion.

Args:
    query (str): Research query or topic to investigate
    max_depth (Optional[int]): Maximum depth of research exploration
    time_limit (Optional[int]): Time limit in seconds for research
    max_urls (Optional[int]): Maximum number of URLs to process
    analysis_prompt (Optional[str]): Custom prompt for analysis
    system_prompt (Optional[str]): Custom system prompt
    __experimental_stream_steps (Optional[bool]): Enable experimental streaming
    on_activity (Optional[Callable]): Progress callback receiving {type, status, message, timestamp, depth}
    on_source (Optional[Callable]): Source discovery callback receiving {url, title, description}

Returns:
    DeepResearchStatusResponse containing:
    * success (bool): Whether research completed successfully
    * status (str): Current state (processing/completed/failed)
    * error (Optional[str]): Error message if failed
    * id (str): Unique identifier for the research job
    * data (Any): Research findings and analysis
    * sources (List[Dict]): List of discovered sources
    * activities (List[Dict]): Research progress log
    * summaries (List[str]): Generated research summaries

Raises:
    Exception: If research fails
Nr  r  r  r  r   __experimental_streamStepsr;  r#  r  r$  r  r   r  r  rU  r  rv   rw   Deep research failed. Error: r   rW  F)Deep research job terminated unexpectedlyr2   )r  async_deep_researchr  check_deep_research_statusr_  r   r  r  )r  r_  r;  r#  r  r$  r  r%  r&  r'  research_paramsr  r  last_activity_countlast_source_countr  new_activitiesactivitynew_sourcessources   &&$$$$$$$$          r!   deep_researchV1FirecrawlApp.deep_research
  s   P  *3J'!+5K()1I&&0?,-$.;N+&2<W89.AA++!+' , 
 ||I&&$h*>O$44V<F|v5!'!56I6J!K .H) !/&)&*>&?#Y&0$Y/0A0BC)Ff% *$'y(9$:!h;.!X-"?

7@S?T UVV!\1JJqM5'+VWWr1   c                   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[,          RS[S[ S[3,          /# )	r(   r_  r;  r#  r  r$  r  r%  r  r,   r   r   r   r   r   )r-   r.   s   "r!   r/   r  u
  s     ED EDED  }	ED
 !ED smED &c]ED $C=ED *2$ED DHS>EDr1   c                  / pVe   W(R&   Ve   W8R&   Ve   WHR&   Ve   WXR&   Ve   WhR&   Ve   WxR&   \        R/ VB pV P                  4       p	RV/VP                  R	R	R
7      Cp
R\         2V
R&   RV
9   dS   V
R,          pV'       dB   RV9   d;   \	        VR,          R4      '       d"   VR,          P                  4       V
R,          R&    V P                  V P                   R2W4      pVP                  ^8X  d    VP                  4       # V P                  VR4        RRRR/#    \        R4      h; i  \         d   p\        \        T4      4      hRp?ii ; i)2  
Initiates an asynchronous deep research operation.

Args:
    query (str): Research query or topic to investigate
    max_depth (Optional[int]): Maximum depth of research exploration
    time_limit (Optional[int]): Time limit in seconds for research
    max_urls (Optional[int]): Maximum number of URLs to process
    analysis_prompt (Optional[str]): Custom prompt for analysis
    system_prompt (Optional[str]): Custom system prompt
    __experimental_stream_steps (Optional[bool]): Enable experimental streaming

Returns:
    Dict[str, Any]: A response containing:
    * success (bool): Whether the research initiation was successful
    * id (str): The unique identifier for the research job
    * error (str, optional): Error message if initiation failed

Raises:
    Exception: If the research initiation fails.
Nr  r  r  r  r   r,  r_  Tr  r  rO  r   r}   /v1/deep-researchr  zstart deep researchr   Fr   r  r2   )r  r  r  r  hasattrr}   rM  r  r  rO   r   r  r  r,   )r  r_  r;  r#  r  r$  r  r%  r2  rt   r  	json_optsr  rg  s   &&$$$$$$      r!   r0  "V1FirecrawlApp.async_deep_researchu
  s   >  *3J'!+5K()1I&&0?,-$.;N+&2<W89.AA'')e^';';TX\';']^	 +G95	( I%!-0IX2wy?RT\7]7]5>x5H5O5O5Q	-(2
	%))T\\N:K*LiaH##s*S#==?* ""8-BC 5'+BCCS#$QRR  	%SV$$	%s0   0D5 <D% D5 %D22D5 5E EEc                &   < V ^8  d   QhRS[ RS[/# rW  r,   r  )r-   r.   s   "r!   r/   r  
  s      (D (DS (D5Q (Dr1   c                   V P                  4       p V P                  V P                   RV 2V4      pVP                  ^8X  d    VP	                  4       # VP                  R8X  d   \        R4      hV P                  VR4        RRR	R
/#    \        R4      h; i  \
         d   p\        \        T4      4      hRp?ii ; i)g  
Check the status of a deep research operation.

Args:
    id (str): The ID of the deep research operation.

Returns:
    DeepResearchResponse containing:

    Status:
    * success - Whether research completed successfully
    * status - Current state (processing/completed/failed)
    * error - Error message if failed
    
    Results:
    * id - Unique identifier for the research job
    * data - Research findings and analysis
    * sources - List of discovered sources
    * activities - Research progress log
    * summaries - Generated research summaries

Raises:
    Exception: If the status check fails.
/v1/deep-research/r  r  zDeep research job not foundzcheck deep research statusNr   Fr   r  )	r  r   r  r  rO   r   r  r  r,   )r  r  rt   r  rg  s   &&   r!   r1  )V1FirecrawlApp.check_deep_research_status
  s    2 '')	%((DLL>9KB4)PRYZH##s*S#==?* %%, =>>""8-IJ 5'+BCCS#$QRR
  	%SV$$	%s/   2B B
 .B 
BB B>%B99B>c                @   < V ^8  d   QhRS[ S[S[3,          RS[RR/# )r(   r  method_namer  Nr   r,   r   )r-   r.   s   "r!   r/   r  
  s/     .l .ltCH~ .lC .lD .lr1   c                $   V'       g   R# R0 RmR0 RmR0 RmR0 RmR0 RmR0 RmR0 RmR	0 Rm/pVP                  V\        4       4      p\        VP                  4       4      V,
          pV'       d"   \        R
V RRP	                  V4       R24      hR# )ah  
Validate additional keyword arguments before they are passed to the API.
This provides early validation before the Pydantic model validation.

Args:
    kwargs (Dict[str, Any]): Additional keyword arguments to validate
    method_name (str): Name of the method these kwargs are for

Raises:
    ValueError: If kwargs contain invalid or unsupported parameters
Nr  rc   r   rJ  r  r  r  r  zUnsupported parameter(s) for z: z, zC. Please refer to the API documentation for the correct parameters.>   r   r   rf   rc   r   r  r   r   r  r  r  r  r  r  r  r  r  r  >	   r`  rb  r  ra  rn   r   r   r  r  >   r  r   r;  r  r:  r9  r?  r  rB  r<  r=  r  rA  r@  >   r  r   r   r  r  r?  r  >   r   r*   r}   r  r  r  r  r  >   r   r   r   rf   rc   r   rt   r   r   r   r  r  r  r  r  r  r  r  )r  setkeysr  r   )r  r  rJ  method_paramsallowed_paramsunknown_paramss   &&&   r!   r  V1FirecrawlApp._validate_kwargs
  s       K {  |  R "@ & (F * ,J%
2 '**;> V[[]+n<<[MDIIVdLeKf  gj  k  l  l r1   c                   Vf   V# \        V\        4      '       dE   \        VR4      '       d   VP                  4       # \        VR4      '       d   VP	                  4       # \        V\
        4      '       d4   VP                  4        UUu/ uF  w  r#W P                  V4      bK  	  upp# \        V\        \        34      '       d!   V Uu. uF  q0P                  V4      NK  	  up# V# u uppi u upi )zg
Utility to ensure a schema is a dict, not a Pydantic model class. Recursively checks dicts and lists.
model_json_schemar}   )
r   r   r@  rT  r}   r  itemsr  listtuple)r  r}   kvs   &&  r!   r  "V1FirecrawlApp._ensure_schema_dict  s     >Mfd##v233//11**}}&fd##?E||~N~tqA//22~NNftUm,,9?@A,,Q/@@ O@s   
C(
C.c                   V'       d   \        V\        \        34      '       g   R# Vf   \        4       p^ RIpVP
                  ! VR\        R7      pWd9   d   R# VP                  V4        \        V\        4      '       Ed    RV9   d   \        VR,          \        4      '       d   VR,          P                  R4      p\        V4      ^8  dp   V^ ,          R8X  db   V^,          R8X  dT   VR	,          pW8X  d    VP                  V4       R# W9   d+   V P                  W8,          W#V4      VP                  V4       # VP                  4        F/  p	V P                  WW44      '       g   K   VP                  V4       R# 	  MK\        V\        4      '       d6   V F/  p
V P                  WW44      '       g   K   VP                  V4       R# 	  VP                  V4       R#   TP                  T4       i ; i)
aU  
Check if an object contains a recursive reference to a specific definition.

Args:
    obj: Object to check
    target_def_name: Name of the definition to check for recursion
    defs: Dictionary of definitions
    visited: Set of visited object keys to detect cycles
    
Returns:
    True if recursive reference is found, False otherwise
FNT)	sort_keysdefault$ref/#$defs)r   r  rV  rM  rO   dumpsr,   addsplitr_  discard_contains_recursive_refvalues)r  objtarget_def_namedefsvisitedrO   obj_keyref_pathdef_namevalueitems   &&&&&      r!   rg  &V1FirecrawlApp._contains_recursive_ref+  s    *S4,77?eG**SD#>G	%#t$$S=ZFS%A%A"6{005H8})hqkS.@Xa[T[E[#+B<#6#' OOG$ $+#'#?#?P_gn#o OOG$ !ZZ\E33EDZZ# OOG$ * C&&D33D4YY# OOG$  
 OOG$ OOG$s1   ,BG  G  >(G  +G  ?3G  7G  G   G3c                    V'       g   R# VP                  4        F   w  r#V P                  W2V4      '       g   K   R# 	  R# )z
Check if $defs contain circular references.

Args:
    defs: Dictionary of definitions to check
    
Returns:
    True if circular references are found, False otherwise
FT)rU  rg  )r  rk  ro  	def_values   &&  r!   _check_for_circular_defs'V1FirecrawlApp._check_for_circular_defs]  s8     #'::<H++IFF $0 r1   c           
        V'       d$   \        V\        \        34      '       d   V^
8  d   V# Vf   \        4       p\	        V4      pWS9   d   V# VP                  V4        \        V\        4      '       Ed   RV9   d   \        VR,          \        4      '       d   VR,          P                  R4      p\        V4      ^8  df   V^ ,          R8X  dX   V^,          R8X  dJ   VR,          pWr9   d;   V P                  \        W',          4      W#V^,           4      VP                  V4       # VVP                  V4       # / pVP                  4        F)  w  rV	R8X  d   K  V P                  WW4^,           4      W&   K+  	  VVP                  V4       # \        V\        4      '       d:   V Uu. uF  qP                  WW4^,           4      NK  	  upVP                  V4       #  VP                  V4       V# u upi   TP                  T4       i ; i)a$  
Resolve $ref references in a JSON schema object.

Args:
    obj: Object to resolve references in
    defs: Dictionary of definitions
    visited: Set to track visited objects and prevent infinite recursion
    depth: Current recursion depth
    
Returns:
    Object with resolved references
r^  r_  r`  ra  rb  )r   r  rV  rM  r  rd  r,   re  r_  _resolve_refsrf  rU  )r  ri  rk  rl  depthobj_idrn  ro  resolvedr   rp  rq  s   &&&&&       r!   rx  V1FirecrawlApp._resolve_refsp  s    *S4,7752:J?eGCJF	$#t$$S=ZFS%A%A"6{005H8})hqkS.@Xa[T[E[#+B<#+#'#5#5d4>6JD[`cd[d#e OOF#  OOF# "%))+JCg~ $($6$6uGUVY$WHM #.   OOF#	 C&&WZ[WZt**4w	JWZ[ OOF#	 ' OOF#
 \ OOF#s2   !B6G6 )G6 <A G6 G6 (!G1	G6 1G6 6H	c                x   aa V'       d   \        V\        4      '       g   V# \        4       oVV3R loS! V4      # )z
Normalize a schema for OpenAI compatibility by handling recursive references.

Args:
    schema: Schema to normalize
    
Returns:
    Normalized schema
c           
        < \        V \        4      '       g1   \        V \        4      '       d   V  Uu. uF  pS! V4      NK  	  up# V # \        V 4      pVS9   d   V # SP	                  V4       \        V 4      pR V9   d   SP                  V4       V# RV9   d   VP                  R4      p/ pVP                  4        F2  w  rg\        V\        4      '       d   R V9  d   S! V4      WV&   K.  WuV&   K4  	  / VCRVP                  4        UU	u/ uF  w  rVS! V	4      bK  	  up	p/Cp
SP                  V4       V
# VP                  R4      R8X  d    RV9   d   VP                  R4      RJ d   VR VP                  R4      R8X  d   RV9   d}   RV9   dv   \        VR,          \        4      '       dV   \        VR,          \        4      '       d9   VR,           Uu. uF  pWR,          9   g   K  VNK  	  ppV'       d   WR&   MVR MVR \        VP                  4       4       Fx  w  rg\        V\        4      '       d   R V9  d   S! V4      W6&   K.  \        V\        4      '       g   KF  V Uu. uF#  p\        V\        4      '       d	   S! V4      MTNK%  	  upW6&   Kz  	  SP                  V4       V# u upi u up	pi u upi u upi )r^  ra  r   object
propertiesadditionalPropertiesTrequired)	r   r  rV  r  rd  rf  poprU  r  )ri  rq  rz  
normalizedrk  processed_restr   rp  rX  rY  resultfieldvalid_requirednormalize_objectrl  s   &            r!   r  EV1FirecrawlApp._normalize_schema_for_openai.<locals>.normalize_object  s   c4((c4((?BCst,T2sCC
 WF 
KKcJ #'!!*$!~~g.!#","2"2"4JC"5$//F%4G.>u.E+.3s+	 #5 hNgGY]YcYcYe5fYeQUQRa9I!9L6LYe5fg' v&(2
*56$>56v&(2j(
*z*5t<<z,7>>9CJ9O &I9O&+,/G&G ',e9ON &I%1?:.&z2":. #:#3#3#56
eT**vU/B&6u&=JOt,,ns&tnsfjDRVAWAW'7'=]a'ans&tJO 7 OOF#w D4 6g&I 'us   J,	J1
J7(J7')J<r   r  rM  )r  r}   r  rl  s   &&@@r!   _normalize_schema_for_openai+V1FirecrawlApp._normalize_schema_for_openai  s3     Z55M%>	@  ''r1   c                   aa V'       d   \        V\        4      '       g   R# \        4       oVV3R loS! V4      '       * # )z
Validate schema for OpenAI compatibility.

Args:
    schema: Schema to validate
    
Returns:
    True if schema is valid, False otherwise
Tc                   < \        V \        4      '       g   R # \        V 4      pVS9   d   R # SP                  V4       RV 9   d   SP	                  V4       R # V P                  R4      R8X  d7   RV 9  d0   RV 9  d)   V P                  R4      RJ d   SP	                  V4       R# V P                  4        F  p\        V\        4      '       d,   RV9  d%   S! V4      '       d   SP	                  V4        R# KD  \        V\        4      '       g   K\  V FG  p\        V\        4      '       g   K  RV9  g   K$  S! V4      '       g   K4  SP	                  V4         R# 	  K  	  SP	                  V4       R # )Fr^  r   r  r  patternPropertiesr  T)r   r  r  rd  rf  r  rh  rV  )ri  rz  rp  rq  has_invalid_structurerl  s   &   r!   r  IV1FirecrawlApp._validate_schema_for_openai.<locals>.has_invalid_structure  s'   c4((WF KK}'8+C'#3../47' eT**vU/B,U33/# 4  t,, %%dD11fD6H4T:: ' 7'+	 !& & OOF#r1   r  )r  r}   r  rl  s   &&@@r!   _validate_schema_for_openai*V1FirecrawlApp._validate_schema_for_openai  s4     Z55%#	J )000r1   c                *   V'       d   \        V\        4      '       g   R# ^ RIpVP                  ! V4      pRV9   ;'       g    RV9   ;'       g    RV9   p\	        VP                  R4      ;'       g    VP                  R4      4      pT;'       g    T# )z
Detect if a schema contains recursive references.

Args:
    schema: Schema to analyze
    
Returns:
    True if schema has recursive patterns, False otherwise
FN"$ref"#/$defs/z#/definitions/ra  definitions)r   r  rO   rc  r   r  )r  r}   rO   schema_stringhas_refshas_defss   &&    r!   _detect_recursive_schema'V1FirecrawlApp._detect_recursive_schema)  s     Z55

6*% . .-'. .- 	
 

7+HHvzz-/HI##8#r1   c                d    V'       g   RRRR/# V P                  V4      '       d   RRRR/# RRRR/# )z
Select appropriate model based on schema complexity.

Args:
    schema: Schema to analyze
    
Returns:
    Dict with modelName and reason
	modelNamezgpt-4o-minireason	no_schemazgpt-4orecursive_schema_detectedsimple_schema)r  )r  r}   s   &&r!   _select_model_for_schema'V1FirecrawlApp._select_model_for_schemaA  sF     +FF((0085PQQ]HoFFr1   c                P   \        V\        4      '       Edm   W!9   Edf   V P                  W,          4      pV'       Ed   \        V\        4      '       d   VP                  R/ 4      p^ RIpVP
                  ! V4      pVP                  R4      ;'       g    RV9   ;'       g    RV9   pV'       db    V P                  W44      pVP
                  ! V4      p	RV	9   ;'       g    RV	9   p
V
'       g#   Tp\        V\        4      '       d   RV9   d   VR M2 V P                  W44      p\        V\        4      '       d   RV9   d   VR V P                  V4      pV P                  V4      '       g   \        V P                  4      hW1V&   V#   \         d     LPi ; i  \         d     Lai ; i)z
Process and validate a schema container (like extract or json_options).

Args:
    schema_container: Dict containing schema
    schema_key: Key where schema is stored (default: "schema")
    
Returns:
    Processed schema container
ra  Nr  r  )r   r  r  r  rO   rc  rx  r   r  r  r  OPENAI_SCHEMA_ERROR_MESSAGE)r  schema_container
schema_keyr}   rk  rO   r  has_any_refsresolved_schemaresolved_stringhas_remaining_refss   &&&        r!   _process_schema_with_validation.V1FirecrawlApp._process_schema_with_validationS  s    &--*2P--.>.JKF v*VT22zz'2. $

6 2JJw' 0 0-0 0-/   *.*<*<V*J*.**_*E-5-H-i-iJZiLi*1%4F)&$77Gv<M$*7O!%!3!3F!A%fd3368I &w 66v>F33F;; !A!ABB+1Z(# %  % s0   1.F  F ."F 1F FFF%$F%r  r  NN)FN         ?)Nr   )r}   )5r3   r4   r5   r6   r7   r  r  r  r   r"  r)  r2  r7  rJ  rT  rh  rp  rx  r  r  r  r  r  r  r  rc   r  r  r  r  r  r  rM  r   rw  rN  r  r  r9  r0  r1  r  r  rg  ru  rx  r  r  r  r  r  r9   r:   r;   s   @r!   r  r    s
    $	q  Q Q$U7 mq	U7
 15U7 15U7 15U7 15U7 '+U7 &+U7 48U7 &*U7 59U7 48U7 )-U7  PT!U7" )-#U7$ /3%U7& 48'U7( EI)U7* JN+U7, &*-U7. .2/U70 371U7 U7n]3 $(	]3
 "&]3 %)]3 #']3 &*]3 '+]3 &+]3 9=]3 ]3~= =,< <,H H(G G(@< .2	@<
 .2@< $(@< .2@<  $@< 04@< /3@< 04@< *.@< 59@< :>@< 48@<  37!@<" -1#@<$  $%@<& ,0'@<( *.)@<* /3+@<, ()-@<. *./@< @<Dz< .2	z<
 .2z< $(z< .2z<  $z< 04z< /3z< 04z< *.z< 59z< :>z< 48z<  37!z<" -1#z<$  $%z<& ,0'z<( *.)z<* /3+z<, *.-z< z<xQ? Q?f? ?:= =2S9 26	S9
 26S9 (,S9 26S9 $(S9 48S9 37S9 48S9 .2S9 9=S9 >BS9 8<S9  7;!S9" 15#S9$ $(%S9& 04'S9( .2)S9* 37+S9, .2-S9 S9j[0 %)	[0
 .2[0 26[0 ,0[0 $([0 &+[0 )-[0 48[0 [0zKC W[	KC
 -1KC -1KC -1KC -1KC #'KC "'KC 04KC "&KC 15KC 04KC %)KC  LP!KC" +/#KC$ 04%KC& AE'KC( +/)KC* ()+KC, *.-KC. /3/KC0 *.1KC KCZJC W[	JC
 -1JC -1JC -1JC -1JC #'JC "'JC 04JC "&JC 15JC 04JC %)JC  LP!JC" +/#JC$ 04%JC& AE'JC( +/)JC* *.+JC, *.-JC. /3/JC JCXJC W[	JC
 -1JC -1JC -1JC -1JC #'JC "'JC 04JC "&JC 15JC 04JC %)JC  LP!JC" +/#JC$ 04%JC& AE'JC( +/)JC* *.+JC, /3-JC. *./JC JCX<F <F|F F:~P %)	~P
 %)~P ,0~P 49~P 16~P ,1~P /3~P ~P@%* %*NO* %)	O*
 %)O* ,0O* 49O* 16O* ,1O* /3O* O*bC '+	C
 .2C %)C 37C CJ8
 '+	8

 .28
 %)8
 378
 8
t$} $}L
 
0 > : :2J 2Jh#H #HJu u4^X (,	^X
 )-^X '+^X .2^X ,0^X ;?^X GK^X EI^X ^X@ED (,	ED
 )-ED '+ED .2ED ,0ED ;?ED EDN(D (DT.l .lf$0d&0dO(b41l$0G$6  6 r1   r  c                      a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
RtV tR# )r{  i  a  
A class to watch and handle crawl job events via WebSocket connection.

Attributes:
    id (str): The ID of the crawl job to watch
    app (V1FirecrawlApp): The V1FirecrawlApp instance
    data (List[Dict[str, Any]]): List of crawled documents/data
    status (str): Current status of the crawl job
    ws_url (str): WebSocket URL for the crawl job
    event_handlers (dict): Dictionary of event type to list of handler functions
c                &   < V ^8  d   QhRS[ RS[/# r(   r  app)r,   r  )r-   r.   s   "r!   r/   V1CrawlWatcher.__annotate__  s     

 

3 

^ 

r1   c                    Wn         W n        . V n        R V n        VP                  P                  RR4       RV 2V n        R. R. R. /V n        R# )r  httpwsrZ  doner   documentN)r  r  r  r  r  replacews_urlevent_handlers)r  r  r  s   &&&r!   r  V1CrawlWatcher.__init__  sW    *,	 ,,VT:;:bTJBR
r1   c                   < V ^8  d   QhRR/# r(   r  Nr2   )r-   r.   s   "r!   r/   r    s     	* 	*t 	*r1   c                B  "   \         P                  ! V P                  RRRV P                  P                   23.R7      ;_uu_4       GRj  xL
 pV P                  V4      G Rj  xL
  RRR4      GRj  xL
  R#  L/ L L
  + GRj  xL 
 '       g   i     R# ; i5i)zE
Establishes WebSocket connection and starts listening for messages.
Nr  r  )max_sizeadditional_headers
websocketsconnectr  r  r  _listenr  	websockets   & r!   r  V1CrawlWatcher.connect  s      %%KK!0GDHH<L<L;M2N OP
 
 
 ,,y)))
 
 

 *
 
 
 
s`   A
BA<BB%A>&B*B5B 6B>B BB	B	
B	B		Bc                   < V ^8  d   QhRR/# r  r2   )r-   r.   s   "r!   r/   r         	, 	,$ 	,r1   c                   "   V  Rj  xL
  p\         P                  ! V4      pV P                  V4      G Rj  xL
  K;   L6 LD9R# 5i)zq
Listens for incoming WebSocket messages and handles them.

Args:
    websocket: The WebSocket connection object
NrO   loads_handle_messager  r  r  msgs   &&  r!   r  V1CrawlWatcher._listen  E      ' 	, 	,'**W%C&&s+++	,+ '5   AAA A,AAA AAAc                V   < V ^8  d   QhRS[ RS[S[S[ S[3,          .R3,          RR/# )r(   
event_typehandlerNr  )r,   r   r   r   )r-   r.   s   "r!   r/   r    s9     	< 	<S 	<8T#s(^DTVZDZ;[ 	<`d 	<r1   c                n    WP                   9   d%   V P                   V,          P                  V4       R# R# )z
Adds an event handler function for a specific event type.

Args:
    event_type (str): Type of event to listen for ('done', 'error', or 'document')
    handler (Callable): Function to handle the event
N)r  append)r  r  r  s   &&&r!   add_event_listener!V1CrawlWatcher.add_event_listener  s.     ,,,
+227; -r1   c                @   < V ^8  d   QhRS[ RS[S[ S[3,          RR/# )r(   r  detailr  Nrt  )r-   r.   s   "r!   r/   r    s*     
  
  
 d38n 
  
 r1   c                n    WP                   9   d%   V P                   V,           F  pV! V4       K  	  R# R# )z
Dispatches an event to all registered handlers for that event type.

Args:
    event_type (str): Type of event to dispatch
    detail (Dict[str, Any]): Event details/data to pass to handlers
N)r  )r  r  r  r  s   &&& r!   dispatch_eventV1CrawlWatcher.dispatch_event  s4     ,,,..z:: ; -r1   c                :   < V ^8  d   QhRS[ S[S[3,          RR/# r(   r  r  NrK  )r-   r.   s   "r!   r/   r    '     R Rc3h RD Rr1   c                  "   VR,          R8X  d@   RV n         V P                  RRV P                   RV P                  RV P                  /4       R# VR,          R8X  dI   RV n         V P                  RRV P                   RV P                  RVR,          RV P                  /4       R# VR,          R	8X  d}   VR,          R,          V n         V P                  P	                  VR,          P                  R. 4      4       V P                   F#  pV P                  R
RVRV P                  /4       K%  	  R# VR,          R
8X  dL   V P                  P                  VR,          4       V P                  R
RVR,          RV P                  /4       R# R# 5i)zq
Handles incoming WebSocket messages based on their type.

Args:
    msg (Dict[str, Any]): The message to handle
r   r  rv   r  r  r  r   rw   catchupr  Nr  r  r  r  r`  r  r  r  r  docs   && r!   r  V1CrawlWatcher._handle_message  C     v;& %DK4;;		SWY]Y`Y`(ab[G#"DK(DKKT[]`ah]ikoquqxqx)yz[I%f+h/DKIIS[__VR89yy##JdDGG0LM ![J&IIS[)
VS[$,PQ '   F	F)r  r  r  r  r  r  N)r3   r4   r5   r6   r7   r  r  r  r  r  r  r9   r:   r;   s   @r!   r{  r{    sH     


 

	* 	*	, 	,	< 	<
  
 R Rr1   r{  c            &         a a ] tR tRt oRtRV3R lV 3R llltRV3R lR lltRV3R lR	 lltRV3R
 lR lltV3R lR lt	V3R lR lt
V3R lR ltV3R lR ltRV3R lR lltRV3R lR lltRRRRRRRRRRRRRRR RR!RR"RR#RR$RR%RR&RR'RR(RR)R/V3R* lR+ lltRRRRRRRRRRRRRRR RR!RR"RR#RR$RR%RR'RR(RR)RR,RR-^R.R/V3R/ lR0 lltRRRRRRRRRRRRRRR RR!RR"RR#RR$RR%RR'RR(RR)RR,RR1RR.R/V3R2 lR3 lltR4RR5RR6RR7RR8RR9RR:RR;RR<RR=RR>RR?RR@RRARRBRRCRR-^R.R/V3RD lRE lltR4RR5RR6RR7RR8RR9RR:RR;RR<RR=RR>RR?RR@RRARRBRRCRR-^R.R/V3RF lRG lltV3RH lRI ltRV3RJ lRK lltRLRR<RRMRRNRR8RRRR RROR/V3RP lRQ lltRRRRRSRRTRR;RURVRURWRUR,R/V3RX lRY llltV3RZ lR[ ltV3R\ lR] ltV3R^ lR_ ltV3R` lRa ltV3Rb lRc ltRRRRRSRRTRR;RURVRURWRUR,R/V3Rd lRe llltRfRRgRRhR/V3Ri lRj lltRfRRgRRkRRhR/V3Rl lRm lltV3Rn lRo lt R6RRpRRfRRqRRTRRrRRsRRtR/V3Ru lRv llt!R6RRpRRfRRqRRTRRrR/V3Rw lRx llt"V3Ry lRz lt#R8RR{RR|RR}RR~RR RRRR=RROR/	V3R lR llt$Rt%Vt&V ;t'# )AsyncV1FirecrawlAppi  z
Asynchronous version of V1FirecrawlApp that implements async methods using aiohttp.
Provides non-blocking alternatives to all V1FirecrawlApp operations.
c                &   < V ^8  d   QhRS[ RS[ /# )r(   r  r  )r,   )r-   r.   s   "r!   r/    AsyncV1FirecrawlApp.__annotate__  s     ; ; ;c ;r1   c                (   < \         SV `  WR 7       R# )r  Nsuperr  )r  r  r  	__class__s   &&&r!   r  AsyncV1FirecrawlApp.__init__  s    :r1   Nc                   < V ^8  d   QhRS[ RS[ RS[S[ S[ 3,          RS[S[S[ S[3,          ,          RS[RS[RS[S[ S[3,          /# )r(   methodr^   rt   r  r  r  r  )r,   r   r   r   r   r   )r-   r.   s   "r!   r/   r    sn     +4 +4+4 +4 #s(^	+4
 4S>*+4 +4 "+4 -1cN+4r1   c                  "   \         P                  ! 4       ;_uu_4       GRj  xL
 p\        V4       F  p VP                  WW4R7      ;_uu_4       GRj  xL
 p	V	P                  R8X  d@   \
        P                  ! V^V,          ,          4      G Rj  xL
   RRR4      GRj  xL
  Kx  V	P                  R8  d   V P                  V	RV R24      G Rj  xL
  V	P                  4       G Rj  xL
 uuRRR4      GRj  xL
  u uuRRR4      GRj  xL
  # 	  \        R4      h EL L L L LX LB L3 L!  + GRj  xL 
 '       g   i     EK  ; i  \         P                   dI   p
Y^,
          8X  d   T
h\
        P                  ! T^T,          ,          4      G Rj  xL 
   Rp
?
EKy  Rp
?
ii ; i  + GRj  xL 
 '       g   i     R# ; i5i)a  
Generic async request method with exponential backoff retry logic.

Args:
    method (str): The HTTP method to use (e.g., "GET" or "POST").
    url (str): The URL to send the request to.
    headers (Dict[str, str]): Headers to include in the request.
    data (Optional[Dict[str, Any]]): The JSON data to include in the request body (only for POST requests).
    retries (int): Maximum number of retry attempts (default: 3).
    backoff_factor (float): Factor to calculate delay between retries (default: 0.5).
        Delay will be backoff_factor * (2 ** retry_count).

Returns:
    Dict[str, Any]: The parsed JSON response from the server.

Raises:
    aiohttp.ClientError: If the request fails after all retries.
    Exception: If max retries are exceeded or other errors occur.
N)r  r^   rt   rO   r  i,  zmake z requestzMax retries exceeded)aiohttpClientSessionr  requestr  asyncior  r  rO   ClientErrorr   )r  r  r^   rt   r  r  r  sessionr  r  rg  s   &&&&&&&    r!   _async_request"AsyncV1FirecrawlApp._async_request  s{    6 ((***g >I&%  /      !#??c1")--!w,0O"PPP$      $??c1"&"4"4Xvhh?W"XXX%-]]_4      +**) 233! +  Q	  Y4  +        ** IA+-!--!w,(GHHHHI +***s?  "GD&GF5ED)E9D7D+D7E%D-
&E*F5,*D7D/D7.D1/D72E?D3 EF5GD5GF5&G)E+D7-E/D71D73E5G7E=E >
E	EEF5EF2	*6F-	 F#!F-	&F5-F2	2F55G	;F><
G	G			Gc                   < V ^8  d   QhRS[ RS[S[ S[3,          RS[S[ S[ 3,          RS[RS[RS[S[ S[3,          /# r  )r,   r   r   r   r   )r-   r.   s   "r!   r/   r    s]     ^ ^^"&sCx.^;?S>^^.3^>B38n^r1   c                F   "   V P                  RWW$V4      G Rj  xL
 #  L5i)a  
Make an async POST request with exponential backoff retry logic.

Args:
    url (str): The URL to send the POST request to.
    data (Dict[str, Any]): The JSON data to include in the request body.
    headers (Dict[str, str]): Headers to include in the request.
    retries (int): Maximum number of retry attempts (default: 3).
    backoff_factor (float): Factor to calculate delay between retries (default: 0.5).
        Delay will be backoff_factor * (2 ** retry_count).

Returns:
    Dict[str, Any]: The parsed JSON response from the server.

Raises:
    aiohttp.ClientError: If the request fails after all retries.
    Exception: If max retries are exceeded or other errors occur.
POSTNr  )r  r^   r  rt   r  r  s   &&&&&&r!   _async_post_request'AsyncV1FirecrawlApp._async_post_request  s$     * ((tn]]]]   !!c                d   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[RS[S[ S[3,          /# r  )r,   r   r   r   r   )r-   r.   s   "r!   r/   r  5  sL     ] ]]%)#s(^]].3]>B38n]r1   c                F   "   V P                  RWRW44      G Rj  xL
 #  L5i)ac  
Make an async GET request with exponential backoff retry logic.

Args:
    url (str): The URL to send the GET request to.
    headers (Dict[str, str]): Headers to include in the request.
    retries (int): Maximum number of retry attempts (default: 3).
    backoff_factor (float): Factor to calculate delay between retries (default: 0.5).
        Delay will be backoff_factor * (2 ** retry_count).

Returns:
    Dict[str, Any]: The parsed JSON response from the server.

Raises:
    aiohttp.ClientError: If the request fails after all retries.
    Exception: If max retries are exceeded or other errors occur.
GETNr	  )r  r^   rt   r  r  s   &&&&&r!   _async_get_request&AsyncV1FirecrawlApp._async_get_request5  s$     ( ((dG\\\\r  c                >   < V ^8  d   QhRS[ P                  RS[RR/# r  r  ClientResponser,   )r-   r.   s   "r!   r/   r  K  s)     + +G,B,B +C +TX +r1   c                R  "    VP                  4       G Rj  xL
 pVP                  RR4      pVP                  RR4      pT P                  TP                  Y$T4      G Rj  xL
 p\        P                  ! T4      h Lc   \        P                  ! RTP                   24      h; i LD5i)a  
Handle errors from async API responses with detailed error messages.

Args:
    response (aiohttp.ClientResponse): The response object from the failed request
    action (str): Description of the action that was being attempted

Raises:
    aiohttp.ClientError: With a detailed error message based on the response status:
        - 402: Payment Required
        - 408: Request Timeout
        - 409: Conflict
        - 500: Internal Server Error
        - Other: Unexpected error with status code
Nr   r  r  r  ?Failed to parse Firecrawl error response as JSON. Status code: )rO   r  r  r  r  _get_async_error_messager  r  r
  
error_datar  r  r  s   &&&    r!   r  !AsyncV1FirecrawlApp._handle_errorK  s      	{'}}.J&NN74PQM&NN96]^M 55hoov^kll!!'** /	{%%(ghphwhwgx&yzzls8   B'A= A;(A=   B' B%!B';A= =%B""B'c          
      8   < V ^8  d   QhRS[ RS[RS[RS[RS[/# r  r  )r-   r.   s   "r!   r/   r  f  :     Z Z# Zs Z[^ Zor Zwz Zr1   c                .   "   V P                  WW44      # 5ia  
Generate a standardized error message based on HTTP status code for async operations.

Args:
    status_code (int): The HTTP status code from the response
    action (str): Description of the action that was being performed
    error_message (str): The error message from the API response
    error_details (str): Additional error details from the API response
    
Returns:
    str: A formatted error message
r  r!  s   &&&&&r!   r  ,AsyncV1FirecrawlApp._get_async_error_messagef        &&{MYY   c                    < V ^8  d   QhRS[ /# r  r  )r-   r.   s   "r!   r/   r  u  s     - -(= -r1   c                   "   V P                  4       pV P                  V P                   R2V4      G Rj  xL
 p\        R/ VB #  L5i)z8Get current credit usage and billing period (v1, async).r  Nr2   )r  r  r  rs  r  rt   resps   &  r!   r"  $AsyncV1FirecrawlApp.get_credit_usageu  sO     ''),,||n12
 
 %,t,,	
   3AAAc                    < V ^8  d   QhRS[ /# r  r&  )r-   r.   s   "r!   r/   r  ~  s     , ,'; ,r1   c                   "   V P                  4       pV P                  V P                   R2V4      G Rj  xL
 p\        R/ VB #  L5i)z7Get current token usage and billing period (v1, async).r(  Nr2   )r  r  r  r  r%  s   &  r!   r)  #AsyncV1FirecrawlApp.get_token_usage~  sO     ''),,||n01
 
 $+d++	
r(  c                P   < V ^8  d   QhRS[ RS[S[,          RS[S[ ,          RR/# )r(   r^   r  rF  r  AsyncV1CrawlWatcher)r,   r   r  )r-   r.   s   "r!   r/   r    s=     *9 *9*9 ]+*9 &c]	*9 7L	*9r1   c                   "   V P                  WV4      G Rj  xL
 pVP                  R4      '       d   RV9   d   \        VR,          V 4      # \        R4      h L@5i)a  
Initiate an async crawl job and return an AsyncV1CrawlWatcher to monitor progress via WebSocket.

Args:
  url (str): Target URL to start crawling from
  params (Optional[V1CrawlParams]): See V1CrawlParams model for configuration:
    URL Discovery:
    * includePaths - Patterns of URLs to include
    * excludePaths - Patterns of URLs to exclude
    * maxDepth - Maximum crawl depth
    * maxDiscoveryDepth - Maximum depth for finding new URLs
    * limit - Maximum pages to crawl

    Link Following:
    * allowBackwardLinks - DEPRECATED: Use crawlEntireDomain instead
    * crawlEntireDomain - Follow parent directory links
    * allowExternalLinks - Follow external domain links  
    * ignoreSitemap - Skip sitemap.xml processing

    Advanced:
    * scrapeOptions - Page scraping configuration
    * webhook - Notification webhook settings
    * deduplicateSimilarURLs - Remove similar URLs
    * ignoreQueryParameters - Ignore URL parameters
    * regexOnFullURL - Apply regex to full URLs
  idempotency_key (Optional[str]): Unique key to prevent duplicate requests

Returns:
  AsyncV1CrawlWatcher: An instance to monitor the crawl job via WebSocket

Raises:
  Exception: If crawl job fails to start
Nr   r  r}  )rT  r  r-  r   )r  r^   r  rF  r~  s   &&&& r!   r  'AsyncV1FirecrawlApp.crawl_url_and_watch  sY     L  $33CQQi((T^-C&~d';TBB788	 R   AAA&Ac                `   < V ^8  d   QhRS[ S[,          RS[S[,          RS[S[,          RR/# )r(   r  r  rF  r  r-  )r   r,   r   r   )r-   r.   s   "r!   r/   r    sG     (@ (@s)(@ ^,(@ &c]	(@ 7L	(@r1   c                   "   V P                  WV4      G Rj  xL
 pVP                  R4      '       d   RV9   d   \        VR,          V 4      # \        R4      h L@5i)a  
Initiate an async batch scrape job and return an AsyncV1CrawlWatcher to monitor progress.

Args:
    urls (List[str]): List of URLs to scrape
    params (Optional[V1ScrapeParams]): See V1ScrapeParams model for configuration:

      Content Options:
      * formats - Content formats to retrieve
      * includeTags - HTML tags to include
      * excludeTags - HTML tags to exclude
      * onlyMainContent - Extract main content only
      
      Request Options:
      * headers - Custom HTTP headers
      * timeout - Request timeout (ms)
      * mobile - Use mobile user agent
      * proxy - Proxy type
      
      Extraction Options:
      * extract - Content extraction config
      * jsonOptions - JSON extraction config
      * actions - Actions to perform
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests

Returns:
    AsyncV1CrawlWatcher: An instance to monitor the batch scrape job via WebSocket

Raises:
    Exception: If batch scrape job fails to start
Nr   r  r  )r  r  r-  r   )r  r  r  rF  batch_responses   &&&& r!   r  /AsyncV1FirecrawlApp.batch_scrape_urls_and_watch  sY     H  $;;D/ZZi((T^-C&~d';TBB>??	 [r0  r   rt   r  r  r  r  r   r   r   r   r  r  r  r   r  rc   r  rf   c          /      P  < V ^8  d   QhRS[ RS[S[S[R,          ,          ,          RS[S[S[ S[ 3,          ,          RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          /# )r(   r^   r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  r  rf   r  r   r   )r,   r   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r   r   )r-   r.   s   "r!   r/   r    s    DM DMDM d7  ,g  $h  i  j	DM
 d38n-DM #49-DM #49-DM  (~DM smDM c]DM /0DM TNDM $,D>DM #+4.DM  ~DM  G$JKL!DM"  ~#DM$ l+%DM& #<0'DM( d57I=Zgiv  yG  IW  Yr  t  *  $@  A  B)DM* *#.+DMr1   c                 "   V P                  VR4       V P                  4       pRVRR\         2/pV'       d   VVR&   V'       d   VVR&   V'       d   VVR&   V'       d   VVR&   Ve   VVR
&   V'       d   VVR&   V'       d   VVR&   V	'       d   V	P                  RRR7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   V'       d   VVR&   Ve   VVR&   Vex   V P	                  V4      p\        V\        4      '       d#   RV9   d   V P	                  VR,          4      VR&   \        V\        4      '       d   TMVP                  RRR7      VR&   Vex   V P	                  V4      p\        V\        4      '       d#   RV9   d   V P	                  VR,          4      VR&   \        V\        4      '       d   TMVP                  RRR7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  RRR7      NK0  	  upVR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P	                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P	                  VR,          R,          4      VR,          R&   RpV P                  V P                   V 2VV4      G R	j  xL
 pVP                  R4      '       d   RV9   d   \        R/ VR,          B # RV9   d   \        RVR,           24      hVP                  R\        V4      4      p\        RV 24      hu upi  L~5i) a1  
Scrape a single URL asynchronously.

Args:
  url (str): Target URL to scrape
  formats (Optional[List[Literal["markdown", "html", "rawHtml", "content", "links", "screenshot", "screenshot@fullPage", "extract", "json"]]]): Content types to retrieve (markdown/html/etc)
  headers (Optional[Dict[str, str]]): Custom HTTP headers
  include_tags (Optional[List[str]]): HTML tags to include
  exclude_tags (Optional[List[str]]): HTML tags to exclude
  only_main_content (Optional[bool]): Extract main content only
  wait_for (Optional[int]): Wait for a specific element to appear
  timeout (Optional[int]): Request timeout (ms)
  location (Optional[V1LocationConfig]): Location configuration
  mobile (Optional[bool]): Use mobile user agent
  skip_tls_verification (Optional[bool]): Skip TLS verification
  remove_base64_images (Optional[bool]): Remove base64 images
  block_ads (Optional[bool]): Block ads
  proxy (Optional[Literal["basic", "stealth", "auto"]]): Proxy type (basic/stealth)
  extract (Optional[V1JsonConfig]): Content extraction settings
  json_options (Optional[V1JsonConfig]): JSON extraction settings
  actions (Optional[List[Union[V1WaitAction, V1ScreenshotAction, V1ClickAction, V1WriteAction, V1PressAction, V1ScrollAction, V1ScrapeAction, V1ExecuteJavascriptAction, V1PDFAction]]]): Actions to perform
  **kwargs: Additional parameters to pass to the API

Returns:
    V1ScrapeResponse with:
    * success - Whether scrape was successful
    * markdown - Markdown content if requested
    * html - HTML content if requested
    * rawHtml - Raw HTML content if requested
    * links - Extracted links if requested
    * screenshot - Screenshot if requested
    * extract - Extracted data if requested
    * json - JSON data if requested
    * error - Error message if scrape failed

Raises:
    Exception: If scraping fails
r  r^   rO  r  r   rt   r   r   Nr   r   r   Tr  r   r   r   r   r   r   r   r}   rc   r   rf   r  r   r  r   r  r2   )r  r  r  r  r  r   r
  r  r  r   r   r,   )r  r^   r   rt   r  r  r  r  r   r   r   r  r  r  r   r  rc   r  rf   r  r  r	  r
  rb  r  error_contents   &&$$$$$$$$$$$$$$$$$,      r!   r  AsyncV1FirecrawlApp.scrape_url  s    z 	fl3((* 3G9-
 '.M)$'.M)$+7M-(+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'" (1M*%..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%-	*B*BxS`ajSkGk151I1I-XaJbckJl1mM)$X.M)mM.J.Jx[hiv[wOw595M5Mm\iNjksNt5uM-(2  11||nXJ'
 
 <<	""v'9#7hv&677 ;HW<M;NOPP %LL#h-@M;M?KLL+ (U
se   AMMM!M7MMAMDMM#4MM3AM AMMM9A$Mr   rE  rF  c          -      |  < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[/# )r(   r  r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   rE  rF  r  r  r   r  )r-   r.   s   "r!   r/   r  c  s    HC HC3iHC $w  (Q   R  S  T	HC
 $sCx.)HC tCy)HC tCy)HC $D>HC 3-HC #HC +,HC HC  (~HC 'tnHC D>HC   FGH!HC" ,'#HC$ |,%HC& $u\3E}Vcer  uC  ES  Un  p{  &{   |  }  ~'HC( ')HC*  }+HC, "#-HC0 
%1HCr1   c                 "   V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Ve'   V Uu. uF  pVP                  R
R
R7      NK  	  upVR&   Ve   VP                  R
R
R7      VR&   VP	                  V4       \        R/ VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      G Rj  xL
 pVP                  R4      '       d.    VP                  R4      pT P                  TTT4      G Rj  xL
 # V P                  VR4       R# u upi  La   \        R4      h; i L/5i) a  
Asynchronously scrape multiple URLs and monitor until completion.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    poll_interval (Optional[int]): Seconds between status checks (default: 2)
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    V1BatchScrapeStatusResponse with:
    * Scraping status and progress
    * Scraped content for each URL
    * Success/error information

Raises:
    Exception: If batch scrape fails
r  Nr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r  r  rO  r  r   r  r  r  r2   )r  r  r  r   r  r   r  r  r
  r  r  r   _async_monitor_job_statusr  )r  r  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   rE  rF  r  r	  r
  r  r  r  r  s   &&$$$$$$$$$$$$$$$$$$$,      r!   r  %AsyncV1FirecrawlApp.batch_scrape_urlsc  s    z 	f&9: '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-(dk'ldkZ`TPT(Udk'lM)$%*ZZDZ%QM'" 	V$ &66"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''811||n,-
 
 <<	""P\\$' 77G]SSSx)ABC (m(
P"MOOSsQ   FMM7A5M-AM:A+M%M&MM	 M)M*M	MMr  c          -      |  < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[/# )r(   r  r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   r  rF  r  r  r   r  )r-   r.   s   "r!   r/   r    s    JI JI3iJI $w  (Q   R  S  T	JI
 $sCx.)JI tCy)JI tCy)JI $D>JI 3-JI #JI +,JI JI  (~JI 'tnJI D>JI   FGH!JI" ,'#JI$ |,%JI& $u\3E}Vcer  uC  ES  Un  p{  &{   |  }  ~'JI( ')JI* &d^+JI, "#-JI0 
1JIr1   c                 "   V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  R
R
R7      NK0  	  upVR&   Ve   VP                  R
R
R7      VR&   Ve   VVR&   VP	                  V4       \        R/ VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      G Rj  xL
 pVP                  R4      ^8X  d    \        R/ VP                  4       B # V P                  VR4      G Rj  xL
  R# u upi  LU   \        R4      h; i L5i) a,  
Initiate a batch scrape job asynchronously.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    V1BatchScrapeResponse with:
    * success - Whether job started successfully
    * id - Unique identifier for the job
    * url - Status check URL
    * error - Error message if start failed

Raises:
    Exception: If job initiation fails
r  Nr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r  r  r  rO  r  r  r  r  r2   )r  r  r  r   r  r   r  r  r
  r  r  r  rO   r   r  )r  r  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   r  rF  r  r	  r
  r  r  r  s   &&$$$$$$$$$$$$$$$$$$$,     r!   r  +AsyncV1FirecrawlApp.async_batch_scrape_urls  s    | 	f&?@ '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%*ZZDZ%QM'"*1DM-. 	V$ &66"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''811||n,-
 
 <<&#-P,?x}}?? $$X/GHHHE (U,
P"MOOHsW   FM4M44MA>M4AM4A+M4
M M4&M" >M4M2M4"M//M4r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  c          (        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[/# r(   r^   r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rE  rF  r  rH  )r-   r.   s   "r!   r/   r  z  s]    uB uBuB  S	*	uB
  S	*uB C=uB &c]uB }uB 'tnuB &d^uB 'tnuB !uB !1uB %_ 456uB #+4.uB  "*$!uB" $D>#uB$ }%uB& #4.'uB(  })uB* "#+uB. 
/uBr1   c               T  "   V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   M	Ve   VVR	&   V	e   V	VR
&   V
e   V
VR&   Ve   VP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   VP                  V4       \        R/ VB pVP                  RRR7      pVVR&   R\         2VR&   V P                  V4      pV P                  V P                   R2VV4      G Rj  xL
 pVP                  R4      '       d.    VP                  R4      pT P                  TTT4      G Rj  xL
 # V P                  VR4      G Rj  xL
  R#  Ld   \        R4      h; i L2 L5i)a   
Crawl a website starting from a URL.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[V1ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, V1WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    delay (Optional[int]): Delay in seconds between scrapes
    allow_subdomains (Optional[bool]): Follow subdomains
    poll_interval (Optional[int]): Seconds between status checks (default: 2)
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    V1CrawlStatusResponse with:
    * Crawling status and progress
    * Crawled page contents
    * Success/error information

Raises:
    Exception: If crawl fails
rJ  Nr  r  r  r  r  r!  r   r"  r#  Tr  r$  r   r%  r&  r'  r(  r*  r^   r  rO  rK  r   r  r  rL  r2   )r  r  r  r  r  r  r
  r  r  r   r;  r  )r  r^   r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rE  rF  r  rO  r  r  rt   r  r  s   &&$$$$$$$$$$$$$$$$$$,      r!   rJ  AsyncV1FirecrawlApp.crawl_urlz  s3    v 	fk2 $+8L($+8L( '0L$*0CL,-$)L!*0CL,-!-1EL-.+1EL-.%,:L)%,:,?,?\`,?,aL)&-L##/5ML12".4KL01(->L)*$)L!'.>L*+ 	F# %4|4"''D'I E"-gY 7H''811\\N)
$k7< < <<	""P\\$' 77G]SSS$$X/@AAA<P"MOOSAsH   D+F(-F.F(
F F(1F$2F(F&F(F!!F(&F(c          (        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[/# rA  rR  )r-   r.   s   "r!   r/   r    s]    sB sBsB  S	*	sB
  S	*sB C=sB &c]sB }sB 'tnsB &d^sB 'tnsB !sB !1sB %_ 456sB #+4.sB  "*$!sB" $D>#sB$ }%sB& #4.'sB(  })sB* "#+sB. 
/sBr1   c                 "   / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   M	Ve   VVR&   V	e   V	VR	&   V
e   V
VR
&   Ve   VP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   VP                  V4       \        R/ VB pVP                  RRR7      pVVR&   R\         2VR&   V P	                  V4      pV P                  V P                   R2VV4      G Rj  xL
 pVP                  R4      '       d    \        R/ VB # V P                  VR4      G Rj  xL
  R#  LC   \        R4      h; i L5i)a  
Start an asynchronous crawl job.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    V1CrawlResponse with:
    * success - Whether crawl started successfully
    * id - Unique identifier for the crawl job
    * url - Status check URL for the crawl
    * error - Error message if start failed

Raises:
    Exception: If crawl initiation fails
Nr  r  r  r  r  r!  r   r"  r#  Tr  r$  r   r%  r&  r'  r(  r*  r^   r  rO  rK  r   r  rL  r2   )r  r  r  r  r  r
  r  r  r-  r   r  )r  r^   r9  r:  r;  r<  r  r=  r>  r  r?  r  r   r@  rA  rB  r(  rC  rE  rF  r  rO  r  r  rt   r  s   &&$$$$$$$$$$$$$$$$$$,     r!   rT  #AsyncV1FirecrawlApp.async_crawl_url  s    p  $+8L($+8L( '0L$*0CL,-$)L!*0CL,-!-1EL-.+1EL-.%,:L)%,:,?,?\`,?,aL)&-L##/5ML12".4KL01(->L)*$)L!'.>L*+ 	F# %4|4"''D'I E"-gY 7H ''811\\N)
$


 
 <<	""P&222 $$X/@AAA
P"MOOAs6   DE3EE38
E! E3E1E3!E..E3c                &   < V ^8  d   QhRS[ RS[/# rW  rX  )r-   r.   s   "r!   r/   r  g  s      @ @3 @3H @r1   c           
     \  "   V P                  4       pRV 2pV P                  V P                   V 2V4      G Rj  xL
 pVP                  R4      R8X  d   RV9   d   VR,          pRV9   d   \	        VR,          4      ^ 8X  d   MmVP                  R4      pV'       g   \
        P                  R4       M>V P                  Wb4      G Rj  xL
 pVP                  VP                  R. 4      4       TpK  WTR&   \        VP                  R4      VP                  R4      VP                  R4      VP                  R	4      VP                  R
4      VP                  R4      RV9   d   RMRR7      pRV9   d   VP                  R4      Vn	        RV9   d   VP                  R4      Vn
        V#  ELl L5i)a  
Check the status and results of an asynchronous crawl job.

Args:
    id (str): Unique identifier for the crawl job

Returns:
    V1CrawlStatusResponse containing:
    Status Information:
    * status - Current state (scraping/completed/failed/cancelled)
    * completed - Number of pages crawled
    * total - Total pages to crawl
    * creditsUsed - API credits consumed
    * expiresAt - Data expiration timestamp
    
    Results:
    * data - List of crawled documents
    * next - URL for next page of results (if paginated)
    * success - Whether status check succeeded
    * error - Error message if failed

Raises:
    Exception: If status check fails
rZ  Nr  rv   r  r  r[  r  r  r  r   FT)r  r  rv   r  r  r  r   )r  r  r  r  r_  r  r   r`  r1  r   r  	r  r  rt   rb  rc  r  rd  rf  r  s	   &&       r!   rh  &AsyncV1FirecrawlApp.check_crawl_statusg  s    2 '')t$ 33||nXJ'
 

 ??8$3$"6*+;v./14*v6H#'HI&*&=&=h&P PIKK	fb 9:"+K&*F#(??8,//'*!ook2#6!ook2($3E
 k!(__W5HN[ 'OOF3HMI
 !Qs)   9F,F'A!F,*F,F*	CF,*F,c                H   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[/# r  r  )r-   r.   s   "r!   r/   r    s=     )_ )_# )_S#X )__b )_  lA )_r1   c                  "    V P                  V P                   RV 2V4      G Rj  xL
 pVP                  R4      R8X  d   RV9   d   VR,          pRV9   d   \        VR,          4      ^ 8X  d   MmVP                  R4      pV'       g   \        P                  R4       M>V P                  Wb4      G Rj  xL
 pVP                  VP                  R. 4      4       TpK  WTR&   \        R
/ VB # \        R4      hVP                  R4      R9   d,   \        P                  ! \        V^4      4      G Rj  xL
  EK7  \        R	VR,           24      h EL' L L!5i)a  
Monitor the status of an asynchronous job until completion.

Args:
    id (str): The ID of the job to monitor
    headers (Dict[str, str]): Headers to include in status check requests
    poll_interval (int): Seconds between status checks (default: 2)

Returns:
    V1CrawlStatusResponse: The job results if completed successfully

Raises:
    Exception: If the job fails or an error occurs during status checks
rZ  Nr  rv   r  r  r[  z&Job completed but no data was returnedz#Job failed or was stopped. Status: r2   r  )r  r  r  r_  r  r   r`  r1  r   r  r  r  )r  r  rt   rE  rc  r  rd  rf  s   &&&&    r!   r;  -AsyncV1FirecrawlApp._async_monitor_job_status  s=      $ 7 7<<.
2$/! K
 x(K7[(&v.D K/{623q8!#.??6#:'"NN+LM!*.*A*A(*T$T	IMM&"$=>&/*.'0?;??#$LMM*.nnmmCq$9:::"EkRZF[E\ ]^^3 %U ;s;   &EEA!E*E5E6A<E2E3EEEr   r  r  r  c                   < V ^8  d   QhRS[ RS[S[ ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[/
# )r(   r^   r   r?  r  r  r  r   r   r  r  )r,   r   r   r   rl   rA  rH  )r-   r.   s   "r!   r/   r    s     KE KEKE 	KE
 !KE %TNKE tnKE }KE #KE +,KE %KE 2?KEr1   c               r  "   / p
V	'       d#   V
P                  V	P                  RRR7      4       Ve   W*R&   Ve   W:R&   Ve   WJR&   Ve   WZR&   Ve   WjR&   Ve   WzR	&   Ve   VP                  RRR7      V
R
&   \        R/ V
B pVP                  RRR7      pWR&   R\         2VR&   RpV P	                  V P
                   V 2VRRV P                   2/R7      G Rj  xL
 pVP                  R4      '       d   RV9   d   \        R/ VB # RV9   d   \        RVR,           24      h\        RV 24      h LW5i)a  
Asynchronously map and discover links from a URL.

Args:
  url (str): Target URL to map
  params (Optional[V1MapParams]): See V1MapParams model:
    Discovery Options:
    * search - Filter pattern for URLs
    * ignoreSitemap - Skip sitemap.xml
    * includeSubdomains - Include subdomain links
    * sitemapOnly - Only use sitemap.xml
    
    Limits:
    * limit - Max URLs to return
    * timeout - Request timeout (ms)

Returns:
  V1MapResponse with:
  * Discovered URLs
  * Success/error status

Raises:
  Exception: If mapping fails
Tr  Nr   r#  rC  rD  r  r   r   r^   r  rO  r  r  r  r  r   rb   r   zFailed to map URL. Error: r2   )
r  r  rA  r  r
  r  r  r  rH  r   )r  r^   r   r?  r  r  r  r   r   r  r  r  r  rb  r  s   &&$$$$$$$$     r!   r  AsyncV1FirecrawlApp.map_url  s    H 
fkk4dkKL #)x %*8').@*+#(4}%"'w$+y!%-]]Dt]%TJz" #0Z0"''D'I E"-gY 7H 11||nXJ'$~&>? 2 
 
 <<	""w(': ,8,, 8'9J8KLMM8
CDD
s   CD7D5D79=D7r*   r}   r  Fr  r  c                  < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[S[S[3,          ,          R	S[S[,          /	# r  r  )r-   r.   s   "r!   r/   r  !  s     dR dR49%dR SM	dR
 SMdR $C=dR #+4.dR  (~dR #4.dR DcN+dR 8I7MdRr1   c                 "   ^ RI p	V	P                  R\        ^R7       V P                  4       p
V'       g   V'       g   \	        R4      hV'       g   V'       g   \	        R4      hV'       d   V P                  V4      pRT;'       g    . RVRVR	VR
VRR\        4        2/pV'       d   W+R&   V'       d   WKR&   V'       d   WR&   V P                  V P                   R2VV
4      G Rj  xL
 pVP                  R4      '       d   VP                  R4      pV'       g   \        R4      h V P                  V P                   RV 2V
4      G Rj  xL
 pVR,          R8X  d   \        R/ VB # VR,          R9   d    \        RVR,           RVR,           24      h\        P                  ! ^4      G Rj  xL
  K  \        RVP                  R4       24      h L L L'5i)a  
Asynchronously extract structured information from URLs.

.. deprecated::
    The extract endpoint is in maintenance mode and its use is discouraged.
    Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor
    to find a replacement.

Args:
    urls (Optional[List[str]]): URLs to extract from
    prompt (Optional[str]): Custom extraction prompt
    schema (Optional[Any]): JSON schema/Pydantic model
    system_prompt (Optional[str]): System context
    allow_external_links (Optional[bool]): Follow external links
    enable_web_search (Optional[bool]): Enable web search
    show_sources (Optional[bool]): Include source URLs
    agent (Optional[Dict[str, Any]]): Agent configuration

Returns:
  V1ExtractResponse with:
  * Structured data matching schema
  * Source information if requested
  * Success/error status

Raises:
  ValueError: If prompt/schema missing or extraction fails
Nr  r  r  r  r  r"  rN  rP  r}   rO  r  r*   r   r   r  r   r  r  r  r  rv   r  r  r   r  r2   r  )r  r  r  r  r  r  r"   r
  r  r  r   r  rS  r  r  )r  r  r*   r}   r  r  r  r  r   r  rt   r  r  r  rc  s   &&$$$$$$$      r!   rc   AsyncV1FirecrawlApp.extract!  s    N 	%  	 	
 '')fBCCF@AA--f5F DJJB "60<fKM?3
 %+"+8($)!11||nK(
 
 <<	""\\$'F KLL$($;$;||nL9% 
 x(K7,;{;; *.EE#l;x3H2IS^_fSgRh$ijjmmA&&&8g9N8OPQQ1
 'sk   <GGGG-G,G5G'G(G)GG0GGA#G1G2$GGGc                &   < V ^8  d   QhRS[ RS[/# rW  r  )r-   r.   s   "r!   r/   r    s      B
 B
# B
:U B
r1   c           
     0  "   V P                  4       pRV 2pV P                  V P                   V 2V4      G Rj  xL
 pVR,          R8X  d   RV9   d   VR,          pRV9   d   \        VR,          4      ^ 8X  d   MmVP	                  R4      pV'       g   \
        P                  R4       M>V P                  Wb4      G Rj  xL
 pVP                  VP	                  R. 4      4       TpK  WTR&   \        VP	                  R4      VP	                  R4      VP	                  R4      VP	                  R	4      VP	                  R
4      VP	                  R4      R7      pRV9   d   VR,          VR&   RV9   d   VR,          VR&   RRV9   d   R/VC# R/VC#  ELV L5i)a  
Check the status of an asynchronous batch scrape job.

Args:
    id (str): The ID of the batch scrape job

Returns:
    V1BatchScrapeStatusResponse containing:
    Status Information:
    * status - Current state (scraping/completed/failed/cancelled)
    * completed - Number of URLs scraped
    * total - Total URLs to scrape
    * creditsUsed - API credits consumed
    * expiresAt - Data expiration timestamp
    
    Results:
    * data - List of scraped documents
    * next - URL for next page of results (if paginated)
    * success - Whether status check succeeded
    * error - Error message if failed

Raises:
    Exception: If status check fails
r  Nr  rv   r  r  r[  r  r  r  )r  r  rv   r  r  r  r   r   FT)	r  r  r  r_  r  r  r   r`  r	  rI  s	   &&       r!   r  -AsyncV1FirecrawlApp.check_batch_scrape_status  s    2 '')&rd+ 33||nXJ'
 

 x K/$"6*+;v./14*v6H#'HI&*&=&=h&P PIKK	fb 9:"+K&*F#.??8,//'*!ook2#6!ook2(
 k! +G 4HW[ *62HV ; 6u

 	
<@

 	
G
 !Qs)   9FFAF*F FCFFc                &   < V ^8  d   QhRS[ RS[/# rW  rk  )r-   r.   s   "r!   r/   r    s     
 
# 
:O 
r1   c                   "   V P                  4       pV P                  V P                   RV R2V4      G Rj  xL
 #  L5i)a  
Get information about errors from an asynchronous batch scrape job.

Args:
  id (str): The ID of the batch scrape job

Returns:
  V1CrawlErrorsResponse containing:
    errors (List[Dict[str, str]]): List of errors with fields:
      * id (str): Error ID
      * timestamp (str): When the error occurred
      * url (str): URL that caused the error
      * error (str): Error message
  * robotsBlocked (List[str]): List of URLs blocked by robots.txt

Raises:
  Exception: If error check fails
r  rm  Nr  r  r  r  r  rt   s   && r!   r  -AsyncV1FirecrawlApp.check_batch_scrape_errors  sJ     & ''),,||n-bT9
 
 	
 
   6?=?c                &   < V ^8  d   QhRS[ RS[/# rW  rk  )r-   r.   s   "r!   r/   r    s     
 
3 
3H 
r1   c                   "   V P                  4       pV P                  V P                   RV R2V4      G Rj  xL
 #  L5i)a  
Get information about errors from an asynchronous crawl job.

Args:
    id (str): The ID of the crawl job

Returns:
    V1CrawlErrorsResponse containing:
    * errors (List[Dict[str, str]]): List of errors with fields:
        - id (str): Error ID
        - timestamp (str): When the error occurred
        - url (str): URL that caused the error
        - error (str): Error message
    * robotsBlocked (List[str]): List of URLs blocked by robots.txt

Raises:
    Exception: If error check fails
rZ  rm  NrY  rZ  s   && r!   rp  &AsyncV1FirecrawlApp.check_crawl_errors  sI     & ''),,||nJrd'2
 
 	
 
r\  c                <   < V ^8  d   QhRS[ RS[S[ S[3,          /# rW  rt  )r-   r.   s   "r!   r/   r    s#     - -S -T#s(^ -r1   c           
        "   V P                  4       p\        P                  ! 4       ;_uu_4       GRj  xL
 pVP                  V P                   RV 2VR7      ;_uu_4       GRj  xL
 pVP                  4       G Rj  xL
 uuRRR4      GRj  xL
  uuRRR4      GRj  xL
  #  Ls LB L, L L  + GRj  xL 
 '       g   i     M; iRRR4      GRj  xL 
  R#   + GRj  xL 
 '       g   i     R# ; i5i)rv  NrZ  r  )r  r  r  r  r  rO   )r  r  rt   r  r  s   &&   r!   rx   AsyncV1FirecrawlApp.cancel_crawl  s      '')((***g~~j&Ew~WWW[c%]]_, XWW +**W, X +WWWW +*****s   2C>B(C>/C!'B*(C!+B2	?B, B2	C!B.
C!C>"B0#C>*C!,B2	.C!0C>2C8B;9
CCC!C>CC>!C;	'C*(
C;	3C;	5	C>c                6   < V ^8  d   QhRS[ RS[S[,          /# r  r  )r-   r.   s   "r!   r/   r    s!     % %s %7H7M %r1   c                   "   V P                  4       p V P                  V P                   RV 2V4      G Rj  xL
 #  L  \         d   p\	        \        T4      4      hRp?ii ; i5i)a  
Check the status of an asynchronous extraction job.

Args:
    job_id (str): The ID of the extraction job

Returns:
    V1ExtractResponse[Any] with:
    * success (bool): Whether request succeeded
    * data (Optional[Any]): Extracted data matching schema
    * error (Optional[str]): Error message if any
    * warning (Optional[str]): Warning message if any
    * sources (Optional[List[str]]): Source URLs if requested

Raises:
    ValueError: If status check fails
r  Nr  r  r  r   r  r,   )r  r  rt   rg  s   &&  r!   r  &AsyncV1FirecrawlApp.get_extract_status  sl     $ '')	%00<<.VH5     	%SV$$	%1   A&$? =? A&? A#
AA##A&c                  < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[S[S[3,          ,          R	S[S[,          /	# r  r  )r-   r.   s   "r!   r/   r  ,  s     D% D%49%D% SM	D%
 SMD% $C=D% #+4.D%  (~D% #4.D% DcN+D% 8I7MD%r1   c          	       "   V P                  4       p	V'       g   V'       g   \        R4      hV'       g   V'       g   \        R4      hV'       d   V P                  V4      p\        T;'       g    . VVVVR\         2R7      p
V'       d   W*R&   V'       d   WJR&   V'       d   WR&    V P                  V P                   R2V
V	4      G R	j  xL
 #  L  \         d   p\        \        T4      4      hR	p?ii ; i5i)
aV  
Initiate an asynchronous extraction job without waiting for completion.

Args:
    urls (Optional[List[str]]): URLs to extract from
    prompt (Optional[str]): Custom extraction prompt
    schema (Optional[Any]): JSON schema/Pydantic model
    system_prompt (Optional[str]): System context
    allow_external_links (Optional[bool]): Follow external links
    enable_web_search (Optional[bool]): Enable web search
    show_sources (Optional[bool]): Include source URLs
    agent (Optional[Dict[str, Any]]): Agent configuration
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests

Returns:
    V1ExtractResponse[Any] with:
    * success (bool): Whether request succeeded
    * data (Optional[Any]): Extracted data matching schema
    * error (Optional[str]): Error message if any

Raises:
    ValueError: If job initiation fails
r  r  r  )r  r"  rN  rP  r}   rO  r*   r   r   r  N)	r  r  r  rS  r  r
  r  r   r,   )r  r  r*   r}   r  r  r  r  r   rt   r  rg  s   &&$$$$$$$   r!   r  !AsyncV1FirecrawlApp.async_extract,  s     D '')fBCCF@AA--f5F(3-$ 	*
 %+"+8($)!	%11<<.,   
  	%SV$$	%sh    C:C:C:C:C:0C:C:C:$C:)#C CC C:C C7C22C77C:r  r  r  c          
      h   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[/# )r(   r^   r  r  r  r  r  )r-   r.   s   "r!   r/   r  r  sQ     ;W ;W;W sm	;W
 %TN;W "*$;W <\;Wr1   c                 "   / pVe   W%R&   Ve   W5R&   Ve   WER&   V P                  VVVVR7      G Rj  xL
 pVP                  R4      '       d   RV9  d   V# VR,          p V P                  V4      G Rj  xL
 pVR,          R	8X  d   V# VR,          R
8X  d   \        RVP                  R4       24      hVR,          R8w  d   M \        P
                  ! ^4      G Rj  xL
  K  \        RRR
RR7      #  L L L5i)aw  
Generate LLMs.txt for a given URL and monitor until completion.

Args:
    url (str): Target URL to generate LLMs.txt from
    max_urls (Optional[int]): Maximum URLs to process (default: 10)
    show_full_text (Optional[bool]): Include full text in output (default: False)
    experimental_stream (Optional[bool]): Enable experimental streaming

Returns:
    V1GenerateLLMsTextStatusResponse containing:
    * success (bool): Whether generation completed successfully
    * status (str): Status of generation (processing/completed/failed)
    * data (Dict[str, str], optional): Generated text with fields:
        - llmstxt (str): Generated LLMs.txt content
        - llmsfulltxt (str, optional): Full version if requested
    * error (str, optional): Error message if generation failed
    * expiresAt (str): When the generated data expires

Raises:
    Exception: If generation fails
Nr  r  r  )r  r  r  r   r  r  rv   rw   z#LLMs.txt generation failed. Error: r   rW  Fr  r0  r  )r  r  r  r   r  r  r  )	r  r^   r  r  r  r  r  r  r  s	   &&$$$    r!   r  &AsyncV1FirecrawlApp.generate_llms_textr  s*    :  (9%%3>"*.A*+66) 3	 7 
 
 ||I&&$h*>O$??GGFh;.!X-"EfjjQXFYEZ [\\!\1--"""/Ev  @H  TV  W  	W-
 H #s:   3C<C6C<'C<8C89A'C< C:!C<8C<:C<r  c                ~   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# r  r  )r-   r.   s   "r!   r/   r    sX     5% 5%5% sm	5%
 %TN5% D>5% "*$5% <V5%r1   c               f  "   / pVe   W&R&   Ve   W6R&   Ve   WVR&   \        VVVVR7      pV P                  4       pRV/VP                  RRR7      CpR	\         2VR
&    V P	                  V P
                   R2VV4      G Rj  xL
 #  L  \         d   p	\        \        T	4      4      hRp	?	ii ; i5i)a  
Initiate an asynchronous LLMs.txt generation job without waiting for completion.

Args:
    url (str): Target URL to generate LLMs.txt from
    max_urls (Optional[int]): Maximum URLs to process (default: 10)
    show_full_text (Optional[bool]): Include full text in output (default: False)
    cache (Optional[bool]): Whether to use cached content if available (default: True)
    experimental_stream (Optional[bool]): Enable experimental streaming

Returns:
    V1GenerateLLMsTextResponse containing:
    * success (bool): Whether job started successfully
    * id (str): Unique identifier for the job
    * error (str, optional): Error message if start failed

Raises:
    ValueError: If job initiation fails
Nr  r  r  r  r^   Tr  r  rO  r  )	r  r  r  r  r
  r  r   r  r,   )
r  r^   r  r  r  r  r  rt   r  rg  s
   &&$$$$    r!   r  ,AsyncV1FirecrawlApp.async_generate_llms_text  s     6  (9%%3>"*.A*+)'"5	
 '')CQ6;;4;#PQ	 +G95	(	%11<<.,   
  	%SV$$	%s<   AB1 #B
 BB
 B1B
 
B.B))B..B1c                &   < V ^8  d   QhRS[ RS[/# rW  r  )r-   r.   s   "r!   r/   r    s     % % %@` %r1   c                   "   V P                  4       p V P                  V P                   RV 2V4      G Rj  xL
 #  L  \         d   p\	        \        T4      4      hRp?ii ; i5i)a  
Check the status of an asynchronous LLMs.txt generation job.

Args:
    id (str): The ID of the generation job

Returns:
    V1GenerateLLMsTextStatusResponse containing:
    * success (bool): Whether generation completed successfully
    * status (str): Status of generation (processing/completed/failed)
    * data (Dict[str, str], optional): Generated text with fields:
        - llmstxt (str): Generated LLMs.txt content
        - llmsfulltxt (str, optional): Full version if requested
    * error (str, optional): Error message if generation failed
    * expiresAt (str): When the generated data expires

Raises:
    ValueError: If status check fails
r  Nre  r  r  rt   rg  s   &&  r!   r  3AsyncV1FirecrawlApp.check_generate_llms_text_status  sl     ( '')	%00<<.RD1     	%SV$$	%rg  r#  r$  /_AsyncV1FirecrawlApp__experimental_stream_stepsr&  r'  c                .  < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[,          RS[S[S[S[ S[3,          .R	3,          ,          R
S[S[S[S[ S[3,          .R	3,          ,          RS[/
# )r(   r_  r;  r#  r  r$  r  ru  r&  Nr'  r  r)  )r-   r.   s   "r!   r/   r    s     ^n ^n^n  }	^n
 !^n sm^n &c]^n $C=^n *2$^n "(DcN+;T+A"BC^n  $sCx.)94)? @A^n Nj^nr1   c          	     F  "   / p
Ve   W*R&   Ve   W:R&   Ve   WJR&   Ve   WZR&   Ve   WjR&   Ve   WzR&   \        R/ V
B p
V P                  VVVVVVR7      G Rj  xL
 pVP                  R	4      '       d   R
V9  d   V# VR
,          p^ p^ p V P                  V4      G Rj  xL
 pV'       d7   RV9   d0   VR,          VR pV F  pV! V4       K  	  \	        VR,          4      pV	'       d7   RV9   d0   VR,          VR pV F  pV	! V4       K  	  \	        VR,          4      pVR,          R8X  d   V# VR,          R8X  d   \        RVP                  R4       24      hVR,          R8w  d   M!\        P                  ! ^4      G Rj  xL
  EK  \        RRR7      #  EL@ L L5i)r+  Nr  r  r  r  r   r,  r-  r   r  r  rU  r  rv   rw   r.  r   rW  Fr/  r  r2   )	r  r0  r  r1  r_  r   r  r  r  )r  r_  r;  r#  r  r$  r  ru  r&  r'  r2  r  r  r3  r4  r  r5  r6  r7  r8  s   &&$$$$$$$$          r!   r9  !AsyncV1FirecrawlApp.deep_research  s    P  *3J'!+5K()1I&&0?,-$.;N+&2<W89.AA11!+' 2 
 
 ||I&&$h*>O$::6BBF|v5!'!56I6J!K .H) !/&)&*>&?#Y&0$Y/0A0BC)Ff% *$'y(9$:!h;.!X-"?

7@S?T UVV!\1--"""+EAlmmO
  C* #sI   AF!FF!6+F!!F"F!.=F!,BF!FF!F!F!c                   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[,          RS[S[ S[3,          /# )	r(   r_  r;  r#  r  r$  r  ru  r  r<  )r-   r.   s   "r!   r/   r  c  s}     :% :%:%  }	:%
 !:% sm:% &c]:% $C=:% *2$:% DHS>:%r1   c                 "   / pVe   W(R&   Ve   W8R&   Ve   WHR&   Ve   WXR&   Ve   WhR&   Ve   WxR&   \        R/ VB pV P                  4       p	RV/VP                  R	R	R
7      Cp
R\         2V
R&    V P	                  V P
                   R2V
V	4      G Rj  xL
 #  L  \         d   p\        \        T4      4      hRp?ii ; i5i)r>  Nr  r  r  r  r   r,  r_  Tr  r  rO  r?  r2   )	r  r  r  r  r
  r  r   r  r,   )r  r_  r;  r#  r  r$  r  ru  r2  rt   r  rg  s   &&$$$$$$    r!   r0  'AsyncV1FirecrawlApp.async_deep_researchc  s    >  *3J'!+5K()1I&&0?,-$.;N+&2<W89.AA'')e^';';TX\';']^	 +G95	(	%11<<. 12   
  	%SV$$	%s<   A1C4#B BB CB C)B==CCc                &   < V ^8  d   QhRS[ RS[/# rW  rD  )r-   r.   s   "r!   r/   r    s      %  %3  %;W  %r1   c                   "   V P                  4       p V P                  V P                   RV 2V4      G Rj  xL
 #  L  \         d   p\	        \        T4      4      hRp?ii ; i5i)rF  rG  Nre  rs  s   &&  r!   r1  .AsyncV1FirecrawlApp.check_deep_research_status  sm     2 '')	%00<<. 22$7     	%SV$$	%rg  r`  ra  rb  rn   c                  < V ^8  d   QhRS[ RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[,          R	S[S[,          R
S[S[S[S[ S[3,          S[3,          ,          RS[/# )r(   r_  r  r`  ra  rb  rn   r   r   r  r  r  )	r,   r   r   r   r   r   r   rZ  re  )r-   r.   s   "r!   r/   r    s     N
 N
N
 C=	N

 #N
 SMN
 3-N
 c]N
 smN
 c]N
 %_5N
 U4S>>#ABCN
 *N
r1   c       	        B  "   / pV
'       dK   \        V
\        4      '       d   VP                  V
4       M"VP                  V
P                  RRR7      4       Ve   W,R&   Ve   W<R&   Ve   WLR&   Ve   W\R&   Ve   WlR&   Ve   W|R	&   Ve   WR
&   V	e   V	P                  RRR7      VR&   VP                  V4       \        RRV/VB pVP                  RRR7      pR\         2VR&   V P                  V P                   R2VRRV P                   2/4      G Rj  xL
 #  L5i)a  
Asynchronously search for content using Firecrawl.

Args:
    query (str): Search query string
    limit (Optional[int]): Max results (default: 5)
    tbs (Optional[str]): Time filter (e.g. "qdr:d")
    filter (Optional[str]): Custom result filter
    lang (Optional[str]): Language code (default: "en")
    country (Optional[str]): Country code (default: "us") 
    location (Optional[str]): Geo-targeting
    timeout (Optional[int]): Request timeout in milliseconds
    scrape_options (Optional[ScrapeOptions]): Result scraping configuration
    params (Optional[Union[Dict[str, Any], SearchParams]]): Additional search parameters
    **kwargs: Additional keyword arguments for future compatibility

Returns:
    SearchResponse: Response containing:
        * success (bool): Whether request succeeded
        * data (List[FirecrawlDocument]): Search results
        * warning (Optional[str]): Warning message if any
        * error (Optional[str]): Error message if any

Raises:
    Exception: If search fails or response cannot be parsed
Tr  Nr  r`  ra  rb  rn   r   r   r$  r_  r  rO  r  r  r  r2   )r   r  r  rZ  r  r
  r  r  )r  r_  r  r`  ra  rb  rn   r   r   r  r  r  r  r  r  s   &&$$$$$$$$$,   r!   r   AsyncV1FirecrawlApp.search  sU    R &$''$$V,$$V[[$T[%RS %*'"?#&% &,(#$(&!'.)$(0*%'.)$%-;-@-@$]a-@-bM/* 	V$ &CEC]C"''D'I"-gY 7H--||nJ'~67
 
 	
 
s   DDDDr2   )r  )Nr  r  r  r  )r(   r  )(r3   r4   r5   r6   r7   r  r  r
  r  r  r  r"  r)  r  r  r  r  r  rJ  rT  rh  r;  r  rc   r  r  rp  rx  r  r  r  r  r  r9  r0  r1  r   r9   r:   __classcell__r  r.   s   @@r!   r  r    s<    
; ;+4 +4Z^ ^.] ],+ +6Z Z- -, ,*9 *9X(@ (@TDM mq	DM
 15DM 15DM 15DM 15DM '+DM &+DM 48DM &*DM 59DM 48DM )-DM  PT!DM" )-#DM$ /3%DM& 48'DM( EI)DM DMLHC W[	HC
 -1HC -1HC -1HC -1HC #'HC "'HC 04HC "&HC 15HC 04HC %)HC  LP!HC" +/#HC$ 04%HC& AE'HC( +/)HC* ()+HC, *.-HC HCVJI W[	JI
 -1JI -1JI -1JI -1JI #'JI "'JI 04JI "&JI 15JI 04JI %)JI  LP!JI" +/#JI$ 04%JI& AE'JI( +/)JI* /3+JI, *.-JI JIXuB .2	uB
 .2uB $(uB .2uB  $uB 04uB /3uB 04uB *.uB 59uB :>uB 48uB  37!uB" -1#uB$  $%uB& ,0'uB( ())uB* *.+uB uBpsB .2	sB
 .2sB $(sB .2sB  $sB 04sB /3sB 04sB *.sB 59sB :>sB 48sB  37!sB" -1#sB$  $%sB& ,0'sB( ())sB* *.+sB sBj@ @D)_ )_VKE !%	KE
 *.KE .2KE (,KE  $KE "'KE 04KE )-KE KEZdR %)	dR
 %)dR ,0dR 49dR 16dR ,1dR /3dR dRLB
 B
H
 
2
 
2- -(% %6D% %)	D%
 %)D% ,0D% 49D% 16D% ,1D% /3D% D%L;W '+	;W
 .2;W 37;W ;Wz5% '+	5%
 .25% %)5% 375% 5%n% %:^n (,	^n
 )-^n '+^n .2^n ,0^n ;?^n GK^n EI^n ^n@:% (,	:%
 )-:% '+:% .2:% ,0:% ;?:% :%x %  %DN
 $(	N

 "&N
 %)N
 #'N
 &*N
 '+N
 &+N
 9=N
 GKN
 N
 N
r1   r  c                      a a ] tR tRt oRtV3R lV 3R lltV3R lR ltV3R lR ltV3R	 lR
 ltV3R lR lt	V3R lR lt
RtVtV ;t# )r-  i  zI
Async version of V1CrawlWatcher that properly handles async operations.
c                &   < V ^8  d   QhRS[ RS[/# r  )r,   r  )r-   r.   s   "r!   r/    AsyncV1CrawlWatcher.__annotate__  s     " "3 "%8 "r1   c                &   < \         SV `  W4       R # r  r  )r  r  r  r  s   &&&r!   r  AsyncV1CrawlWatcher.__init__  s    !r1   c                   < V ^8  d   QhRR/# r  r2   )r-   r.   s   "r!   r/   r    s     * *t *r1   c                @  "   \         P                  ! V P                  RRV P                  P                   23.R7      ;_uu_4       GRj  xL
 pV P                  V4      G Rj  xL
  RRR4      GRj  xL
  R#  L/ L L
  + GRj  xL 
 '       g   i     R# ; i5i)zK
Establishes async WebSocket connection and starts listening for messages.
r  r  )r  Nr  r  s   & r!   r  AsyncV1CrawlWatcher.connect  s      %%KK!0GDHH<L<L;M2N OP
 
 
 ,,y)))	
 
 
 *	
 
 
 
s`   A	BA;BB$A=%B)B4A?5B=B?BB	B

B	B		Bc                   < V ^8  d   QhRR/# r  r2   )r-   r.   s   "r!   r/   r  "  r  r1   c                   "   V  Rj  xL
  p\         P                  ! V4      pV P                  V4      G Rj  xL
  K;   L6 LD9R# 5i)z
Listens for incoming WebSocket messages and handles them asynchronously.

Args:
    websocket: The WebSocket connection object
Nr  r  s   &&  r!   r  AsyncV1CrawlWatcher._listen"  r  r  c                :   < V ^8  d   QhRS[ S[S[3,          RR/# r  rK  )r-   r.   s   "r!   r/   r  -  r  r1   c                  "   VR,          R8X  d@   RV n         V P                  RRV P                   RV P                  RV P                  /4       R# VR,          R8X  dI   RV n         V P                  RRV P                   RV P                  RVR,          RV P                  /4       R# VR,          R	8X  d}   VR,          R,          V n         V P                  P	                  VR,          P                  R. 4      4       V P                   F#  pV P                  R
RVRV P                  /4       K%  	  R# VR,          R
8X  dL   V P                  P                  VR,          4       V P                  R
RVR,          RV P                  /4       R# R# 5i)z
Handles incoming WebSocket messages based on their type asynchronously.

Args:
    msg (Dict[str, Any]): The message to handle
r   r  rv   r  r  r  r   rw   r  r  Nr  r  s   && r!   r  #AsyncV1CrawlWatcher._handle_message-  r  r  c                >   < V ^8  d   QhRS[ P                  RS[RR/# r  r  )r-   r.   s   "r!   r/   r  C  s)     + +G,B,B +C +TX +r1   c                f  "    VP                  4       G Rj  xL
 pVP                  RR4      pVP                  RR4      pT P
                  P                  TP                  Y$T4      G Rj  xL
 p\        P                  ! T4      h Lm   \        P                  ! RTP                   24      h; i LD5i)z)
Handle errors from async API responses.
Nr   r  r  r  r  )rO   r  r  r  r  r  r  r  s   &&&    r!   r  !AsyncV1CrawlWatcher._handle_errorC  s     	{'}}.J&NN74PQM&NN96]^M
 99(//6bopp!!'** /	{%%(ghphwhwgx&yzz qs8   B1B B(B  *B1*B/+B1B %B,,B1c          
      8   < V ^8  d   QhRS[ RS[RS[RS[RS[/# r  r  )r-   r.   s   "r!   r/   r  S  r  r1   c                .   "   V P                  WW44      # 5ir  r  r!  s   &&&&&r!   r  ,AsyncV1CrawlWatcher._get_async_error_messageS  r!  r"  )r  )r3   r4   r5   r6   r7   r  r  r  r  r  r  r9   r:   r  r  s   @@r!   r-  r-    sP     " "* *	, 	,R R,+ + Z Z Zr1   r-  c                T    V ^8  d   Qh/ ^ \         9   d   \        P                  ;R&   # )r(   r  )__conditional_annotations__loggingLogger)r-   s   "r!   r/   r/      s"      4 9 8 85r1   )Tr  r7   r  r   r  typingr   r   r   r   r   r   r   r	   r
   rO   r   r   r  rY   r  r  r  	getLoggerr  r"   r  r#   	BaseModelr%   r=   rG   rN   r\   rl   rr   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r-  r1  r5  r;  rA  rH  rL  rS  rZ  re  rj  rs  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r{  r  r-  r/   )r  s   @r!   <module>r     sV    	  X X X   	     !++K8 8
 -CLJ!X'' !
(H.. (h(( 
C8-- C:(,,gaj : *x)) *
Uh(( Uh00 $h(( $(#8%% #"++ "H&& 
H&& 
H&& 
#X'' #X''  2 2 
"($$ "(X'' (+8%% +._ . *1-wqz  ,H.. ,	$("4"4 	$+H&& +( h((  	$H.. 	$8%% H.. 
	0($$ 	0 H&&  
4h(( 
4
&**GAJ 
&
4X'' 
4 x))  -** -H.. -x)) -8-- H$6$6 1h&8&8 18#5#5 0X%7%7 01x11 1	68-- 	6 X//  8#5#5  !3!3  &8+=+= &x'9'9  x))  +h(( +b*  b* JUYR YRvh
. h
T9OZ. OZr1   