Programming Quotes API for open source projects.
Visit: programming-quotes-api.azurewebsites.net
Github repo: github.com/mudroljub/programming-quotes-api
Feel free to get involved, suggest or implement new features.
- Description: Fetches a random programming quote.
GET /api/quotes
- Description: Retrieves quotes, with optional query parameters:
page
: The page number (default: 1).quotesPerPage
: Number of quotes per page (default: 20).author
: Filter quotes by a specific author.
- Description: Retrieves a single quote by its unique ID.
Access to these routes requires a valid token.
- Description: Adds a new quote.
- Required Parameters (in JSON body):
author
: The name of the author (should match a Wikipedia entry).text
: The quote text.
- Optional Parameters:
source
: The source or context of the quote.
- Description: Updates an existing quote by ID.
- Parameters (in JSON body):
author
,text
, orsource
.
- Description: Votes for a specific quote.
- Required Parameters (in JSON body):
quoteId
: The ID of the quote.newVote
: A numeric value (1–5).
- Description: Deletes a quote by its unique ID.
- Description: Logs in or registers a new user.
- Required Parameters (in JSON body):
email
: The user's email address.password
: The user's password.
- Returns: A JWT token.
Token Usage: For all subsequent requests, include the token in the Authorization
header as follows:
Authorization: Bearer <token>
- Install Node.js
- Set environment variables
Import json file into local MongoDB database (replace with real values):
mongoimport --db quotes --collection quotes --file quotes.json --jsonArray --username quotes --password quotes
Create .env
file proper values (this is an example):
# database credentials (obtain from MongoDB)
CONNECTION_STRING=mongodb://quotes:quotes@localhost:27017/quotes
# whatever random string you like
JWT_SECRET=BILO ŠTA SAMO DA JE TAJNA
# use development for local testing
NODE_ENV=development
npm i
npm run dev