The following parameters help you control the Chrome browser setup of your API request.
render_jsboolean
default=true
Note: API requests with Javascript enabled will cost 5 API credits.
By default API requests will use real Chrome browsers that can handle Javascript web pages. You can set render_js to false. When doing this a simple HTTP request is made without Javascript support.
wait_for_msnumber, between 0 and 35000
default=750
You can specify how long the Chrome browser should wait in milliseconds after the page has finished loading. This is useful if some elements take time before they are visible on the page for example.
wait_for_selectorstring
default=""
The browser will wait on the given CSS selector to appear on the page. For example if you want to wait on a button appearing: wait_for_selector="button.my-button"
domcontentloaded wait until the html DOM is loaded and ready
load wait until the html DOM is loaded and ready and all images and frames have finished loading
networkidle0 wait until there are no active network requests
networkidle2 wait until there are at most 2 active network requests
block_adsboolean
default=false
If set to true the browser will bock advertisements. This will speed up API requests.
block_resourcesboolean
default=true
By default our API blocks images, videos, fonts and CSS stylsheets. Set block_resources to false to disable this blocking. This will slow down requests significantly.
browser_widthnumber, 1 to 3840
default=1920
Set the Chrome browser viewport width
browser_heightnumber, 1 to 2160
default=1080
Set the Chrome browser viewport height
device"desktop" | "mobile"
default="desktop"
When setting this to mobile the Chrome browser will act like it's a mobile browser. This is useful to scrape the mobile version of web pages.
Note: this works best in combination with setting reasonable browser_width and browser_height values.
Browser example
The following code navigates to https://isjsenabled.com and waits for the CSS selector div.enabled > h1 to appear. Note that we have url encoded the wait_for_selector parameter.
The following parameters help you to control the proxy setup of your API request.
proxy_type"normal" | "premium"
default="normal"
Note: API requests with premium proxies will cost 25 API credits.
By default API requests will use our normal proxies. Some hard to scrape websites are able to detect our normal proxies though. In that case you can set the proxy_type to premium. This will use our premium residential proxies which are impossible to detect.
country_code"us" | "ca" | "nl" | ...
default=null
Note: Only available when proxy_type is premium
Select the location of the proxies. For example, if you only want proxies from Canada you can set country_code=ca . We use the ISO 3166-1 country code format.
Availble country codes
USA
us
Canada
ca
Great Britain
gb
Germany
de
France
fr
Spain
es
Italy
it
Sweden
se
Greece
gr
Portugal
pt
Netherlands
nl
Belgium
be
Russia
ru
Ukraine
ua
Poland
pl
Israel
il
Turkey
tr
Australia
au
Malaysia
my
Thailand
th
South Korea
kr
Japan
jp
Philippines
ph
Singapore
sg
China
cn
Hong Kong
hk
Taiwan
tw
India
in
Pakistan
pk
Iran
ir
Indonesia
id
Azerbaijan
az
Kazakhstan
kz
UAE
ae
Mexico
mx
Brazil
br
Argentina
ar
Chile
cl
Peru
pe
Ecuador
ec
Colombia
co
South Africa
za
Egypt
eg
Angola
ao
Cameroon
cm
Chad
td
Benin
bj
Ethiopia
et
Djibouti
dj
Gambia
gm
Ghana
gh
Kenya
ke
Liberia
lr
Madagascar
mg
Mali
ml
Mauritania
mr
Mauritius
mu
Morocco
ma
Mozambique
mz
Nigeria
ng
Senegal
sn
Seychelles
sc
Zimbabwe
zw
South Sudan
ss
Sudan
sd
Togo
tg
Tunisia
tn
Uganda
ug
Zambia
zm
Afghanistan
af
Bahrain
bh
Bangladesh
bd
Bhutan
bt
Myanmar
mm
Cambodia
kh
Iraq
iq
Jordan
jo
Lebanon
lb
Maldives
mv
Mongolia
mn
Oman
om
Qatar
qa
Saudi Arabia
sa
Turkmenistan
tm
Uzbekistan
uz
Yemen
ye
Albania
al
Andorra
ad
Austria
at
Armenia
am
Bosnia and Herzegovina
ba
Bulgaria
bg
Belarus
by
Croatia
hr
Cyprus
cy
Czech Republic
cz
Denmark
dk
Estonia
ee
Finland
fi
Georgia
ge
Hungary
hu
Iceland
is
Ireland
ie
Latvia
lv
Liechtenstein
li
Lithuania
lt
Luxembourg
lu
Monaco
mc
Moldova
md
Montenegro
me
Norway
no
Romania
ro
Serbia
rs
Slovakia
sk
Slovenia
si
Switzerland
ch
Macedonia
mk
Bahamas
bs
Belize
bz
British Virgin Islands
vg
Costa Rica
cr
Cuba
cu
Dominica
dm
Haiti
ht
Honduras
hn
Jamaica
jm
Aruba
aw
Panama
pa
Puerto Rico
pr
Trinidad and Tobago
tt
Fiji
fj
New Zealand
nz
Bolivia
bo
Paraguay
py
Uruguay
uy
Côte d'Ivoire
ci
Syria
sy
proxy_session_idnumber, 1 to 9999
default=null
If you want to keep the same IP addresses for multiple scrape requests you can supply a proxy_session_id value. This must be a number between 0 and 9999.
Proxy example
The following code uses a premium proxy from Belgium to scrape a web page. It sets the proxy_session_id parameter, so that any next requests with the same proxy_session_id will have the same IP.
To forward headers you can add your own headers to the request with the SB- prefix. For example, to sent a custom Accept-Language header, you can add a SB-Accept-Language: klingon,elvish header to your API request.
You can send POST and PUT requests to the url you want to scrape.
method"GET" | "POST" | "PUT"
default="GET"
Change this value if you want to send a POST or PUT request. For example when you want to scrape search results from a POST search result page.
bodyany
default=null
Only applicable if you send a POST or PUT request. This can be JSON data, or x-www-form-urlencoded or anything else you want.
Note: make sure you set the right SB-Content-Type header. This makes sure our API forwards your post data correctly.
Post request example
Here we send a JSONPOST request. Note that we have url encoded the body parameter containing our JSON data. And, we have set the SB-Content-Type: application/json header. This way the receiving web page understands that we try to send JSON data.
Add cookies to the request, use the key=value; notation. For example to set 2 cookie values: is_new_customer=1; language=nl;
return_original_status_codeboolean
default=false
Normally when an API request fails our API returns an 500 status code. If you want to original status code to be returned set this to false
timeoutnumber 1,90000
default=30000
The amount of time a request can take before it's considered as timed out and our API will try again. Note that our API will try to get a webpage multiple times if it fails, so the total time of your request can be greater than the value set here.
API response
If succesful the API will respond with the original page HTML. It forwards the Content-Type header. This means that if the scraped web page contains html text/html content is returned. But, for example, if the scraped web page contains json application/json content is returned. This also supports images and binary data.
Validation errors
If you supply incorrect parameters you can get a JSON validation error. This will always be a response status code between 400 and 499
An example validation error response looks like this:
{"errors":{"api_key":["Invalid api key"]}}
Scrape errors
In some cases our API will be unable to retrieve the scraped web page data. In that case a 500 response code is returned, together with the error details as JSON.
{"browser_error":"server responded with a 402","browser_status_code":402,"browser_response_body":"<!doctype html><body>...</body></html>"}
Response headers
Our API sends 2 response headers with each successful request.
SB-Cost - The credit cost of the API request
SB-Resolved-Url - The final URL of the scraped web page after all redirects have finished
Credit cost
Only successful requests will cost credits. A request is successful if one of the following status codes is returned: 2xx, 404, 410
Furthermore, depending on what API credits you supply a request can cost between 1 and 30 credits.