Google News API (Async)

This endpoint will retrieve news data from a Google news result page and transform it into usable JSON.

Single Query Request:

<?php

$curl = curl_init();

$data = json_encode(array(
    'apiKey' => 'APIKEY',
    'query' => 'QUERY',
    'tld' => 'TLD',
    'uule' => 'UULE',
    'num' => 'NUM',
    'hl' => 'HOSTLANGUAGE',
    'gl' => 'GUESTLANGUAGE',
    'ie' => 'QUERYENCODING',
    'oe' => 'RESULTENCODING',
    'start' => 'START',
    'callback' => array(
        'type' => 'webhook',
        'url' => 'CALLBACK'
    )
));

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://async.scraperapi.com/structured/google/news',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

if (curl_errno($curl)) {
    echo 'Error:' . curl_error($curl);
} else {
    echo $response;
}

curl_close($curl);

?>

<?php

$curl = curl_init();

$data = json_encode(array(
    'apiKey' => 'APIKEY',
    'queries' => array('QUERY1', 'QUERY2', 'QUERY3'),
    'tld' => 'TLD',
    'uule' => 'UULE',
    'num' => 'NUM',
    'hl' => 'HOSTLANGUAGE',
    'gl' => 'GUESTLANGUAGE',
    'ie' => 'QUERYENCODING',
    'oe' => 'RESULTENCODING',
    'start' => 'START',
    'callback' => array(
        'type' => 'webhook',
        'url' => 'CALLBACK'
    )
));

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://async.scraperapi.com/structured/google/news',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $data,
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

if (curl_errno($curl)) {
    echo 'Error:' . curl_error($curl);
} else {
    echo $response;
}

curl_close($curl);

?>

Multiple Parameters can be used with this method:

REQUIRED

APIKEY

User account’s normal API key.

QUERY

Google Search Query.

Sample Response

Single Query Request:

Multiple Query Request:

After the job(s) finish, you will find the result under the response key in the response JSON object. The structure is the same as in the corresponding SYNC data endpoint.

Last updated

Was this helpful?