LogoLogo
Release NotesDataPipelineFAQs
NodeJS
NodeJS
  • Making Requests
    • API Endpoint Method
    • Proxy Port Method
    • SDK Method
    • Async Requests Method
      • How to use
      • Callbacks
      • API Parameters
      • Async Batch Requests
      • Decoding
    • Structured Data Collection Method
      • Amazon Product Page API
      • Amazon Search API
      • Amazon Offers API
      • Amazon Reviews API
      • Ebay Product Page API
      • Ebay Search API
      • Google SERP API
      • Google News API
      • Google Jobs API
      • Google Shopping API
      • Google Maps Search API
      • Redfin Agent Details API
      • Redfin 'For Rent' Listings API
      • Redfin 'For Sale' Listings API
      • Redfin Listing Search API
      • Walmart Search API
      • Walmart Category API
      • Walmart Product API
      • Walmart Reviews API
    • Async Structured Data Collection Method
      • Amazon Product Page API (Async)
      • Amazon Search API (Async)
      • Amazon Offers API (Async)
      • Amazon Reviews API (Async)
      • Ebay Product Page API (Async)
      • Ebay Search API (Async)
      • Google Search API (Async)
      • Google News API (Async)
      • Google Jobs API (Async)
      • Google Shopping API (Async)
      • Google Maps Search API (Async)
      • Redfin Agent Details API (Async)
      • Redfin 'For Rent' Listings API (Async)
      • Redfin 'For Sale' Listings API (Async)
      • Redfin Listing Search API (Async)
      • Walmart Search API (Async)
      • Walmart Category API (Async)
      • Walmart Product API (Async)
      • Walmart Reviews API (Async)
    • Making POST/PUT Requests
    • Customizing Requests
      • Amazon ZIP Code Targeting
      • Cached Results
      • Cost Control
      • Custom Headers
      • Device Type
      • Geotargeting
      • Geotargeting (Premium)
      • Parameters as Headers
      • Premium Residential/Mobile Proxy Pools
      • Rendering Javascript
        • Render Instruction Set
        • Screenshot Capture🆕
      • Sessions
  • Handling and Processing Responses
    • API Status Codes
    • Output Formats
      • JSON Response - Autoparse 📜
      • LLM Output Formats 💻
    • Response Encoding and Content-Type
  • Dashboard & Billing
    • API Key
    • Credit Usage
    • Delete Account
    • Invoice History
    • Billing Email
    • Billing Address
    • VAT Number
    • Payment Method
    • Cancel Subscription
  • Credits and Requests
  • Account Information
  • Documentation Overview
Powered by GitBook

Quick links

  • Homepage
  • Dashboard
  • Pricing
  • Contact Sales

Resources

  • Developer Guides
  • Blog
  • Contact Support
  • Learning Hub
On this page

Was this helpful?

  1. Making Requests
  2. Customizing Requests

Cost Control

ScraperAPI helps you control and manage your costs efficiently. By using the max_cost parameter with your requests, you instruct the API to set a limit on the maximum API credits you'd like to spend per each individual scrape. This helps prevent overspending, ensuring you stay within your individual project's budget.

  • API REQUEST

import request from 'request-promise';
request('http://api.scraperapi.com/?api_key=API_KEY&premium=true&max_cost=5&url=https://example.com/')
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
});
  • ASYNC REQUEST

import axios from 'axios';

(async () => {
  try {
    const { data } = await axios({
      method: 'POST',
      url: 'https://async.scraperapi.com/batchjobs',
      data: {
        apiKey: 'API_KEY',
        url: 'https://example.com/page1',
        apiParams: {
          premium: 'true',
          max_cost: '5'
        }
      }
    });

    console.log(data);
  } catch (error) {
    console.error(error);
  }
})();
  • PROXY MODE - COMING SOON!

If the scrape cost exceeds your limit, a 403 status code will be returned for the request, with the following error message:

"This request would cost more than your max_cost. You can see the cost per request in your response header or in API Playground in the dashboard."

PreviousCached ResultsNextCustom Headers

Last updated 8 months ago

Was this helpful?