A random quote generator API built with Node.js by Hugo Adona.
- Random Quote Generation: Get single or multiple random quotes with their authors
- JSON Database: Quotes are stored in a pre-defined JSON database for fast access
- RESTful API: Clean and simple API endpoints
- Author Attribution: Each quote comes with proper author attribution
- Lightweight: Minimal dependencies for optimal performance
- Node.js (v14 or higher)
- npm or yarn
- Clone the repository:
git clone https://github.com/HugoAdona/quotely.git
cd quotely- Install dependencies:
npm install- Start the server:
npm startThe API will be available at http://localhost:3000 (or your configured port).
GET /api/quote
Returns a single random quote with its author.
Response:
{
"quote": "The only way to do great work is to love what you do.",
"author": "Steve Jobs"
}GET /api/quotes?count=5
Returns multiple random quotes. Use the count parameter to specify how many quotes you want (default: 1, max: 50).
Response:
{
"quotes": [
{
"quote": "Be yourself; everyone else is already taken.",
"author": "Oscar Wilde"
},
{
"quote": "In the middle of difficulty lies opportunity.",
"author": "Albert Einstein"
}
]
}// Get a single quote
fetch('/api/quote')
.then(response => response.json())
.then(data => console.log(data.quote, '- ' + data.author));
// Get multiple quotes
fetch('/api/quotes?count=3')
.then(response => response.json())
.then(data => data.quotes.forEach(item =>
console.log(item.quote, '- ' + item.author)
));# Get a single quote
curl http://localhost:3000/api/quote
# Get 5 random quotes
curl http://localhost:3000/api/quotes?count=5quotely/
├── src/
│ ├── routes/
│ ├── data/
│ │ └── quotes.json
│ └── app.js
├── package.json
├── README.md
└── .gitignore
- Daily inspiration apps
- Quote of the day widgets
- Writing prompts for journaling
- Social media content
- Educational applications
- Motivational displays
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- 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
To add new quotes to the database:
- Edit the
src/data/quotes.jsonfile - Follow the existing format:
{
"quote": "Your quote here",
"author": "Author Name"
}- Ensure proper JSON formatting
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Hugo Adona
- GitHub: @HugoAdona
- Thanks to all the great minds whose quotes inspire us daily
- Built with ❤️ and Node.js
"The best way to predict the future is to create it." - Peter Drucker