firecrawl 4.1.1__tar.gz → 4.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of firecrawl might be problematic. Click here for more details.
- {firecrawl-4.1.1 → firecrawl-4.3.0}/PKG-INFO +1 -1
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__init__.py +1 -1
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v1/client.py +142 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/client.py +12 -0
- firecrawl-4.3.0/firecrawl/v2/methods/aio/usage.py +72 -0
- firecrawl-4.3.0/firecrawl/v2/methods/usage.py +84 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/types.py +34 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl.egg-info/PKG-INFO +1 -1
- firecrawl-4.1.1/firecrawl/v2/methods/aio/usage.py +0 -42
- firecrawl-4.1.1/firecrawl/v2/methods/usage.py +0 -41
- {firecrawl-4.1.1 → firecrawl-4.3.0}/LICENSE +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/README.md +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/aio/test_aio_batch_scrape.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/aio/test_aio_crawl.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/aio/test_aio_extract.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/aio/test_aio_map.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/aio/test_aio_scrape.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/aio/test_aio_search.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/aio/test_aio_usage.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/aio/test_aio_watcher.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/conftest.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/test_async.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/test_batch_scrape.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/test_crawl.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/test_extract.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/test_map.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/test_scrape.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/test_search.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/test_usage.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/e2e/v2/test_watcher.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_aio_crawl_params.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_aio_crawl_request_preparation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_aio_crawl_validation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_aio_map_request_preparation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_aio_scrape_request_preparation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_aio_search_request_preparation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_batch_request_preparation_async.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_ensure_async.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_batch_request_preparation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_crawl_params.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_crawl_request_preparation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_crawl_validation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_map_request_preparation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_pagination.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_scrape_request_preparation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_search_request_preparation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_search_validation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_usage_types.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_webhook.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/utils/test_validation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/watcher/test_ws_watcher.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/client.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/firecrawl.backup.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/types.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v1/__init__.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/__init__.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/client_async.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/aio/__init__.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/aio/batch.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/aio/crawl.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/aio/extract.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/aio/map.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/aio/scrape.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/aio/search.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/batch.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/crawl.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/extract.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/map.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/scrape.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/methods/search.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/utils/__init__.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/utils/error_handler.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/utils/get_version.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/utils/http_client.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/utils/http_client_async.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/utils/normalize.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/utils/validation.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/watcher.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/v2/watcher_async.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl.egg-info/SOURCES.txt +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl.egg-info/dependency_links.txt +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl.egg-info/requires.txt +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl.egg-info/top_level.txt +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/pyproject.toml +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/setup.cfg +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/setup.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/tests/test_change_tracking.py +0 -0
- {firecrawl-4.1.1 → firecrawl-4.3.0}/tests/test_timeout_conversion.py +0 -0
|
@@ -358,6 +358,46 @@ class V1SearchResponse(pydantic.BaseModel):
|
|
|
358
358
|
warning: Optional[str] = None
|
|
359
359
|
error: Optional[str] = None
|
|
360
360
|
|
|
361
|
+
class V1CreditUsageData(pydantic.BaseModel):
|
|
362
|
+
remaining_credits: int
|
|
363
|
+
plan_credits: Optional[int] = None
|
|
364
|
+
billing_period_start: Optional[str] = None
|
|
365
|
+
billing_period_end: Optional[str] = None
|
|
366
|
+
|
|
367
|
+
class V1CreditUsageResponse(pydantic.BaseModel):
|
|
368
|
+
success: bool
|
|
369
|
+
data: V1CreditUsageData
|
|
370
|
+
|
|
371
|
+
class V1TokenUsageData(pydantic.BaseModel):
|
|
372
|
+
remaining_tokens: int
|
|
373
|
+
plan_tokens: Optional[int] = None
|
|
374
|
+
billing_period_start: Optional[str] = None
|
|
375
|
+
billing_period_end: Optional[str] = None
|
|
376
|
+
|
|
377
|
+
class V1TokenUsageResponse(pydantic.BaseModel):
|
|
378
|
+
success: bool
|
|
379
|
+
data: V1TokenUsageData
|
|
380
|
+
|
|
381
|
+
class V1CreditUsageHistoricalPeriod(pydantic.BaseModel):
|
|
382
|
+
startDate: Optional[str] = None
|
|
383
|
+
endDate: Optional[str] = None
|
|
384
|
+
apiKey: Optional[str] = None
|
|
385
|
+
creditsUsed: int
|
|
386
|
+
|
|
387
|
+
class V1CreditUsageHistoricalResponse(pydantic.BaseModel):
|
|
388
|
+
success: bool
|
|
389
|
+
periods: List[V1CreditUsageHistoricalPeriod]
|
|
390
|
+
|
|
391
|
+
class V1TokenUsageHistoricalPeriod(pydantic.BaseModel):
|
|
392
|
+
startDate: Optional[str] = None
|
|
393
|
+
endDate: Optional[str] = None
|
|
394
|
+
apiKey: Optional[str] = None
|
|
395
|
+
tokensUsed: int
|
|
396
|
+
|
|
397
|
+
class V1TokenUsageHistoricalResponse(pydantic.BaseModel):
|
|
398
|
+
success: bool
|
|
399
|
+
periods: List[V1TokenUsageHistoricalPeriod]
|
|
400
|
+
|
|
361
401
|
class V1GenerateLLMsTextParams(pydantic.BaseModel):
|
|
362
402
|
"""
|
|
363
403
|
Parameters for the LLMs.txt generation operation.
|
|
@@ -722,6 +762,90 @@ class V1FirecrawlApp:
|
|
|
722
762
|
else:
|
|
723
763
|
self._handle_error(response, 'search')
|
|
724
764
|
|
|
765
|
+
def get_credit_usage(self) -> V1CreditUsageResponse:
|
|
766
|
+
"""Get current credit usage and billing period (v1)."""
|
|
767
|
+
_headers = self._prepare_headers()
|
|
768
|
+
response = self._get_request(
|
|
769
|
+
f"{self.api_url}/v1/team/credit-usage",
|
|
770
|
+
_headers
|
|
771
|
+
)
|
|
772
|
+
|
|
773
|
+
if response.status_code == 200:
|
|
774
|
+
try:
|
|
775
|
+
response_json = response.json()
|
|
776
|
+
if response_json.get('success') and 'data' in response_json:
|
|
777
|
+
return V1CreditUsageResponse(**response_json)
|
|
778
|
+
elif "error" in response_json:
|
|
779
|
+
raise Exception(f"Failed to get credit usage. Error: {response_json['error']}")
|
|
780
|
+
else:
|
|
781
|
+
raise Exception(f"Failed to get credit usage. Error: {response_json}")
|
|
782
|
+
except ValueError:
|
|
783
|
+
raise Exception('Failed to parse Firecrawl response as JSON.')
|
|
784
|
+
else:
|
|
785
|
+
self._handle_error(response, 'get credit usage')
|
|
786
|
+
|
|
787
|
+
def get_token_usage(self) -> V1TokenUsageResponse:
|
|
788
|
+
"""Get current token usage and billing period (v1)."""
|
|
789
|
+
_headers = self._prepare_headers()
|
|
790
|
+
response = self._get_request(
|
|
791
|
+
f"{self.api_url}/v1/team/token-usage",
|
|
792
|
+
_headers
|
|
793
|
+
)
|
|
794
|
+
|
|
795
|
+
if response.status_code == 200:
|
|
796
|
+
try:
|
|
797
|
+
response_json = response.json()
|
|
798
|
+
if response_json.get('success') and 'data' in response_json:
|
|
799
|
+
return V1TokenUsageResponse(**response_json)
|
|
800
|
+
elif "error" in response_json:
|
|
801
|
+
raise Exception(f"Failed to get token usage. Error: {response_json['error']}")
|
|
802
|
+
else:
|
|
803
|
+
raise Exception(f"Failed to get token usage. Error: {response_json}")
|
|
804
|
+
except ValueError:
|
|
805
|
+
raise Exception('Failed to parse Firecrawl response as JSON.')
|
|
806
|
+
else:
|
|
807
|
+
self._handle_error(response, 'get token usage')
|
|
808
|
+
|
|
809
|
+
def get_credit_usage_historical(self, by_api_key: bool = False) -> V1CreditUsageHistoricalResponse:
|
|
810
|
+
"""Get historical credit usage (v1)."""
|
|
811
|
+
_headers = self._prepare_headers()
|
|
812
|
+
url = f"{self.api_url}/v1/team/credit-usage/historical" + ("?byApiKey=true" if by_api_key else "")
|
|
813
|
+
response = self._get_request(url, _headers)
|
|
814
|
+
|
|
815
|
+
if response.status_code == 200:
|
|
816
|
+
try:
|
|
817
|
+
response_json = response.json()
|
|
818
|
+
if response_json.get('success') and 'periods' in response_json:
|
|
819
|
+
return V1CreditUsageHistoricalResponse(**response_json)
|
|
820
|
+
elif "error" in response_json:
|
|
821
|
+
raise Exception(f"Failed to get historical credit usage. Error: {response_json['error']}")
|
|
822
|
+
else:
|
|
823
|
+
raise Exception(f"Failed to get historical credit usage. Error: {response_json}")
|
|
824
|
+
except ValueError:
|
|
825
|
+
raise Exception('Failed to parse Firecrawl response as JSON.')
|
|
826
|
+
else:
|
|
827
|
+
self._handle_error(response, 'get credit usage historical')
|
|
828
|
+
|
|
829
|
+
def get_token_usage_historical(self, by_api_key: bool = False) -> V1TokenUsageHistoricalResponse:
|
|
830
|
+
"""Get historical token usage (v1)."""
|
|
831
|
+
_headers = self._prepare_headers()
|
|
832
|
+
url = f"{self.api_url}/v1/team/token-usage/historical" + ("?byApiKey=true" if by_api_key else "")
|
|
833
|
+
response = self._get_request(url, _headers)
|
|
834
|
+
|
|
835
|
+
if response.status_code == 200:
|
|
836
|
+
try:
|
|
837
|
+
response_json = response.json()
|
|
838
|
+
if response_json.get('success') and 'periods' in response_json:
|
|
839
|
+
return V1TokenUsageHistoricalResponse(**response_json)
|
|
840
|
+
elif "error" in response_json:
|
|
841
|
+
raise Exception(f"Failed to get historical token usage. Error: {response_json['error']}")
|
|
842
|
+
else:
|
|
843
|
+
raise Exception(f"Failed to get historical token usage. Error: {response_json}")
|
|
844
|
+
except ValueError:
|
|
845
|
+
raise Exception('Failed to parse Firecrawl response as JSON.')
|
|
846
|
+
else:
|
|
847
|
+
self._handle_error(response, 'get token usage historical')
|
|
848
|
+
|
|
725
849
|
def crawl_url(
|
|
726
850
|
self,
|
|
727
851
|
url: str,
|
|
@@ -2913,6 +3037,24 @@ class AsyncV1FirecrawlApp(V1FirecrawlApp):
|
|
|
2913
3037
|
"""
|
|
2914
3038
|
return self._get_error_message(status_code, action, error_message, error_details)
|
|
2915
3039
|
|
|
3040
|
+
async def get_credit_usage(self) -> V1CreditUsageResponse:
|
|
3041
|
+
"""Get current credit usage and billing period (v1, async)."""
|
|
3042
|
+
headers = self._prepare_headers()
|
|
3043
|
+
resp = await self._async_get_request(
|
|
3044
|
+
f"{self.api_url}/v1/team/credit-usage",
|
|
3045
|
+
headers
|
|
3046
|
+
)
|
|
3047
|
+
return V1CreditUsageResponse(**resp)
|
|
3048
|
+
|
|
3049
|
+
async def get_token_usage(self) -> V1TokenUsageResponse:
|
|
3050
|
+
"""Get current token usage and billing period (v1, async)."""
|
|
3051
|
+
headers = self._prepare_headers()
|
|
3052
|
+
resp = await self._async_get_request(
|
|
3053
|
+
f"{self.api_url}/v1/team/token-usage",
|
|
3054
|
+
headers
|
|
3055
|
+
)
|
|
3056
|
+
return V1TokenUsageResponse(**resp)
|
|
3057
|
+
|
|
2916
3058
|
async def crawl_url_and_watch(
|
|
2917
3059
|
self,
|
|
2918
3060
|
url: str,
|
|
@@ -727,6 +727,18 @@ class FirecrawlClient:
|
|
|
727
727
|
"""Get recent token usage metrics (v2)."""
|
|
728
728
|
return usage_methods.get_token_usage(self.http_client)
|
|
729
729
|
|
|
730
|
+
def get_credit_usage_historical(self, by_api_key: bool = False):
|
|
731
|
+
"""Get historical credit usage (v2)."""
|
|
732
|
+
return usage_methods.get_credit_usage_historical(self.http_client, by_api_key)
|
|
733
|
+
|
|
734
|
+
def get_token_usage_historical(self, by_api_key: bool = False):
|
|
735
|
+
"""Get historical token usage (v2)."""
|
|
736
|
+
return usage_methods.get_token_usage_historical(self.http_client, by_api_key)
|
|
737
|
+
|
|
738
|
+
def get_queue_status(self):
|
|
739
|
+
"""Get metrics about the team's scrape queue."""
|
|
740
|
+
return usage_methods.get_queue_status(self.http_client)
|
|
741
|
+
|
|
730
742
|
def watcher(
|
|
731
743
|
self,
|
|
732
744
|
job_id: str,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from ...utils.http_client_async import AsyncHttpClient
|
|
2
|
+
from ...utils.error_handler import handle_response_error
|
|
3
|
+
from ...types import ConcurrencyCheck, CreditUsage, TokenUsage, CreditUsageHistoricalResponse, TokenUsageHistoricalResponse
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
async def get_concurrency(client: AsyncHttpClient) -> ConcurrencyCheck:
|
|
7
|
+
resp = await client.get("/v2/concurrency-check")
|
|
8
|
+
if resp.status_code >= 400:
|
|
9
|
+
handle_response_error(resp, "get concurrency")
|
|
10
|
+
body = resp.json()
|
|
11
|
+
if not body.get("success"):
|
|
12
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
13
|
+
data = body.get("data", body)
|
|
14
|
+
return ConcurrencyCheck(
|
|
15
|
+
concurrency=data.get("concurrency"),
|
|
16
|
+
max_concurrency=data.get("maxConcurrency", data.get("max_concurrency")),
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
async def get_credit_usage(client: AsyncHttpClient) -> CreditUsage:
|
|
21
|
+
resp = await client.get("/v2/team/credit-usage")
|
|
22
|
+
if resp.status_code >= 400:
|
|
23
|
+
handle_response_error(resp, "get credit usage")
|
|
24
|
+
body = resp.json()
|
|
25
|
+
if not body.get("success"):
|
|
26
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
27
|
+
data = body.get("data", body)
|
|
28
|
+
return CreditUsage(
|
|
29
|
+
remaining_credits=data.get("remainingCredits", data.get("remaining_credits", 0)),
|
|
30
|
+
plan_credits=data.get("planCredits", data.get("plan_credits")),
|
|
31
|
+
billing_period_start=data.get("billingPeriodStart", data.get("billing_period_start")),
|
|
32
|
+
billing_period_end=data.get("billingPeriodEnd", data.get("billing_period_end")),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
async def get_token_usage(client: AsyncHttpClient) -> TokenUsage:
|
|
37
|
+
resp = await client.get("/v2/team/token-usage")
|
|
38
|
+
if resp.status_code >= 400:
|
|
39
|
+
handle_response_error(resp, "get token usage")
|
|
40
|
+
body = resp.json()
|
|
41
|
+
if not body.get("success"):
|
|
42
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
43
|
+
data = body.get("data", body)
|
|
44
|
+
return TokenUsage(
|
|
45
|
+
remaining_tokens=data.get("remainingTokens", data.get("remaining_tokens", 0)),
|
|
46
|
+
plan_tokens=data.get("planTokens", data.get("plan_tokens")),
|
|
47
|
+
billing_period_start=data.get("billingPeriodStart", data.get("billing_period_start")),
|
|
48
|
+
billing_period_end=data.get("billingPeriodEnd", data.get("billing_period_end")),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def get_credit_usage_historical(client: AsyncHttpClient, by_api_key: bool = False) -> CreditUsageHistoricalResponse:
|
|
53
|
+
query = "?byApiKey=true" if by_api_key else ""
|
|
54
|
+
resp = await client.get(f"/v2/team/credit-usage/historical{query}")
|
|
55
|
+
if resp.status_code >= 400:
|
|
56
|
+
handle_response_error(resp, "get credit usage historical")
|
|
57
|
+
body = resp.json()
|
|
58
|
+
if not body.get("success"):
|
|
59
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
60
|
+
return CreditUsageHistoricalResponse(**body)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
async def get_token_usage_historical(client: AsyncHttpClient, by_api_key: bool = False) -> TokenUsageHistoricalResponse:
|
|
64
|
+
query = "?byApiKey=true" if by_api_key else ""
|
|
65
|
+
resp = await client.get(f"/v2/team/token-usage/historical{query}")
|
|
66
|
+
if resp.status_code >= 400:
|
|
67
|
+
handle_response_error(resp, "get token usage historical")
|
|
68
|
+
body = resp.json()
|
|
69
|
+
if not body.get("success"):
|
|
70
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
71
|
+
return TokenUsageHistoricalResponse(**body)
|
|
72
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from ..utils import HttpClient, handle_response_error
|
|
2
|
+
from ..types import ConcurrencyCheck, CreditUsage, QueueStatusResponse, TokenUsage, CreditUsageHistoricalResponse, TokenUsageHistoricalResponse
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def get_concurrency(client: HttpClient) -> ConcurrencyCheck:
|
|
6
|
+
resp = client.get("/v2/concurrency-check")
|
|
7
|
+
if not resp.ok:
|
|
8
|
+
handle_response_error(resp, "get concurrency")
|
|
9
|
+
body = resp.json()
|
|
10
|
+
if not body.get("success"):
|
|
11
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
12
|
+
data = body.get("data", body)
|
|
13
|
+
return ConcurrencyCheck(
|
|
14
|
+
concurrency=data.get("concurrency"),
|
|
15
|
+
max_concurrency=data.get("maxConcurrency", data.get("max_concurrency")),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_credit_usage(client: HttpClient) -> CreditUsage:
|
|
20
|
+
resp = client.get("/v2/team/credit-usage")
|
|
21
|
+
if not resp.ok:
|
|
22
|
+
handle_response_error(resp, "get credit usage")
|
|
23
|
+
body = resp.json()
|
|
24
|
+
if not body.get("success"):
|
|
25
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
26
|
+
data = body.get("data", body)
|
|
27
|
+
return CreditUsage(
|
|
28
|
+
remaining_credits=data.get("remainingCredits", data.get("remaining_credits", 0)),
|
|
29
|
+
plan_credits=data.get("planCredits", data.get("plan_credits")),
|
|
30
|
+
billing_period_start=data.get("billingPeriodStart", data.get("billing_period_start")),
|
|
31
|
+
billing_period_end=data.get("billingPeriodEnd", data.get("billing_period_end")),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_token_usage(client: HttpClient) -> TokenUsage:
|
|
36
|
+
resp = client.get("/v2/team/token-usage")
|
|
37
|
+
if not resp.ok:
|
|
38
|
+
handle_response_error(resp, "get token usage")
|
|
39
|
+
body = resp.json()
|
|
40
|
+
if not body.get("success"):
|
|
41
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
42
|
+
data = body.get("data", body)
|
|
43
|
+
return TokenUsage(
|
|
44
|
+
remaining_tokens=data.get("remainingTokens", data.get("remaining_tokens", 0)),
|
|
45
|
+
plan_tokens=data.get("planTokens", data.get("plan_tokens")),
|
|
46
|
+
billing_period_start=data.get("billingPeriodStart", data.get("billing_period_start")),
|
|
47
|
+
billing_period_end=data.get("billingPeriodEnd", data.get("billing_period_end")),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
def get_queue_status(client: HttpClient) -> QueueStatusResponse:
|
|
51
|
+
resp = client.get("/v2/team/queue-status")
|
|
52
|
+
if not resp.ok:
|
|
53
|
+
handle_response_error(resp, "get queue status")
|
|
54
|
+
body = resp.json()
|
|
55
|
+
if not body.get("success"):
|
|
56
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
57
|
+
data = body.get("data", body)
|
|
58
|
+
return QueueStatusResponse(
|
|
59
|
+
jobs_in_queue=data.get("jobsInQueue", 0),
|
|
60
|
+
active_jobs_in_queue=data.get("activeJobsInQueue", 0),
|
|
61
|
+
waiting_jobs_in_queue=data.get("waitingJobsInQueue", 0),
|
|
62
|
+
max_concurrency=data.get("maxConcurrency", 0),
|
|
63
|
+
most_recent_success=data.get("mostRecentSuccess", None),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def get_credit_usage_historical(client: HttpClient, by_api_key: bool = False) -> CreditUsageHistoricalResponse:
|
|
68
|
+
resp = client.get(f"/v2/team/credit-usage/historical{'?byApiKey=true' if by_api_key else ''}")
|
|
69
|
+
if not resp.ok:
|
|
70
|
+
handle_response_error(resp, "get credit usage historical")
|
|
71
|
+
body = resp.json()
|
|
72
|
+
if not body.get("success"):
|
|
73
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
74
|
+
return CreditUsageHistoricalResponse(**body)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def get_token_usage_historical(client: HttpClient, by_api_key: bool = False) -> TokenUsageHistoricalResponse:
|
|
78
|
+
resp = client.get(f"/v2/team/token-usage/historical{'?byApiKey=true' if by_api_key else ''}")
|
|
79
|
+
if not resp.ok:
|
|
80
|
+
handle_response_error(resp, "get token usage historical")
|
|
81
|
+
body = resp.json()
|
|
82
|
+
if not body.get("success"):
|
|
83
|
+
raise Exception(body.get("error", "Unknown error"))
|
|
84
|
+
return TokenUsageHistoricalResponse(**body)
|
|
@@ -480,10 +480,44 @@ class ConcurrencyCheck(BaseModel):
|
|
|
480
480
|
class CreditUsage(BaseModel):
|
|
481
481
|
"""Remaining credits for the team/API key."""
|
|
482
482
|
remaining_credits: int
|
|
483
|
+
plan_credits: Optional[int] = None
|
|
484
|
+
billing_period_start: Optional[str] = None
|
|
485
|
+
billing_period_end: Optional[str] = None
|
|
483
486
|
|
|
484
487
|
class TokenUsage(BaseModel):
|
|
485
488
|
"""Recent token usage metrics (if available)."""
|
|
486
489
|
remaining_tokens: int
|
|
490
|
+
plan_tokens: Optional[int] = None
|
|
491
|
+
billing_period_start: Optional[str] = None
|
|
492
|
+
billing_period_end: Optional[str] = None
|
|
493
|
+
|
|
494
|
+
class QueueStatusResponse(BaseModel):
|
|
495
|
+
"""Metrics about the team's scrape queue."""
|
|
496
|
+
jobs_in_queue: int
|
|
497
|
+
active_jobs_in_queue: int
|
|
498
|
+
waiting_jobs_in_queue: int
|
|
499
|
+
max_concurrency: int
|
|
500
|
+
most_recent_success: Optional[datetime] = None
|
|
501
|
+
|
|
502
|
+
class CreditUsageHistoricalPeriod(BaseModel):
|
|
503
|
+
startDate: Optional[str] = None
|
|
504
|
+
endDate: Optional[str] = None
|
|
505
|
+
apiKey: Optional[str] = None
|
|
506
|
+
creditsUsed: int
|
|
507
|
+
|
|
508
|
+
class CreditUsageHistoricalResponse(BaseModel):
|
|
509
|
+
success: bool
|
|
510
|
+
periods: List[CreditUsageHistoricalPeriod]
|
|
511
|
+
|
|
512
|
+
class TokenUsageHistoricalPeriod(BaseModel):
|
|
513
|
+
startDate: Optional[str] = None
|
|
514
|
+
endDate: Optional[str] = None
|
|
515
|
+
apiKey: Optional[str] = None
|
|
516
|
+
tokensUsed: int
|
|
517
|
+
|
|
518
|
+
class TokenUsageHistoricalResponse(BaseModel):
|
|
519
|
+
success: bool
|
|
520
|
+
periods: List[TokenUsageHistoricalPeriod]
|
|
487
521
|
|
|
488
522
|
# Action types
|
|
489
523
|
class WaitAction(BaseModel):
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
from ...utils.http_client_async import AsyncHttpClient
|
|
2
|
-
from ...utils.error_handler import handle_response_error
|
|
3
|
-
from ...types import ConcurrencyCheck, CreditUsage, TokenUsage
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
async def get_concurrency(client: AsyncHttpClient) -> ConcurrencyCheck:
|
|
7
|
-
resp = await client.get("/v2/concurrency-check")
|
|
8
|
-
if resp.status_code >= 400:
|
|
9
|
-
handle_response_error(resp, "get concurrency")
|
|
10
|
-
body = resp.json()
|
|
11
|
-
if not body.get("success"):
|
|
12
|
-
raise Exception(body.get("error", "Unknown error"))
|
|
13
|
-
data = body.get("data", body)
|
|
14
|
-
return ConcurrencyCheck(
|
|
15
|
-
concurrency=data.get("concurrency"),
|
|
16
|
-
max_concurrency=data.get("maxConcurrency", data.get("max_concurrency")),
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
async def get_credit_usage(client: AsyncHttpClient) -> CreditUsage:
|
|
21
|
-
resp = await client.get("/v2/team/credit-usage")
|
|
22
|
-
if resp.status_code >= 400:
|
|
23
|
-
handle_response_error(resp, "get credit usage")
|
|
24
|
-
body = resp.json()
|
|
25
|
-
if not body.get("success"):
|
|
26
|
-
raise Exception(body.get("error", "Unknown error"))
|
|
27
|
-
data = body.get("data", body)
|
|
28
|
-
return CreditUsage(remaining_credits=data.get("remainingCredits", data.get("remaining_credits", 0)))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
async def get_token_usage(client: AsyncHttpClient) -> TokenUsage:
|
|
32
|
-
resp = await client.get("/v2/team/token-usage")
|
|
33
|
-
if resp.status_code >= 400:
|
|
34
|
-
handle_response_error(resp, "get token usage")
|
|
35
|
-
body = resp.json()
|
|
36
|
-
if not body.get("success"):
|
|
37
|
-
raise Exception(body.get("error", "Unknown error"))
|
|
38
|
-
data = body.get("data", body)
|
|
39
|
-
return TokenUsage(
|
|
40
|
-
remaining_tokens=data.get("remainingTokens", 0)
|
|
41
|
-
)
|
|
42
|
-
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
from ..utils import HttpClient, handle_response_error
|
|
2
|
-
from ..types import ConcurrencyCheck, CreditUsage, TokenUsage
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def get_concurrency(client: HttpClient) -> ConcurrencyCheck:
|
|
6
|
-
resp = client.get("/v2/concurrency-check")
|
|
7
|
-
if not resp.ok:
|
|
8
|
-
handle_response_error(resp, "get concurrency")
|
|
9
|
-
body = resp.json()
|
|
10
|
-
if not body.get("success"):
|
|
11
|
-
raise Exception(body.get("error", "Unknown error"))
|
|
12
|
-
data = body.get("data", body)
|
|
13
|
-
return ConcurrencyCheck(
|
|
14
|
-
concurrency=data.get("concurrency"),
|
|
15
|
-
max_concurrency=data.get("maxConcurrency", data.get("max_concurrency")),
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def get_credit_usage(client: HttpClient) -> CreditUsage:
|
|
20
|
-
resp = client.get("/v2/team/credit-usage")
|
|
21
|
-
if not resp.ok:
|
|
22
|
-
handle_response_error(resp, "get credit usage")
|
|
23
|
-
body = resp.json()
|
|
24
|
-
if not body.get("success"):
|
|
25
|
-
raise Exception(body.get("error", "Unknown error"))
|
|
26
|
-
data = body.get("data", body)
|
|
27
|
-
return CreditUsage(remaining_credits=data.get("remainingCredits", data.get("remaining_credits", 0)))
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def get_token_usage(client: HttpClient) -> TokenUsage:
|
|
31
|
-
resp = client.get("/v2/team/token-usage")
|
|
32
|
-
if not resp.ok:
|
|
33
|
-
handle_response_error(resp, "get token usage")
|
|
34
|
-
body = resp.json()
|
|
35
|
-
if not body.get("success"):
|
|
36
|
-
raise Exception(body.get("error", "Unknown error"))
|
|
37
|
-
data = body.get("data", body)
|
|
38
|
-
return TokenUsage(
|
|
39
|
-
remaining_tokens=data.get("remainingTokens", 0)
|
|
40
|
-
)
|
|
41
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_aio_crawl_params.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/aio/test_ensure_async.py
RENAMED
|
File without changes
|
|
File without changes
|
{firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_crawl_params.py
RENAMED
|
File without changes
|
|
File without changes
|
{firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_crawl_validation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{firecrawl-4.1.1 → firecrawl-4.3.0}/firecrawl/__tests__/unit/v2/methods/test_search_validation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|