Hacktiv8Shimbun_Backend
Mobile app server for hacktiv8 Shimbun
non cache version here https://github.com/fariswd/Hacktiv8Shimbun_Backend/tree/server_non_cached
Host
Host: http://s1.hacktiv8shimbun.ga
combine with HTTP endpoint
example:
GET http://s1.hacktiv8shimbun.ga/api/article
HTTP Endpoint
Endpoint | HTTP | Require | Description |
---|---|---|---|
/api/article/ | POST | {json} | post a new article |
/api/articles/ | POST | {articles: [{json},{json}, ... ]} | post a new articles |
/api/article/ | GET | - | get all article |
/api/article/:id | GET | params.id | get article by id |
/api/article/:id | PUT | params.id, {json} | edit an article |
/api/article/:id | DELETE | params.id | delete an article |
/api/latest | GET | - | get latest 10 |
/api/latest/:page | GET | params.page | get page, 10 articles/page |
/api/category/:category | GET | params.category | get article by category latest 10 |
/api/category/:category/:page | GET | params.category, params.page | get article by category, 10 articles/page |
/api/search?keyword= | GET | query.keyword | search by title |
/api/search?keyword=&page= | GET | query.keyword, query.page | search by title |
Versioning (Redis Cache)
Endpoint | HTTP | Require | Description |
---|---|---|---|
/api/latestver | GET | - | get version cache |
API Documentation
POST | /api/article
- Require: {json}
- Data Params:
{
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
}
- Success Response
{
"status": "OK",
"newArticle": {
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
}
}
- Error Response
{
status: 'cannot post article',
msg: <error message>
}
POST | /api/articles
- Require: {articles: [{json},{json}, ... ]}
- Data Params:
{ "articles" :
[
{
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"imageHeader": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "Fri Dec 01 2017 00:00:00 GMT+0700 (WIB)"
},
{
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Shiina Mashiro",
"author": "Kagamine Punk",
"imageHeader": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "Sat Dec 02 2017 00:00:00 GMT+0700 (WIB)"
},
...
]
}
- Success Response
{
"status": "OK",
"newArticle": {
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
},
...
}
- Error Response
{
status: 'cannot post article',
msg: <error message>
}
GET | /api/article or /api/article/:id
- Require: -
- Params:
optional: id=[object_id] - Data Params: -
- Success Response
default:
{
{
"status": "OK",
"articles": [
{
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
},
{
"__v": 0,
"_id": "5a3f7ac32821764c7f44b865",
"title": "[Waifu Friday] Hatsune Miku",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-10T09:58:00.562Z"
},
...
]
}
}
using params:
{
{
"status": "OK",
"articles":
{
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
}
}
}
- Error Response
{
status: 'cannot get all articles',
msg: <error message>
}
PUT | /api/article/:id
- Require: :id params
- Params:
required: id=[object_id] - Data Params:
{
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
}
- Success Response
{
"status": {
"n": 1,
"nModified": 1,
"ok": 1
},
"articleBefore": {
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
},
"artcileAfter": {
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
}
}
- Error Response
{
status: "cannot edit article ID 5a3f7bc02821764c7f44b86e",
msg: <error message>
}
DELETE | /api/article/:id
- Require: :id params
- Params:
required: id=[object_id] - Data Params: -
- Success Response
{
"status": {
"n": 1,
"ok": 1
},
"articleBefore": {
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
}
}
- Error Response
{
status: "cannot delete article ID 5a3f7bc02821764c7f44b86e",
msg: <error message>
}
GET | /api/latest or /api/latest/:page
- Description: Get 10 latest article, if use params 10/page sorted descending
- Require: -
- Params:
optional: page=[Number] - Data Params: -
- Success Response
default:
{
{
"status": "OK",
"articles": [
{
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
},
{
"__v": 0,
"_id": "5a3f7ac32821764c7f44b865",
"title": "[Waifu Friday] Hatsune Miku",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-10T09:58:00.562Z"
},
...
]
}
}
using params:
{
{
"status": "OK",
"page": 2,
"articles": [
{
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
},
{
"__v": 0,
"_id": "5a3f7ac32821764c7f44b865",
"title": "[Waifu Friday] Hatsune Miku",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-10T09:58:00.562Z"
},
...
]
}
}
- Error Response
{
status: 'cannot get latest',
msg: <error message>
}
GET | /api/category/:category or /api/category/:category/:page
- Description: Get 10 latest category, if use params 10/page, sorted descending
- Require: params.category
- Params:
optional: page=[Number] - Data Params: -
- Success Response
default:
{
{
"status": "OK",
"articles": [
{
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
},
{
"__v": 0,
"_id": "5a3f7ac32821764c7f44b865",
"title": "[Waifu Friday] Hatsune Miku",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-10T09:58:00.562Z"
},
...
]
}
}
using params:
{
{
"status": "OK",
"page": 2,
"articles": [
{
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
},
{
"__v": 0,
"_id": "5a3f7ac32821764c7f44b865",
"title": "[Waifu Friday] Hatsune Miku",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-10T09:58:00.562Z"
},
...
]
}
}
- Error Response
{
status: `cannot get catagory of 'waifu' on page 2`,
msg: <error message>
}
GET | /api/search?keyword=XXX or /api/search?keyword=XXX&page=YYY
- Description: Get 10 latest searched by title, if use params 10/page, sorted descending
- Require: query.keyword
- Params:
optional: page=[Number] - Data Params: -
- Success Response
default:
{
{
"status": "OK",
"articles": [
{
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
},
{
"__v": 0,
"_id": "5a3f7ac32821764c7f44b865",
"title": "[Waifu Friday] Hatsune Miku",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-10T09:58:00.562Z"
},
...
]
}
}
using params:
{
{
"status": "OK",
"page": 2,
"articles": [
{
"__v": 0,
"_id": "5a3f7bc02821764c7f44b86e",
"title": "[Waifu Friday] Kizuna Ai",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-17T09:58:00.562Z"
},
{
"__v": 0,
"_id": "5a3f7ac32821764c7f44b865",
"title": "[Waifu Friday] Hatsune Miku",
"author": "Kagamine Punk",
"image_header": "http://jpg.link.com/img.jpg",
"category": [
"Perfect",
"Virtual",
"Waifu",
"waifu friday"
],
"content": "<p>Some HTML Content</p>",
"createdAt": "2017-08-10T09:58:00.562Z"
},
...
]
}
}
- Error Response
{
status: `cannot search 'waifu' on page 2`,
msg: <error message>
}