Blog

Objects

  1. Category
    id:ID for the category in database.
    name:Name of the category to display.
    posts:
  2. Post
    id:ID for the post in database.
    title:
    content:
    allow_comment:
    category:
    image:
    comments_count:
    tags:
    create_time:
    update_time:
    summarized:
  3. Tag
    id:ID for the tag in database.
    name:Name of the tag.
    frequency:
    posts:list of PostObjects (conditional).
  4. Comment
    id:ID for the comment in database.
    content:Content of the comment.
    create_time:(Timestamp) create time of the comment.
    user:UserObject Authentication if user is login.
    author_mail:Author email if user is not login.
    author_name:Author name if user is not login.
    replies:List of Comment Objects.

All of the listed APIs are restfull and content-type is application/json

Post API

class fardel.apps.blog.views.PostApi[source]
URL:/api/blog/posts/ and /api/blog/posts/<post_id>/
get(post_id=None)[source]
Optional url parameter:
 
  • post_id
Optional url query string:
 
  • page (default: 1)
  • per_page (default: 16)
Response:

If post_id is provided:

{ "post": PostObject(with content) }

If post_id is not provided:

{
    "posts":[list of PostObjects(without content and with summarized)]
    "pages": Number of pages
}
Errors:

If post id is not valid:

status_code:

404

response:
{"message":"No post with this id"}

Comment API

class fardel.apps.blog.views.CommentApi[source]
URL:/api/blog/posts/<post_id>/comments/
get(post_id)[source]
Optional url query string:
 
  • page (default: 1)
  • per_page (default: 16)
Response:
{
    "comments":[list of CommentObjects]
    "pages": Number of pages
}
Errors:

If post_id is not in valid ( not a published post or not found ):

status_code:

404 .. code-block:: python

{“message”:”No post with this id”}

post(post_id)[source]
  • Authorization token is not required but optional
Required data:
  • author_name (if you dont use access_token)
  • author_email (if you dont use access_token)
  • content
Optional data:
  • parent_comment_id
Response:
{"message":"Comment successfuly added"}
Errors:

If post_id is not in valid ( not a published post or not found ):

status_code:

404

response:
{"message":"No post with this id"}

If commenter information (user_id or (author_name, author_email) ) is not provided:

status_code:

422

response:
{"message":"Author name and Author email are required to post a comment  or you need to sign in"}

Tag API

class fardel.apps.blog.views.TagApi[source]
URL:/api/blog/tags/ or /api/blog/tags/<tag_id>/posts/
get(tag_id=None)[source]
If tag_id is provided:
response:
{
    "tag": TagObject(with posts)
}
errors:

If tag_id is not in valid:

status_code:

404 .. code-block:: python

{“message”:”No tag found with this id”}

Without tag_id:
response:
{
    "tags": [list of TagObjects(without posts)]
}

Category API

class fardel.apps.blog.views.CategoryApi[source]
URL:/api/blog/categories/ or /api/blog/categories/<category_id>/posts/
get(category_id=None)[source]
If category_id is provided:
optional url query string:
 
  • page (default: 1)
  • per_page (default: 16)
response:
{
    "category": CategoryObject(with posts)
}
errors:

If category_id is not in valid:

status_code:

404 .. code-block:: python

{“message”:”No category found with this id”}

Without category_id:
response:
{
    "categories": [list of CategoryObject(without posts)]
}