UNPKG

scraperapi-sdk

Version:
56 lines (55 loc) 2.83 kB
/// <reference types="node" /> import { OutgoingHttpHeaders } from 'http'; import AccountInfo from './model/AccountInfo'; import APIOptions from './model/APIOptions'; import APIResponse from './model/APIResponse'; /** * A backward compatible ScraperAPI client that provides a few shorthand methods to scrape websites easily. */ export default class ScraperAPIClient { private readonly apiKey; constructor(apiKey: string); /** * Function to retrieve account information. * * @returns {{ * "burst": number; // The number of burst (frequent) requests currently in flight * "concurrencyLimit": number; // The maximum number of concurrent requests allowed * "concurrentRequests": number; // The number of concurrent requests currently in flight * "failedRequestCount": number; // The number of failed requests in the current billing cycle * "requestCount": number; // The total number of requests in the current billing cycle * "requestLimit": number; // The maximum number of requests allowed in the current billing cycle * "subscriptionDate": Date; // The start date of the current billing cycle * }} */ account(): Promise<AccountInfo>; /** * Shorthand function to send a GET request to the API and fetch the provided URL. * * @param url The target URL to fetch though the API, e.g. https://example.com * @param options The API options to use for this request (e.g. render, country_code, etc.) * @param headers The headers to be passed to the API (optional) * @returns APIResponse */ get(url: string, options?: APIOptions, headers?: OutgoingHttpHeaders): Promise<APIResponse>; /** * Shorthand function to send a POST request to the API and fetch the provided URL. * * @param url The target URL to fetch though the API, e.g. https://example.com * @param options The API options to use for this request (e.g. render, country_code, etc.) * @param headers The headers to be passed to the API (optional) * @param body The body to be passed to the API (optional) * @returns APIResponse */ post(url: string, options?: APIOptions, headers?: OutgoingHttpHeaders, body?: string): Promise<APIResponse>; /** * Shorthand function to send a PUT request to the API and fetch the provided URL. * * @param url The target URL to fetch though the API, e.g. https://example.com * @param options The API options to use for this request (e.g. render, country_code, etc.) * @param headers The headers to be passed to the API (optional) * @param body The body to be passed to the API (optional) * @returns APIResponse */ put(url: string, options?: APIOptions, headers?: OutgoingHttpHeaders, body?: string): Promise<APIResponse>; }