Sending Fetch Requests

https://api.usetrove.io/v1/fetch/browser?key=<YOUR_TROVE_KEY>
https://api.usetrove.io/v1/fetch/http?key=<YOUR_TROVE_KEY>

Sending fetch requests is simple and responses will be sent as text/html unless an error occur in which case there will be a JSON response. You can see samples below for Node.js, Python and PHP. All requests are made with the POST method.


Send a request using https

For Node.js there are plenty of third party libraries as well, such as node-fetch or got.

const https = require('https');
const TROVE_KEY = '<YOUR_TROVE_KEY>';
const TROVE_API = `https://api.usetrove.io/v1/fetch/browser?key=${TROVE_KEY}`;
function handleResponse(response) {
response.setEncoding('utf8');
response.on('data', function (data) {
const htmlResponse = data;
console.log(htmlResponse);
});
}
function sendRequest(postBody) {
const url = new URL(TROVE_API);
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
};
const request = https.request(url, requestOptions, handleResponse);
request.write(JSON.stringify(postBody));
request.end();
}
sendRequest({
url: 'https://google.com/search?q=social%20media%20marketing',
});
// <!DOCTYPE html>
// <html itemscope="" itemtype="http://schema.org/SearchResultsPage" lang="en">
// <head>
// <meta
// content="/images/branding/googleg/1x/googleg_standard_color_128dp.png"
// itemprop="image"
// />
// <meta content="origin" name="referrer" />
// <title>social media marketing - Google Search</title>
// <meta
// content="At65Ued/IKGjC1CHbimm0Lp+lkdFLAxYwLJcFtCOYfet7yt3CzeAxdYQzUwWr6pf1Im3ATkD/5XFcTJpyN5HXw8AAABTeyJvcmlnaW4iOiJodHRwczovL3d3dy5nb29nbGUuY29tOjQ0MyIsImZlYXR1cmUiOiJUcnVzdFRva2VucyIsImV4cGlyeSI6MTYwMjUyNzU0MX0="
// http-equiv="origin-trial"
// />
// ...more html