Posts API Documentation
Base URL
http://localhost:8000/careers/
Required Headers
Authorization: Bearer
Content-Type: application/json
Pagination (used on list endpoints)
-
batch_size: default 10, max 100 -
batch_number: default 0
Field limits
-
Post
title: required, max 200 chars -
Post
content: required, max 5000 chars -
Comment
content: required, max 1000 chars
Quick model shapes
-
Post:
-
Like:
-
Comment:
Core flow (CRUD)
1) Create post
POST /careers/create/
Body:
Example:
curl -X POST "http://localhost:8000/careers/create/" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"username":"alice","title":"My Post","content":"This is the content"}'
Response: 201 Created (returns the created post)
2) List posts
GET /careers/
Example:
curl -X GET "http://localhost:8000/careers/?batch_size=10&batch_number=0" \
-H "Authorization: Bearer <token>"
Response: 200 OK with pagination wrapper
3) Retrieve a post
GET /careers/{id}/
Example:
Response: 200 OK with the post object
4) Update a post
PATCH /careers/{id}/
Body (one or both fields):
Example:
curl -X PATCH "http://localhost:8000/careers/1/" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"title":"New title","content":"New content"}'
Response: 200 OK with the updated post
5) Delete a post
DELETE /careers/{id}/
Example:
Response: 204 No Content
Social features
Likes
- Like a post: POST
/careers/{id}/like/
Example:
Response: 201 Created with { "message": "Post liked successfully" }
- Unlike a post: DELETE
/careers/{id}/unlike/
Example:
Response: 204 No Content
- List likes: GET
/careers/{id}/likes/?batch_size=10&batch_number=0
Example:
curl -X GET "http://localhost:8000/careers/1/likes/?batch_size=10&batch_number=0" \
-H "Authorization: Bearer <token>"
Response: 200 OK with likes and batch_info
Comments
- Add comment: POST
/careers/{id}/comment/
Body:
Example:
curl -X POST "http://localhost:8000/careers/1/comment/" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"content":"This is a comment"}'
Response: 201 Created with the comment
- List comments: GET
/careers/{id}/comments/?batch_size=10&batch_number=0
Example:
curl -X GET "http://localhost:8000/careers/1/comments/?batch_size=10&batch_number=0" \
-H "Authorization: Bearer <token>"
Response: 200 OK with comments and batch_info
Shares
- Share a post: POST
/careers/{id}/share/Example:
Response: 201 Created with { "message": "Post shared successfully" }
- List shares: GET
/careers/{id}/shares/?batch_size=10&batch_number=0
Example:
curl -X GET "http://localhost:8000/careers/1/shares/?batch_size=10&batch_number=0" \
-H "Authorization: Bearer <token>"
Response: 200 OK with shares and batch_info
- Create a shared post with new content: POST
/careers/{id}/share-post/Body:
Example:
curl -X POST "http://localhost:8000/careers/1/share-post/" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"title":"Shared Post Title","content":"My thoughts"}'
Response: 201 Created with the new post (post_type is "share" and original_post present)