Skip to content

reemhd/articles-api

Repository files navigation

News API

About The Project

This News API provides a REST API that enables users to search for and retrieve information on topics, articles, users, and comments from a database.

It is hosted on Render and can be viewed here: NEWS API Note: The API is hosted on a free-tier plan, which may result in longer initial load times as the server spins up

Prerequisites

Installation

  1. Clone this repository
git clone https://github.com/reemhd/News-API.git
  1. Install the dependencies:
npm install
npm install pg
npm install dotenv
npm install express
  1. To connect the two databases, you need to create two files that allow access to environment variables. These files should contain the following lines:
  • .env.test --> PGDATABASE=nc_news_test
  • .env.development --> PGDATABASE=nc_news
  1. Seed Databases:
npm run setup-dbs
npm run seed
npm run seed-prod
  1. To run tests you will need development dependencies installed:
npm install supertest -D
npm install jest -D
npm install jest-sorted -D
npm install pg-format -D
  1. To run tests:
npm test

API Endpoints

GET /api

Responds with all the available endpoints

GET /api/topics

Get all the topics

POST /api/topics

Post topics

GET /api/articles

Returns all the articles

GET /api/articles/:article_id

Returns a specific article

POST /api/articles/:article_id

Post a specific article

PATCH /api/articles/:article_id

Update a specific article's votes

DELETE /api/articles/:article_id

Deletes a specific article

GET /api/articles/:article_id/comments

Gets all the comments for the specific article

POST /api/articles/:article_id/comments

Post a comment for a specific article

DELETE /api/comments/:comment_id

Deletes a comment

PATCH /api/comments/:comment_id

Updates a comment's votes

GET /api/users

Returns all users

GET /api/users/:username

Returns a specific user

Hosting

Database was set up on ElephantSQL

Hosted on Render

About

REST API to search for and retrieve news on topics add comments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 21

Languages