# Google News API

Here is the list of default parameters for this API : \ <br>

<table><thead><tr><th align="center">Parameters</th><th width="337.95744680851067" align="center">Description</th></tr></thead><tbody><tr><td align="center">api_key<br><br><mark style="color:red;">required</mark></td><td align="center">This is your API key.</td></tr><tr><td align="center">q<br><br><mark style="color:red;">required</mark></td><td align="center"><p>Type: <code>String</code></p><p><br>Google Search Query</p></td></tr><tr><td align="center">num</td><td align="center">Type: <code>Number(Integer)</code><br><br>Number of results per page.</td></tr><tr><td align="center">gl</td><td align="center"><p>Type: <code>String</code><br></p><p>Default: <code>"us"</code><br> Name of the country. The name should be in <a href="https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes">ISO 3166 Alpha-2</a> format.</p></td></tr><tr><td align="center">hl</td><td align="center">Type: <code>String</code><br><br>Default: <code>"en_us"</code><br><br>The language of the requested results.</td></tr><tr><td align="center">page</td><td align="center">Type: <code>Number(Integer)</code><br><code>[0,10,20...]</code><br><br>Default: <code>0</code><br>(Enter 10 for 2nd-page results, 20 for 3rd, etc .)<br><br>The page number to get targeted search results.<br><mark style="color:red;">Note: Don't use with num parameter.</mark></td></tr><tr><td align="center">lr</td><td align="center">Type: <code>String</code><br><br>Limit the search to one or multiple languages.<br>It is used as <mark style="color:red;"><code>lang_{language code}</code></mark><em>.</em> For example <em>- "</em>lang_us".</td></tr><tr><td align="center">uule</td><td align="center">Type: <code>String</code><br><br>Used to encode a place an exact location(with latitude and longitude) into a value used in a cookie, an URL, or an HTTP header.</td></tr><tr><td align="center">duration</td><td align="center"><p>Type: <code>String</code><br><br>Use this as "<code>d/w/m/mn/y"</code><br>where n is from <code>0-10</code>.</p><p><mark style="color:red;"><code>d</code></mark> - the previous 24 hours,  <mark style="color:red;"><code>w</code></mark> - the previous seven days, <mark style="color:red;"><code>m</code></mark> - the previous month, <mark style="color:red;"><code>mn</code></mark> - the previous n number of months, <mark style="color:red;"><code>y</code></mark> - past year</p><p><br>The <code>duration</code> parameter requests search results from a specified time period (quick date range).</p></td></tr><tr><td align="center">nfpr</td><td align="center"><p>Type: <code>Boolean</code></p><p><br>Default: <code>0</code><br>It excludes the result from an auto-corrected query that is spelled wrong. It can be set to <mark style="color:red;"><code>1</code></mark> to exclude these results or <mark style="color:red;"><code>0</code></mark> to include them.</p></td></tr><tr><td align="center">tbs</td><td align="center">Type: <code>String</code><br><br>to be searched - An advanced parameter to filter search results. </td></tr><tr><td align="center">safe</td><td align="center"><p>Type: String<br><code>[active/off]</code><br></p><p>Default: <code>off</code><br>To filter the adult content set <code>safe</code> to <mark style="color:red;"><code>active</code></mark> or to disable it set it <mark style="color:red;"><code>off</code></mark>.</p></td></tr><tr><td align="center">html</td><td align="center">Type: <code>Boolean</code><br><br>Default: <code>false</code><br>To render response as raw HTML.</td></tr></tbody></table>

### API Example:

{% tabs %}
{% tab title="cURL" %}

```json
cURL "https://api.serpdog.io/news?&api_key=APIKEY&q=football&gl=us"
```

{% endtab %}

{% tab title="Node JS" %}

```javascript
const axios = require('axios');

axios.get('https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us')
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
payload = {'api_key': 'APIKEY', 'q':'football' , 'gl':'us'}
resp = requests.get('https://api.serpdog.io/news', params=payload)
print (resp.text)
```

{% endtab %}

{% tab title="Java" %}

```java
try {
 String url = "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us";
 URL urlForGetRequest = new URL(url);
 String readLine = null;
 HttpURLConnection conection = (HttpURLConnection) urlForGetRequest.openConnection();
 conection.setRequestMethod("GET");
 int responseCode = conection.getResponseCode();
 if (responseCode == HttpURLConnection.HTTP_OK) {
 BufferedReader in = new BufferedReader(new InputStreamReader(conection.getInputStream()));
 StringBuffer response = new StringBuffer();
 while ((readLine = in.readLine()) != null) {
 response.append(readLine);
 }
 in.close();
 System.out.println(response.toString());
} else {
 throw new Exception("Error in API Call");
 }
} catch (Exception ex) {
 ex.printStackTrace();
}
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'json'
params = {
 :api_key => "APIKEY",
 :q => "football",
 :gl => "us"
}
uri = URI('https://api.serpdog.io/news')
uri.query = URI.encode_www_form(params)
website_content = Net::HTTP.get(uri)
print(website_content)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = "https://api.serpdog.io/news?api_key=APIKEY&q=footbal&gl=us";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
```

{% endtab %}
{% endtabs %}

```json
{
  "meta": {
    "api_key": "APIKEY",
    "q": "football",
    "gl": "us"
  },
  "subArticles": [
    {
      "name": "News about college football",
      "news_results": [
        {
          "title": "Staff Picks: Kendall Milton, Cameron Ward among college football breakout \nstars in 2022 season",
          "source": "CBS Sports",
          "image": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
          "date": "2 days ago",
          "url": "https://www.cbssports.com/college-football/news/staff-picks-kendall-milton-cameron-ward-among-college-football-breakout-stars-in-2022-season/"
        },
        {
          "title": "College Football World Reacts To Peyton Manning's Recruiting Admission",
          "source": "The Spun",
          "image": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
          "date": "18 mins ago",
          "url": "https://thespun.com/college-football/college-football-world-reacts-to-peyton-mannings-recruiting-admission"
        },
        {
          "title": "For Air Force football, Troy Calhoun believes every year requires resetting \nexpectations",
          "source": "The Athletic",
          "image": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
          "date": "7 hours ago",
          "url": "https://theathletic.com/3376293/2022/06/26/air-force-football-preview-troy-calhoun/"
        }
      ]
    },
    {
      "name": "News about Fantasy football",
      "news_results": [
        {
          "title": "Fantasy football 2022: A deeper dive on Saquon Barkley",
          "source": "The Athletic",
          "image": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
          "date": "7 hours ago",
          "url": "https://theathletic.com/3365167/2022/06/26/fantasy-football-2022-a-deeper-dive-on-saquon-barkley/"
        },
        {
          "title": "Fantasy football mock draft - Four WRs go in first round in 12-team PPR",
          "source": "ESPN",
          "image": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
          "date": "3 days ago",
          "url": "https://www.espn.com/fantasy/football/story/_/id/34138347/fantasy-football-mock-draft-four-wrs-go-first-round-12-team-ppr"
        },
        {
          "title": "Fantasy football sleepers roundtable: Allen Lazard, Chris Olave and 8 more \nfavorites",
          "source": "The Athletic",
          "image": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
          "date": "2 hours ago",
          "url": "https://theathletic.com/3367894/2022/06/26/fantasy-football-sleepers-2022/"
        }
      ]
    }
  ],
  "news_results": [
    {
      "title": "Martin Bengtsson: football’s Swedish wonderkid whose dream died at Inter",
      "snippet": "If Martin Bengtsson feels stressed he kicks a football around on his own and, almost immediately, the tension begins to ebb away.",
      "source": "The Guardian",
      "imgSrc": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
      "lastUpdated": "3 hours ago",
      "rank": "1"
    },
    {
      "title": "Ten years that changed the face of women’s football",
      "snippet": "It was a landmark moment for women's football. Under the arch of Wembley stadium, to the soundtrack of Beyonc's feminist anthem Run the...",
      "source": "The Guardian",
      "imgSrc": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
      "lastUpdated": "4 hours ago",
      "rank": "2"
    },
    {
      "title": "Milan choose between Asensio and Ziyech - Football Italia",
      "snippet": "Milan must choose between Hakim Ziyech of Chelsea and Real Madrid's Marco Asensio to reinforce the front line this summer, shifting the priority from \na.",
      "source": "Football Italia",
      "imgSrc": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
      "lastUpdated": "2 hours ago",
      "rank": "3"
    },
    {
      "title": "Gabriel Jesus: Arsenal agree terms with Manchester City forward on five-year deal",
      "snippet": "Arsenal have agreed personal terms with Manchester City forward Gabriel Jesus on a five-year deal ahead of a proposed 45 million move.",
      "source": "The Athletic",
      "imgSrc": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
      "lastUpdated": "47 mins ago",
      "rank": "4"
    },
    {
      "title": "Reports Di Maria has said yes to Juventus - Football Italia",
      "snippet": "Multiple sources claim Juventus have finally reached a breakthrough for Angel Di Maria and are finalising the details of his contract.",
      "source": "Football Italia",
      "imgSrc": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
      "lastUpdated": "3 hours ago",
      "rank": "5"
    },
    {
      "title": "Tottenham news and transfers LIVE: £42m Gvardiol enquiry, Conte eyes Calhanoglu, Jesus confirmed",
      "snippet": "It has already been a busy transfer window for Tottenham Hotspur Football Club. Unlike Spurs teams of the past, business has been done early...",
      "source": "Football.London",
      "imgSrc": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
      "lastUpdated": "3 hours ago",
      "rank": "6"
    },
    {
      "title": "Brazil's 1982 World Cup team are feted as heroes but Zico claims Italy defeat scarred the game",
      "snippet": "EXCLUSIVE INTERVIEW BY OLIVER HOLT: Next week, it will be 40 years since the Brazil of Zico, Socrates, Eder, Falcao and Junior lost that...",
      "source": "Daily Mail",
      "imgSrc": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
      "lastUpdated": "21 hours ago",
      "rank": "7"
    },
    {
      "title": "Real Madrid sign Deportivo talent to play for Castilla",
      "snippet": "Real Madrid have completed the signing of Noel Lopez from Deportivo La Coruna. The 19 year old will play in the Real Madrid Castilla team in...",
      "source": "Football Espana",
      "imgSrc": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
      "lastUpdated": "8 hours ago",
      "rank": "8"
    }
  ],
  "pagination": {
    "current": "1",
    "next": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=10&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8NMDegQIARBK",
    "page_no": {
      "2": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=10&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8tMDegQIARA4",
      "3": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=20&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8tMDegQIARA6",
      "4": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=30&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8tMDegQIARA8",
      "5": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=40&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8tMDegQIARA-",
      "6": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=50&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8tMDegQIARBA",
      "7": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=60&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8tMDegQIARBC",
      "8": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=70&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8tMDegQIARBE",
      "9": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=80&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8tMDegQIARBG",
      "10": "https://www.google.com/search?q=football&gl=us&tbm=nws&ei=RK24YtfoNIur5NoPisGm4AQ&start=90&sa=N&ved=2ahUKEwjXmoCP58v4AhWLFVkFHYqgCUwQ8tMDegQIARBI"
    }
  },
  "serpdog_pagination": {
    "current": "1",
    "page_no": {
      "2": "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us&start=10",
      "3": "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us&start=20",
      "4": "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us&start=30",
      "5": "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us&start=40",
      "6": "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us&start=50",
      "7": "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us&start=60",
      "8": "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us&start=70",
      "9": "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us&start=80",
      "10": "https://api.serpdog.io/news?api_key=APIKEY&q=football&gl=us&start=90"
    }
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.serpdog.io/google-news-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
