An open API service indexing awesome lists of open source software.

https://github.com/shawon922/django-blog-api

A simple API built with "Django Rest Framework (DRF)" for "django-blog". Here is the link of "django-blog", https://github.com/shawon922/django-blog
https://github.com/shawon922/django-blog-api

django django-rest-framework drf json-web-token pillow python python3

Last synced: about 2 months ago
JSON representation

A simple API built with "Django Rest Framework (DRF)" for "django-blog". Here is the link of "django-blog", https://github.com/shawon922/django-blog

Awesome Lists containing this project

README

          

# django-blog-api
## A simple API built with "Django Rest Framework (DRF)" for "django-blog".

### Session and Token based authentication available.

-------------------------

### To generate a Auth-token:

```
$ curl -X POST -d "username=your_username&password=your_password" http://localhost:8000/api/auth/token/
```

### To create a post, you must be authenticated. So do like this:

```
$ curl -H "Authorization: JWT " http://localhost:8000/api/posts/create
```

### To post a comment, you have to pass the following parameters:

1. slug

2. type (ex. post)

3. parent_id (optional. But if you post a reply to a comment, it's required.)

### To post a comment:

Example:
```
$ curl -X POST -H "Authorization: JWT " -H "Content-Type: application/json" -d '{"content":"This is a comment."}' 'http://localhost:8000/api/comments/create/?slug=the-slug-of-the-post&type=post'
```

### To post a reply:

Example:
```
$ curl -X POST -H "Authorization: JWT " -H "Content-Type: application/json" -d '{"content":"This is a comment."}' 'http://localhost:8000/api/comments/create/?slug=the-slug-of-the-post&type=post&parent_id=id_of_the_comment'
```