Sid Meier's Civilization V - Quotes API
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
API Reference
- Model
- All Quotes
- Technologies Quotes
- Wonders Quotes
- Great Works Quotes
- Eras Quotes
URL
Note: See below for more details for "queries"
Model
Technologies, Wonders, and Great Works share the same next structure.
{
_id:
// The quotation text
quote:
// The name of the author
author:
// Type of category quote and its name
category: {
type: , // values: technology, wonder, great work
name: , // name of the wonder, technology or great work
}
// Expansion pack in which was added
expansionAdded: // 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"
},
Query Structure
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 (' ') | %20 | '/api/v1/all-quotes?author=Albert%20Einstein' |
| '&' | &26 | '/api/v1/all-quotes?expansionAdded=Gods%26Kings' |
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: |
| 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
All Quotes
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 All Quotes
Returns an array of all quotes in the three main categories (Technologies, Wonders, Great Works)
Response
"status": "success",
"results": , // Number of results in "quotes"
"data": {
"quotes": [
{
"_id": ,
"author":
"quote": ,
"category": {
"type":
"name":
},
"expansionAdded": ,
},
]
}
Get Quote
Gets a specified quote from an Id.
Response
{
"status": "success",
"data": {
"quote": {
"_id": ,
"quote": ,
"author": ,
"category": {
"type": ,
"name":
},
"expansionAdded": ,
}
}
}
Create Quote
Creates a new quote from the body request
{
"quote": , // Required
"author": , // Required
"category": {
"type": , // Required
"name": // Required
},
expansionAdded: // Default: Vanilla
}
Update Quote
Updates a specific quote from an Id
Delete Quote
Deletes a specific quote from an Id
Technologies Quotes
These routes allow working with only technologies quotes.
Get All Technologies Quotes
Response
"status": "success",
"results": , // Number of results in "quotes"
"data": {
"quotes": [
{
"_id": ,
"author":
"quote": ,
"category": {
"type": 'technology'
"name":
},
"expansionAdded": ,
},
]
}