NAV Navbar Icon
php javascript shell

Introduction

Data returned by the API

{
    "News": [
        {
            "title": "Nick Leeder appointed as latest head of Google Ireland",
            "description": "Google has announced that Nick Leeder will replace Fionnuala Meehan as the head of its Irish operation starting in April.",
            "url": "",
            "image": "",
            "publishedAt": "2020-03-23T13:58:53Z",
        }
    ]
}

News api is an API to search for News from a variety of sources, including Google News. We also provide top headlines from which you can filter by topic such as world, business, sports...

Description of data returned by the API:

Property Description
News[i].title The title of the article
News[i].description The description of the article
News[i].url The URL to the article
News[i].image The main article image
News[i].publishedAt The publish date of the article

Categories

Category data returned by the API

{
     "Categories": [
         {
             "id": "1",
             "category_name": "english_politics",
             "label_name": "Politics",
             }
     
     {
    "id": "2",
    "category_name": "english_sports",
    "label_name": "Sports",
    }

]
 }
 

You need to pass language code here for getting categories https://newsapi.in/newsapi/category.php?lang='language code here'

For getting english news, You need to pass country code here for getting categories https://newsapi.in/newsapi/category.php?country='country name here'

You can find language code in Language List

Authentication

To authorize, use this code:

<?php
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'https://newsapi.in/newsapi/news.php?key=API-key&category='category_name'); 
$data = curl_exec($ch); 
curl_close($ch); 
curl "https://newsapi.in/newsapi/news.php?key=API-key&category='category_name"
fetch('https://newsapi.in/newsapi/news.php?key=API-key&category='category_name');

Make sure to replace API-Token with your API token.

Authentication is handled by your API token. You must pass your token as GET parameter.
https://newsapi.in/newsapi/news.php?key=API-key&category='category_name'

Search Endpoint

<?php
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'https://newsapi.in/newsapi/news.php?key=API-key&category='category_name''); 
$data = curl_exec($ch); 
curl_close($ch); 
curl "https://newsapi.in/newsapi/news.php?key=API-key&category='category_name'"
fetch("https://newsapi.in/newsapi/news.php?key=API-key&category='category_name'")
    .then(function (response) {
        return response.json();
    })
    .then(function (data) {
        console.log(data);
    });

The above command returns JSON structured like this:

{
    "News": [
        {
            "title": "Nick Leeder appointed as latest head of Google Ireland",
            "description": "Google has announced that Nick Leeder will replace Fionnuala Meehan as the head of its Irish operation starting in April.",
            "url": "",
            "image": "",
            "publishedAt": "2020-03-23T13:58:53Z",
            }
    ]
}

This endpoint allows you to search News from keywords.

Search HTTP Request

Get News HTTP Request

For getting full content news. You need to pass content_type parameter via news api call

Query Parameters

Parameter Default Description
key Must Replace with your api key.Get it from dashboard.
category Any Get category from category api and pass here

Languages

Language Code
Afrikaans afrikaans
Amharic amharic
Arabic arabic
Armenian armenian
Azerbaijani azerbaijani
Basque basque
Belarusian belarusian
Bengali bengali
Bulgarian bulgarian
Catalan catalan
Chinese chinese
Croatian croatian
Czech czech
Danish danish
Dutch dutch
Finnish finnish
French french
German german
Gujarati gujarati
Hebrew hebrew
Hindi hindi
Hungarian hungarian
Indonesian indonesian
Italian italian
Kannada kannada
Khmer khmer
Korean korean
Macedonian macedonian
Malay malay
Malayalam malayalam
Oriya oriya
Persian persian
Punjabi punjabi
Tamil tamil
Telugu telugu
Turkish turkish
Urdu urdu
Vietnamese vietnamese

Errors

The API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
429 Too Many Requests -- You've reached your daily limit.
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.