Skip to main content
Open In ColabOpen on GitHub

Scrapingbee CheckUsageTool

This tool allows you to keep track of your credits and concurrency usage while you are scraping the web.

Overviewโ€‹

Integration detailsโ€‹

ClassPackageSerializableJS supportPackage latest
CheckUsageToollangchain-scrapingbeeโœ…โŒPyPI - Version

Setupโ€‹

pip install -U langchain-scrapingbee

Credentialsโ€‹

You should configure credentials by setting the following environment variables:

  • SCRAPINGBEE_API_KEY
import getpass
import os

# if not os.environ.get("SCRAPINGBEE_API_KEY"):
# os.environ["SCRAPINGBEE_API_KEY"] = getpass.getpass("SCRAPINGBEE API key:\n")

Instantiationโ€‹

The CheckUsageTool only require the API Key during instantiation. If not set up in environment vairable, you can provide it directly here.

Here we show how to instantiate an instance of the CheckUsageTool:

from langchain_scrapingbee import CheckUsageTool

usage_tool = CheckUsageTool(api_key=os.environ.get("SCRAPINGBEE_API_KEY"))

Invocationโ€‹

This tool doesn't require any arguments. Invoking this tool will check your ScrapingBee API usage data and returns the following information:

  • max_api_credit
  • used_api_credit
  • max_concurrency
  • current_concurrency
  • renewal_subscription_date
usage_tool.invoke({})

Use within an agentโ€‹

import os
from langchain_scrapingbee import CheckUsageTool
from langchain_google_genai import ChatGoogleGenerativeAI
from langgraph.prebuilt import create_react_agent

if not os.environ.get("GOOGLE_API_KEY") or not os.environ.get("SCRAPINGBEE_API_KEY"):
raise ValueError(
"Google and ScrapingBee API keys must be set in environment variables."
)

llm = ChatGoogleGenerativeAI(temperature=0, model="gemini-2.5-flash")
scrapingbee_api_key = os.environ.get("SCRAPINGBEE_API_KEY")

usage_tool = CheckUsageTool(api_key=os.environ.get("SCRAPINGBEE_API_KEY"))

agent = create_react_agent(llm, [usage_tool])

user_input = "How many api credits do I have available in my account?"

# Stream the agent's output step-by-step
for step in agent.stream(
{"messages": user_input},
stream_mode="values",
):
step["messages"][-1].pretty_print()
API Reference:create_react_agent

API referenceโ€‹

For more details on our usage endpoint, please check out this link.