Documentation
Obtaining an Authentication Token
Request: POST
Url:
https://nyasablog.com/api/account/login
Params:
username (Enter your login email)
password (Your password)
No that's not a typo above. The param is username but you use your email.
Success Response:
{
"response": "Successfully authenticated.",
"pk": 1,
"email": "mike@nyasablog.com",
"token": "27a46967801960de8734f65ba13b124aaea96ad9"
}
Creating a Blog Post
Request: POST
Headers:
Authorization: Token <token>
Url:
https://nyasablog.com/api/blog/create
Params:
title (text)
body (text)
image (file)
Success Response:
{
"title": "New Title!",
"body": "this is new body \ncool.\nstuff.",
"image": "image": "image": "https://nyc3.digitaloceanspaces.com/nyasa-blog-spaces/nyasa-blog-static/blog/9/Blantyre-blantyre.jpg",
"date_updated": "2019-07-09T15:19:33.095626Z",
"username": "mike"
}
Viewing a Specific Blog Post
Request: GET
Headers:
Authorization: Token <token>
Url:
https://nyasablog.com/api/blog/<slug>/
Success Response:
{
"title": "Blantyre",
"Blantyre is a city in the Shire Highlands, in southern Malawi. It adjoins the town of Limbe and is known for its British colonial architecture and nearby parks and reserves. On Chichiri Hill, the Museum of Malawi (Chichiri Museum) has exhibits on natural history and ethnography, and also hosts traditional dances.
Colonial Mandala House, built in 1882, houses the Society of Malawi Library and Archive.",
"image": "image": "https://nyc3.digitaloceanspaces.com/nyasa-blog-spaces/nyasa-blog-static/blog/6/Blantyre-kwathu.jfif",
"date_updated": "2019-07-09T16:02:19.170321Z",
"username": "mike"
}
Updating a Specific Blog Post
Request: PUT
Headers:
Authorization: Token <token>
Url:
https://nyasablog.com/api/blog/<slug>/update
Success Response:
{
"response": "updated"
}
Deleting a Specific Blog Post
Request: DELETE
Headers:
Authorization: Token <token>
Url:
https://nyasablog.com/api/blog/<slug>/delete
Success Response:
{
"response": "deleted"
}
List Blog Posts (Pagination, Search and Ordering)
Request: GET
Headers:
Authorization: Token <token>
Url:
https://nyasablog.com/api/blog/list/?search=<query>&ordering=-date_updated&page=1
Params:
query (this will search the title and body of blog posts for a match)
ordering (Can use: title, body, username or date_updated)
page (10 results will be shown per page.)
Success Response:
{
"count": <num_results>,
"next": null,
"previous": null,
"results": [
{
"title": "gfhhfghfgh",
"body": "fghgfhfghf",
"image": "http://nyasablog.com/media/blog/1/gfhhfghfgh-1.png",
"date_updated": "2019-07-05T21:43:56.452234Z",
"username": "mike"
},
...
}