SDKs

Official clients for Python and TypeScript, covering every endpoint of every API.

Python

pip install scrapecrate
from scrapecrate import ScrapeCrate

client = ScrapeCrate(api_key="YOUR_API_KEY")  # or set SCRAPECRATE_API_KEY

res = client.youtube.transcript(video_id="dQw4w9WgXcQ", lang="en")
print(res.data["text"], res.credits_used, res.credits_remaining)

page = client.maps.places_search(q="coffee in Berlin", limit=20)
print(len(page.data), page.next_cursor)

for ad in client.ads.iterate("ads_search", q="running shoes", country="US"):
    print(ad["page"]["name"], ad.get("body"))

Python 3.9+. Sync client ScrapeCrate and async client AsyncScrapeCrate. Retries 429/5xx with backoff (failed calls are free).

TypeScript / Node.js

npm install scrapecrate
import { ScrapeCrate } from 'scrapecrate';

const client = new ScrapeCrate({ apiKey: process.env.SCRAPECRATE_API_KEY });

const res = await client.trustpilot.companyReviews({ domain: 'booking.com', stars: '1,2', limit: 20 });
console.log(res.data.length, res.creditsUsed, res.nextCursor);

Node 18+, Deno and Bun (uses fetch). Typed errors, ESM and CommonJS builds.

Responses and pagination

Every method returns the response of the API: data (an object for lookups, a list for lists), the cost of the call and your balance (credits_used / creditsUsed, credits_remaining / creditsRemaining) and, for lists, the cursor of the next page (next_cursor / nextCursor). To read a whole list, call iterate() with the endpoint name and its parameters: it follows the cursors for you and yields one item at a time, so you can stop whenever you have enough and pay only for the pages you fetched.

Configuration

Both clients read the key from the SCRAPECRATE_API_KEY environment variable when you do not pass it. A call times out after 90 seconds; 429 and 5xx answers and network errors are retried up to 3 times with exponential backoff, honouring Retry-After (Python: timeout and max_retries; TypeScript: timeoutMs and maxRetries). Retries of failed calls cost nothing, because failed calls are never billed.

Methods

One namespace per API, one method per endpoint. Parameters are the API parameters, with the same names.

EndpointPythonTypeScript
/v1/youtube/transcripts/{video_id}client.youtube.transcript()client.youtube.transcript()
/v1/youtube/transcripts/{video_id}/languagesclient.youtube.transcript_languages()client.youtube.transcriptLanguages()
/v1/youtube/videos/{video_id}client.youtube.video()client.youtube.video()
/v1/youtube/videos/{video_id}/chaptersclient.youtube.video_chapters()client.youtube.videoChapters()
/v1/youtube/videos/{video_id}/commentsclient.youtube.video_comments()client.youtube.videoComments()
/v1/youtube/channels/{channel_id}client.youtube.channel()client.youtube.channel()
/v1/youtube/channels/{channel_id}/videosclient.youtube.channel_videos()client.youtube.channelVideos()
/v1/youtube/searchclient.youtube.search()client.youtube.search()
/v1/maps/places/searchclient.maps.places_search()client.maps.placesSearch()
/v1/maps/places/{place_id}client.maps.place()client.maps.place()
/v1/maps/places/{place_id}/reviewsclient.maps.place_reviews()client.maps.placeReviews()
/v1/maps/places/resolveclient.maps.places_resolve()client.maps.placesResolve()
/v1/trustpilot/companies/searchclient.trustpilot.companies_search()client.trustpilot.companiesSearch()
/v1/trustpilot/companies/{domain}client.trustpilot.company()client.trustpilot.company()
/v1/trustpilot/companies/{domain}/reviewsclient.trustpilot.company_reviews()client.trustpilot.companyReviews()
/v1/trustpilot/categoriesclient.trustpilot.categories()client.trustpilot.categories()
/v1/trustpilot/categories/{category_id}/companiesclient.trustpilot.category_companies()client.trustpilot.categoryCompanies()
/v1/ads/searchclient.ads.ads_search()client.ads.adsSearch()
/v1/ads/{ad_id}client.ads.ad()client.ads.ad()
/v1/ads/pages/searchclient.ads.pages_search()client.ads.pagesSearch()
/v1/ads/pages/{page_id}client.ads.page()client.ads.page()
/v1/ads/pages/{page_id}/adsclient.ads.page_ads()client.ads.pageAds()

Errors

Both SDKs turn the API's error body {"error": {"code", "message", "request_id", "details"}} into a typed error carrying status, code, message, the request id (request_id in Python, requestId in TypeScript), details and retry_after / retryAfter: ValidationError (400), AuthenticationError (401), InsufficientCreditsError (402), PermissionDeniedError (403), NotFoundError (404), RateLimitError (429) and ServiceUnavailableError (5xx), all subclasses of ApiError. Check code to tell errors with the same status apart: a ServiceUnavailableError with code not_available means the API is not launched yet, while source_unavailable is temporary. Every code is listed on the errors page.