A REST API for quotes from Sid Meier’s Civilization V game.
I initially built this as a project to practice with MongoDB and NodeJS. I hope you will like it!
Please be free to comment or add any new feature. I'd thank you lot if you helped me to complete the database with the Great Works Quotes. Thanks for your time!
Main Technologies implemented
- NodeJS
- Express
- MongoDB
- Mongoose
https://civilizationv-quotes-api.up.railway.app/api/v1/<queries>
Note: See below for more details for "queries"
Technologies, Wonders, and Great Works share the same next structure.
{
_id: <String>
// The quotation text
quote: <String>
// The name of the author
author: <String>
// Type of category quote and its name
category: {
type: <String>, // values: technology, wonder, great work
name: <String>, // name of the wonder, technology or great work
}
// Expansion pack in which was added
expansionAdded: <String> // values: Vanilla, Gods&Kings, Brave New World
}
Example
{
"quote": "Education is the best provision for old age.",
"author": "Aristotle",
"category": {
"type": "technology",
"name": "Education"
},
"expansionAdded": "Vanilla"
},
Important
- All authors name starts with Uppercase
- Expansions: Vanilla, Gods&Kings, Brave New World (All with Uppercase)
- Category.type: technology, wonder, great work (All with Lowercase)
- Category.name: Starts with Lowercase
Special characters in queries
Character | Representation | Example |
---|---|---|
Space (' ') | '/api/v1/all-quotes?author=Albert Einstein' | |
'&' | &26 | '/api/v1/all-quotes?expansionAdded=Gods&Kings' |
Query parameters
Param | Type | Description | Example | Returns |
---|---|---|---|---|
fields | String |
Returns quotes with only one or more specific fields plus the Id | /api/v1/all-quotes?fields=quote,author |
{ _id: <string>, quote: <string>, author: <string> } |
sort | String |
Sort the results by the specific fields | /api/v1/all-quotes?sort=category.name |
Returns an array of quotes sorted by the name of its category in DESC order by default(sort=-category.name == ASC order). |
limit | Int |
Sets the number of results per page. | /api/v1/all-quotes?limit=5 |
Returns the first 5 results |
page | Int |
The page of results to return | /api/v1/all-quotes?page=2&limit=5 |
Returns the 5 results from page 2 |
Two or more params
FIELDS and SORT accepts more than one param, separated by comma:
fields: ?fields=quote,author
sort: ?sort=author,category.name
This route only accept get, post, patch and delete with the three main categories: Technologies, Wonders, Great Works. Era quotes has different model and most of them have more than one quote for each era. If you want era quotes too, you must make another fetch.
GET /api/v1/all-quotes
Returns an array of all quotes in the three main categories (Technologies, Wonders, Great Works)
Response
"status": "success",
"results": <Int>, // Number of results in "quotes"
"data": {
"quotes": [
{
"_id": <string>,
"author": <string>
"quote": <string>,
"category": {
"type": <string>
"name": <string>
},
"expansionAdded": <string>,
},
]
}
GET /api/v1/all-quotes/{quoteId}
Gets a specified quote from an Id.
Response
{
"status": "success",
"data": {
"quote": {
"_id": <string>,
"quote": <string>,
"author": <string>,
"category": {
"type": <string>,
"name": <string>
},
"expansionAdded": <string>,
}
}
}
POST /api/v1/all-quotes
Creates a new quote from the body request
{
"quote": <string>, // Required
"author": <string>, // Required
"category": {
"type": <string>, // Required
"name": <string> // Required
},
expansionAdded: <string> // Default: Vanilla
}
PATCH /api/v1/all-quotes/{quoteId}
Updates a specific quote from an Id
DELETE /api/v1/all-quotes/{quoteId}
Deletes a specific quote from an Id
These routes allow working with only technologies quotes.
GET /api/v1/technologies
Response
"status": "success",
"results": <Int>, // Number of results in "quotes"
"data": {
"quotes": [
{
"_id": <string>,
"author": <string>
"quote": <string>,
"category": {
"type": 'technology'
"name": <string>
},
"expansionAdded": <string>,
},
]
}
GET /api/v1/technologies/{technologyQuoteId}
Gets a specified technology quote from an Id.
Response
{
"status": "success",
"data": {
"quote": {
"_id": <string>,
"quote": <string>,
"author": <string>,
"category": {
"type": 'technology',
"name": <string>
},
"expansionAdded": <string>,
}
}
}
POST /api/v1/technologies
Creates a new technology quote from the body request
{
"quote": <string>, // Required
"author": <string>, // Required
"category": {
"type": 'technology',
"name": <string> // Required
},
expansionAdded: <string> // Default: Vanilla
}
PATCH /api/v1/technologies/{technologyQuoteId}
Updates a specific technology quote from an Id
DELETE /api/v1/technologies/{technologyQuoteId}
Deletes a specific technology quote from an Id
These routes allow working with only wonders quotes.
GET /api/v1/wonders
Response
"status": "success",
"results": <Int>, // Number of results in "quotes"
"data": {
"quotes": [
{
"_id": <string>,
"author": <string>
"quote": <string>,
"category": {
"type": 'wonder'
"name": <string>
},
"expansionAdded": <string>,
},
]
}
GET /api/v1/wonders/{wonderQuoteId}
Gets a specified wonder quote from an Id.
Response
{
"status": "success",
"data": {
"quote": {
"_id": <string>,
"quote": <string>,
"author": <string>,
"category": {
"type": 'wonder',
"name": <string>
},
"expansionAdded": <string>,
}
}
}
PATCH /api/v1/wonders
Creates a new wonder quote from the body request
{
"quote": <string>, // Required
"author": <string>, // Required
"category": {
"type": 'wonder',
"name": <string> // Required
},
expansionAdded: <string> // Default: Vanilla
}
PATCH /api/v1/wonders/{wonderQuoteId}
Updates a specific wonder quote from an Id
DELETE /api/v1/wonders/{wonderQuoteId}
Deletes a specific wonder quote from an Id
These routes allow working with only great works quotes.
GET /api/v1/great-works
Response
"status": "success",
"results": <Int>, // Number of results in "quotes"
"data": {
"quotes": [
{
"_id": <string>,
"author": <string>
"quote": <string>,
"category": {
"type": 'great work'
"name": <string>
},
"expansionAdded": <string>,
},
]
}
GET /api/v1/great-works/{greatWorkQuoteId}
Gets a specified great work quote from an Id.
Response
{
"status": "success",
"data": {
"quote": {
"_id": <string>,
"quote": <string>,
"author": <string>,
"category": {
"type": 'great work',
"name": <string>
},
"expansionAdded": <string>,
}
}
}
PATCH /api/v1/great-works
Creates a new wonder quote from the body request
{
"quote": <string>, // Required
"author": <string>, // Required
"category": {
"type": 'great works',
"name": <string> // Required
},
expansionAdded: <string> // Default: Vanilla
}
PATCH /api/v1/great-works/{greatWorkQuoteId}
Updates a specific great work quote from an Id
DELETE /api/v1/great-works/{greatWorkQuoteId}
Deletes a specific great work quote from an Id
Era quotes have a different schema compared with the three other main categories. Most eras have much more than one quote.
{
_id: <String>
// Array with quotes from an era.
quotes: [
{
_id: <String>,
quote: <String>,
author: <String>
}
],
// Name of the era
era: <String>
// Expansion pack in which was added
expansionAdded: <String> // values: Vanilla, Gods&Kings, Brave New World
}
'era' values : Ancient, Classical, Medieval, Renaissance, Industrial, Modern, Future, Atomic, Information
Example
{
"_id": "61e88",
"expansionAdded": "Gods&Kings",
"quotes": [
{
"_id": "911c",
"quote": "I never think about the future. It comes soon enough.",
"author": "Albert Einstein"
}
],
"era": "Information"
},
GET /api/v1/eras
Response
"status": "success",
"results": <Int>, // Number of results in "quotes"
"data": {
"quotes": [
{
"_id": <string>,
"era": <string> // Name of the era
"expansionAdded": <string>,
"quotes": [
{
"_id": <string>,
"quote": <string>,
"author": <string>
},
{
"_id": <string>,
"quote": <string>,
"author": <string>
}
],
}
]
}
GET /api/v1/eras/{eraId}
Gets quotes from a specified era with an eraId.
GET /api/v1/eras/{eraId}/{quoteId}
It's possible to get a specific quote from all that an era has.
Example
{
"_id": "61e88",
"expansionAdded": "Gods&Kings",
"quotes": [
{
"_id": "911c",
"quote": "I never think about the future. It comes soon enough.",
"author": "Albert Einstein"
}
],
"era": "Information"
},
Request
GET /api/v1/eras/61e88/911c
Response
{
"status": "success",
"data": {
"quote": {
"_id": "911c",
"quote": "I never think about the future. It comes soon enough.",
"author": "Albert Einstein"
}
}
}
POST /api/v1/eras
PATCH /api/v1/eras
DELETE /api/v1/eras