Appearance
Render from a protected URL
Authentication might be needed in order to access a HTML. Here's how to login using different authentication methods. You can use Cookies, Basic access authentication or your own custom headers.
Using custom headers
js
const request = require('request');
const options = {
method: 'POST',
url: 'https://api.doppio.sh/v1/render/pdf/direct',
headers: {
'Authorization': 'Bearer <YOUR API KEY>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
page: {
pdf: {
printBackground: true
},
goto: {
url: 'https://www.this-is-a-protected-url.com'
},
setExtraHTTPHeaders: {
'Authorization': '<YOUR OWN TOKEN>',
'x-something-very-custom': 'a secret token'
}
}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Using Cookies
js
const request = require('request');
const options = {
method: 'POST',
url: 'https://api.doppio.sh/v1/render/pdf/direct',
headers: {
'Authorization': 'Bearer <YOUR API KEY>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
page: {
pdf: {
printBackground: true
},
goto: {
url: 'https://www.this-is-a-protected-url.com'
},
setCookies: [
{
name: 'cookie1',
value: 'value1',
},
{
name: 'cookie2',
value: 'value2',
}
]
}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Using basic HTTPs Authentication
js
const request = require('request');
const options = {
method: 'POST',
url: 'https://api.doppio.sh/v1/render/pdf/direct',
headers: {
'Authorization': 'Bearer <YOUR API KEY>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
page: {
pdf: {
printBackground: true
},
goto: {
url: 'https://www.this-is-a-protected-url.com'
},
authenticate: {
username: '<username>',
password: '<password>',
},
}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Using LocalStorage
js
const request = require('request');
const options = {
method: 'POST',
url: 'https://api.doppio.sh/v1/render/pdf/direct',
headers: {
'Authorization': 'Bearer <YOUR API KEY>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
page: {
pdf: {
printBackground: true
},
goto: {
url: 'https://www.this-is-a-protected-url.com'
},
setLocalStorageItems: [{
key: 'TOKEN',
value: 'the secret token value you need to set',
}],
}
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});