Northcoders News API is a backend service built to provide data programmatically, mimicking a real-world application like Reddit. The API is designed to interact with a PostgreSQL database using node-postgres and allows for various operations related to articles, comments, users, and topics.
Access the hosted version of the NC-News API at: NC-NEWS
The purpose of this project is to create an API that can be accessed programmatically for managing and retrieving data related to news articles, users, comments, and topics. This project shows how to build and structure a backend service similar to those used in real-world applications.
Ensure you have the following installed on your machine:
Node.js (https://nodejs.org/) (version 14.17.0 or higher)
PostgreSQL (https://www.postgresql.org/) (version 12 or higher)
To run the NC-News API server locally or deploy it to a production environment, follow the steps below.
git clone https://github.com/filosoho/nc-news.git
cd your-repo-name
npm install
As .env.* files are ignored by Git, you will need to create these files manually to set up the necessary environment variables for connecting to the databases.
Ensure these .env
files are listed in your .gitignore
to prevent them from being pushed to GitHub.
.env.development
PGDATABASE=database_name
.env.test
PGDATABASE=database_name_test
npm run setup-dbs
npm run seed
Run the automated tests with:
npm test
Explore the full API documentation here for detailed information on available endpoints, request methods, and examples.
Recommended extension to view JSON files JSON Viewer Pro
Endpoint | Description |
---|---|
GET /api | Responds with a list of available endpoints |
GET /api/topics | Responds with a list of topics |
POST /api/topics | Adds a new topic with a unique slug and description |
GET /api/articles | Responds with a list of articles |
GET /api/articles (queries) | Allows articles to be filtered and sorted |
POST /api/articles | Adds a new article |
GET /api/articles/:article_id (comment count) | Adds a comment count to the response when retrieving a single article |
GET /api/articles/:article_id | Responds with a single article retrived by article_id |
PATCH /api/articles/:article_id | Updates an article by article_id |
DELETE /api/articles/:article_id | Deletes an article by article_id |
GET /api/articles/:article_id/comments | Responds with a list of comments by article_id |
POST /api/articles/:article_id/comments | Adds a comment by article_id |
GET /api/comments/:comment_id | Responds with a single comment retirved by comment_id |
PATCH /api/comments/:comment_id | Updates a comment by comment_id |
DELETE /api/comments/:comment_id | Deletes a comment by comment_id |
GET /api/users | Responds with a list of users |
GET /api/users/:username | Responds with a single object of a user retirved by a username |
Contributions are welcome! Follow these steps to contribute:
- Fork the repository.
- Create your feature branch (git checkout -b feature/AmazingFeature).
- Commit your changes (git commit -m 'Add some AmazingFeature').
- Push to the branch (git push origin feature/AmazingFeature).
- Open a pull request.
This portfolio project was created as part of a Digital Skills Bootcamp in Software Engineering provided by Northcoders