To get a local copy up and running, follow these simple steps.
This is a list of things you need to have prior to installing the project.
- Node.js
- npm
- git clone
https://github.com/git-dru/API-GNEWS.git
- Navigate into the project directory:
cd API-GNEWS
- Install the dependencies:
npm install
You will need a GNews API key to make requests. You can obtain an API key by signing up at https://gnews.io/docs/v4#introduction.
Once you have the API key, create a .env file in the root directory of the project and add your GNews API key like so:
GNEWS_API_KEY=<your_gnews_api_key>
Replace <your_gnews_api_key> with the actual key.
Start the server:
node index.js
Fetch N news articles:
GET /api/article?count=N
Search articles by keyword:
GET /api/article/search?search=SEARCH
Search articles by title:
GET /api/article/title?title=TITLE
Search articles by author:
GET /api/article/author?author=AUTHOR_NAME
All endpoints support caching, so repeated requests for the same data will not trigger additional calls to the GNews API.
- Node.js
- Express.js
- Axios
- node-cache