Skip to content

hidimpu/inshorts-api-v2

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“° Inshorts News API v2


This is the v2 for my previous Inshorts News API. You can check out the v1 here.


# So why a new version?

The v2 API comes with better fetching speeds, more accurate and ordered results, and a wider array of categories than the v1 API. The v2 API directly incorporates official Inshorts API underneath that provides all these benefits.


✨ Features

  • πŸš€ Blazing fast
  • πŸ“„ 15 different categories to choose from
  • 🏷️ Support for trending, top and all news along with 15 different news topics/categories.
  • 🚧 Ability to limit the number of results per page.

πŸ—ƒοΈ News Categories

This API has support for all, trending and top news along with 15 different categories. Here is a complete list of all the supported categories.

  1. national
  2. business
  3. politics
  4. sports
  5. technology
  6. startups
  7. entertainment
  8. hatke
  9. education
  10. world
  11. automobile
  12. science
  13. travel
  14. miscellaneous
  15. fashion

You can check all the API endpoints here https://inshortsv2.vercel.app


πŸ” Usage

There are two ways to get news stories :

1. Getting All, Trending or Top news stories :

Base URL : https://inshortsv2.vercel.app/news/

You can use either of these endpoints :

  1. all
  2. top
  3. trending

Make a GETrequest to the Base URL to get the corresponding news in JSON format

https://inshortsv2.vercel.app/news/{type}

Example - https://inshortsv2.vercel.app/news/all

To limit the number of results per page, add /{limit count} at the end of the API url.

Example - https://inshortsv2.vercel.app/news/all/23 this will limit the results to 23 for that page

NOTE : If no limit is provided, default limit is 10 results per page


# Response Format

The response JSON Object looks something like this -

{
  "total": 9,
  "articles": [
    {
      "title": "Sonia, Rahul recall 'bold leadership' of ex-PM PV Narasimha Rao",
      "description": "On the occasion of former PM PV Narasimha Rao's birth centenary, Congress President Sonia Gandhi paid tribute to him and said that India overcame several challenges \"successfully\" due to his \"bold leadership\". Congress leader Rahul Gandhi said that the former PM's remarkable political journey reflected his \"grit and determination\" and his contribution \"continues to shape modern India\".",
      "author": "Kiran Khatri",
      "source_name": "ANI",
      "source_url": "https://www.aninews.in/news/national/general-news/sonia-rahul-gandhi-recall-bold-leadership-achievements-and-contributions-of-pv-narasimha-rao20200724141933/?utm_campaign=fullarticle&utm_medium=referral&utm_source=inshorts",
      "image_url": "https://static.inshorts.com/inshorts/images/v1/variants/jpg/m/2020/07_jul/24_fri/img_1595593537891_958.jpg?",
      "created_at": 1595598762000,
      "inshorts_url": "https://shrts.in/KkNP"
    },
    {
      "title": "My wife was the one who pushed me to resume shoot: Kapil Sharma",
      "description": "On being asked if his wife, Ginni Chatrath, was fine with him resuming the shoot of 'The Kapil Sharma Show', actor-comedian Kapil Sharma said, \"Ginni was the one to push me to resume shoot.\" \"She jokingly said I annoyed her in...last four months,\" he added. Kapil further said he was initially reluctant to resume work but Ginni convinced him. ",
      "author": "Udit Gupta",
      "source_name": "PINKVILLA",
      "source_url": "https://www.pinkvilla.com/tv/news-gossip/exclusive-kapil-sharma-resuming-tkss-shoot-no-live-audience-new-normal-ginni-pushing-him-resume-551378?amp=&utm_campaign=fullarticle&utm_medium=referral&utm_source=inshorts",
      "image_url": "https://static.inshorts.com/inshorts/images/v1/variants/jpg/m/2020/07_jul/24_fri/img_1595591751600_819.jpg?",
      "created_at": 1595598341000,
      "inshorts_url": "https://shrts.in/m42L"
    },
  ]
}

2. Getting news stories by topics/categories:

Base URL : https://inshortsv2.vercel.app/topics/

You can use either of these endpoints :

  1. national
  2. business
  3. politics
  4. sports
  5. technology
  6. startups
  7. entertainment
  8. hatke
  9. education
  10. world
  11. automobile
  12. science
  13. travel
  14. miscellaneous
  15. fashion

Make a GETrequest to the Base URL to get the corresponding news in JSON format

https://inshortsv2.vercel.app/topics/{topic name}

Example - https://inshortsv2.vercel.app/topic/national

To limit the number of results per page, add /{limit count} at the end of the API url.

Example - https://inshortsv2.vercel.app/topic/national/15 this will limit the results to 15 for that page

NOTE : If no limit is provided, default limit is 10 results per page


# Response Format

The response JSON Object looks something like this -

{
  "total": 9,
  "articles": [
    {
      "title": "Sonia, Rahul recall 'bold leadership' of ex-PM PV Narasimha Rao",
      "description": "On the occasion of former PM PV Narasimha Rao's birth centenary, Congress President Sonia Gandhi paid tribute to him and said that India overcame several challenges \"successfully\" due to his \"bold leadership\". Congress leader Rahul Gandhi said that the former PM's remarkable political journey reflected his \"grit and determination\" and his contribution \"continues to shape modern India\".",
      "author": "Kiran Khatri",
      "source_name": "ANI",
      "source_url": "https://www.aninews.in/news/national/general-news/sonia-rahul-gandhi-recall-bold-leadership-achievements-and-contributions-of-pv-narasimha-rao20200724141933/?utm_campaign=fullarticle&utm_medium=referral&utm_source=inshorts",
      "image_url": "https://static.inshorts.com/inshorts/images/v1/variants/jpg/m/2020/07_jul/24_fri/img_1595593537891_958.jpg?",
      "created_at": 1595598762000,
      "inshorts_url": "https://shrts.in/KkNP"
    },
    {
      "title": "My wife was the one who pushed me to resume shoot: Kapil Sharma",
      "description": "On being asked if his wife, Ginni Chatrath, was fine with him resuming the shoot of 'The Kapil Sharma Show', actor-comedian Kapil Sharma said, \"Ginni was the one to push me to resume shoot.\" \"She jokingly said I annoyed her in...last four months,\" he added. Kapil further said he was initially reluctant to resume work but Ginni convinced him. ",
      "author": "Udit Gupta",
      "source_name": "PINKVILLA",
      "source_url": "https://www.pinkvilla.com/tv/news-gossip/exclusive-kapil-sharma-resuming-tkss-shoot-no-live-audience-new-normal-ginni-pushing-him-resume-551378?amp=&utm_campaign=fullarticle&utm_medium=referral&utm_source=inshorts",
      "image_url": "https://static.inshorts.com/inshorts/images/v1/variants/jpg/m/2020/07_jul/24_fri/img_1595591751600_819.jpg?",
      "created_at": 1595598341000,
      "inshorts_url": "https://shrts.in/m42L"
    },
  ]
}

πŸ‘· Setup

This API is created as a collection of multiple different serverless functions that are specifically made to be hosted on Vercel. You can modify the code to make it work with Nodejs based server or as AWS Lambda functions

Run locally

  • You will need Vercel CLI to run this locally.
npm i -g vercel
$ git clone https://github.com/sumitkolhe/inshorts-api-v2

$ cd inshorts-api-v2
  • Install the dependencies
npm install
  • Run the API
vercel dev

NOTE: You will need to deploy the project to Vercel first even if you want to run it locally using vercel dev. The Vercel CLI wil guide you through the process.


πŸš€ Deploy to Vercel

You can directly deploy this repo to your Vercel account by clicking the button below.

Deploy with Vercel

About

πŸ“° Inshorts News API v2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%