crawlbase文档
登录

概览

Account API 返回您 Crawlbase 产品的月度使用统计数据。可用于监控消耗、构建内部仪表板,或在您接近额度上限时发出警报。

此 API 仍在积极维护中。它在导航中被归入「旧版」一栏,仅仅因为它是较早的端点形式,目前没有替代方案的计划。

端点:https://api.crawlbase.com/account

速率限制:每 5 分钟 1 次请求

此端点在服务器端聚合了大量数据。请缓存响应,无需更频繁地调用。

快速开始

curl 'https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawling-api'
import requests

res = requests.get('https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawling-api')
print(res.json())
const res = await fetch('https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawling-api');
console.log(await res.json());
require 'net/http'

puts Net::HTTP.get(URI('https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawling-api'))

参数

token
string必填
您的 Crawlbase token。
product
string必填
要获取使用情况的产品。可选值之一:crawling-api、crawler、smartproxy、scraper-api、leads-api、screenshot-api。
previous_month
booleanfalse
当为 true 时,会在当月数据之外同时返回上月统计数据,便于趋势对比。

响应字段

totalSuccess
本月成功请求总数。
totalFailed
本月失败请求总数。
totalDue
本月成功请求的应付金额总计(美元)。
remainingCredits
本月剩余可用额度。仅针对订阅类产品返回。
domainStats
按域名分组的明细数组:domain、totalRequests、success、failure、successRate。

按产品示例

# Crawling API
curl "https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawling-api"

# Enterprise Crawler
curl "https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawler"

# Smart AI Proxy
curl "https://api.crawlbase.com/account?token=YOUR_TOKEN&product=smartproxy"

# Scraper API (legacy)
curl "https://api.crawlbase.com/account?token=YOUR_TOKEN&product=scraper-api"

# Leads API (legacy)
curl "https://api.crawlbase.com/account?token=YOUR_TOKEN&product=leads-api"

# Screenshots API (legacy)
curl "https://api.crawlbase.com/account?token=YOUR_TOKEN&product=screenshot-api"

# With previous month for trend comparison
curl "https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawling-api&previous_month=true"
import requests

products = ['crawling-api', 'crawler', 'smartproxy', 'scraper-api', 'leads-api', 'screenshot-api']
for product in products:
    res = requests.get(
        'https://api.crawlbase.com/account',
        params={'token': 'YOUR_TOKEN', 'product': product},
    )
    print(product, res.json())

# With previous month for trend comparison
res = requests.get('https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawling-api&previous_month=true')
print(res.json())
const products = ['crawling-api', 'crawler', 'smartproxy', 'scraper-api', 'leads-api', 'screenshot-api'];
for (const product of products) {
  const res = await fetch(`https://api.crawlbase.com/account?token=YOUR_TOKEN&product=${product}`);
  console.log(product, await res.json());
}

// With previous month for trend comparison
const res = await fetch('https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawling-api&previous_month=true');
console.log(await res.json());
require 'net/http'

%w[crawling-api crawler smartproxy scraper-api leads-api screenshot-api].each do |product|
  uri = URI('https://api.crawlbase.com/account')
  uri.query = URI.encode_www_form(token: 'YOUR_TOKEN', product: product)
  puts product, Net::HTTP.get(uri)
end

# With previous month for trend comparison
puts Net::HTTP.get(URI('https://api.crawlbase.com/account?token=YOUR_TOKEN&product=crawling-api&previous_month=true'))