The Quotes API is free, open source. It is built from the needs of a coder to call from the web Portfolio. MongoDB database.
Name | URL | Description |
---|---|---|
Staging | https://stage-api-quotes.herokuapp.com/ | Synced with the stating branch of this repository |
Production | "" | The primary API server |
GET /api/quotes
Return all quotes
[
{
_id: oid,
quote: String,
author: String,
tags: [],
length: Number,
createdAt: Date,
updatedAt: Date
__v: 0
}
...
]
GET /api/query
param | type | Description |
---|---|---|
quote | String |
Set quote=random for random quote |
max | Int |
The maximum Length in characters ( can be combined with min ) |
min | Int |
The minimum Length in characters ( can be combined with max ) |
{
_id: oid,
quote: String,
author: String,
tags: [],
length: Number,
createdAt: Date,
updatedAt: Date
__v: 0
}
Random Quote try in browser
GET /api/query?quote=random
Random Quote with a maximum length of 50 characters try in browser
GET /api/query?quote=random&max=50
Random Quote with a minium length of 50 characters try in browser
GET /api/query?quote=random&min=50
Random Quote with a length between 50 and 140 characters try in browser
GET /api/query?quote=random&min=50&max=140
Get a random quote (fetch)
fetch("http://localhost:3000/api/query?quote=random")
.then((response) => response.json())
.then((data) => {
console.log(`${data.quote} — ${data.author}`);
});
Get a random quote (async/await)
async function randomQuote() {
const response = await fetch("http://localhost:3000/api/query?quote=random");
const data = await response.json();
console.log(`${data.quote} — ${data.author}`);
}
randomQuote();
Get a random quote (JQuery)
$.getJSON("http://localhost:3000/api/query?quote=random", function (data) {
console.log(`${data.quote} — ${data.author}`);
});