Skip to content

Latest commit

 

History

History
58 lines (52 loc) · 44.9 KB

endpoints.md

File metadata and controls

58 lines (52 loc) · 44.9 KB

API Endpoints

The table below shows all endpoints related to the DRF API, with example outputs, post data, and explanations. Generic views were used throughout the API build, here they are broken down to explain further.

⏪ Main README

Url HTTP Method CRUD Operation View Type POST Data Format GET Example Output Explanation
Built-in Auth Endpoints
'/' GET Read List - {
"message": "welcome message"
}
HTML representation of the root route
'/admin/' - - - - - Admin interface for managing models
'/dj-rest-auth/' - - - - - Authentication endpoints provided by 'dj-rest-auth'
'/dj-rest-auth/login/' POST Create Login {
"username":"string",
"password":"string"
}
- User login endpoint
'dj-rest-auth-registration' POST Create Register {
"username":"string",
"password":"string",
"password2":"string"
}

-
New user registration endpoint
'dj-rest-auth/logout/' POST Delete Logout - - User logout endpoint
Profiles Endpoints
'/profiles/' GET Read List - This shows just one profile, however, the list view is multiple of these instances:
{
"id": 4,
"owner": "super",
"name": "",
"bio": "",
"job": "",
"created_on": "12/10/2023 - 08:31",
"updated_on": "12/10/2023 - 08:31",
"image": ".../user_defualt_icon_d7nivg.png",
"is_owner": false,
"employer": null,
"following_id": null,
"approval_id": null,
"posts_count": 0,
"following_count": 0,
"followers_count": 0,
"approval_count": 0
},
Displays list of user profiles
'/profiles/pk/' GET Read Retrieve - {
"id": 2,
"owner": "magic",
"name": "",
"bio": "",
"job": "",
"created_on": "07/10/2023 - 09:01",
"updated_on": "09/10/2023 - 13:38",
"image": ".../user_defualt_icon_d7nivg.png",
"is_owner": true,
"employer": null,
"following_id": null,
"approval_id": null,
"posts_count": 1,
"following_count": 1,
"followers_count": 1,
"approval_count": 1
}
Retrieves profile details of a specific user profile
'/profiles/pk/' PUT Update Update {
"name": "string",
"bio": "string",
"job": "string",
"image": "string",
"employer": "employer pk",
}
- Updates existing user profiles. It can only be updated by the owner of the profile.
Posts Endpoints
'/posts/' GET Read List - This shows just one post, however, the list view is multiple of these instances:

{
"id": 3,
"owner": "magic",
"title": "Tests",
"content": "testing",
"created_on": "09/10/2023 - 14:14",
"updated_on": "09/10/2023 - 14:14",
"image": ".../logo_nobg_aac6d9.png",
"is_owner": true,
"profile_id": 2,
"profile_image": ".../user_defualt_icon_d7nivg.png",
"profile_job": "",
"like_id": null,
"comments_count": 0,
"likes_count": 1
},
Displays a list of all posts, accessible to all users.
'/posts/' POST Create Create {
"title": "string",
"content": "string",
"image": image file
}
- Enables users to create a new post, only accessiböe to logged in users.
'/posts/pk/' GET Read Retrieve - {
"id": 3,
"owner": "magic",
"title": "Tests",
"content": "testing",
"created_on": "09/10/2023 - 14:14",
"updated_on": "09/10/2023 - 14:14",
"image": ".../logo_nobg_aac6d9.png",
"is_owner": true,
"profile_id": 2,
"profile_image": ".../user_defualt_icon_d7nivg.png",
"profile_job": "",
"like_id": null,
"comments_count": 0,
"likes_count": 1
}
Displays all details of a specific post, accessible to all users.
'/posts/pk/' PUT Update Update {
"title": "string",
"content": "string",
"image": image file
}
- Users can update a post if they are the post owner.
'/posts/pk/' DELETE Delete Destroy - - Deletes the related post.Only the owner of the post can delete it.
Comments Endpoints
'/comments/' GET Read List - {
"id": 1,
"owner": "admin",
"post": 2,
"content": "amazing work mate!",
"created_on": "1\u00A0month, 1\u00A0week ago",
"updated_on": "1\u00A0month, 1\u00A0week ago",
"is_owner": false,
"profile_id": 1,
"profile_image": ".../user_defualt_icon_d7nivg.png"
},
Displays a list of all comments accessible by all users.
'/comments/' POST Create Create {
"post": post instance,
"content": "text field"
}
- Creates a comment instance, only accessible to logged in users.
'/comments/pk/' GET Read Retrieve - {
"id": 1,
"owner": "admin",
"post": 2,
"content": "amazing work mate!",
"created_on": "1\u00A0month, 1\u00A0week ago",
"updated_on": "1\u00A0month, 1\u00A0week ago",
"is_owner": false,
"profile_id": 1,
"profile_image": ".../user_defualt_icon_d7nivg.png"
}
Retrieves a single comments details.
'/comments/pk/' PUT Update Update {
"post": post instance,
"content": "text field"
}
- Updates a comment instance, only accessible by the owner of the related comment.
'/comments/pk/' DELETE Delete Destroy - - Deletes a comment instance, only the comment owner can delete the comment.
Companies Endpoints
'/companies/' GET Read List - Only one company instance is shown here, however a list view contains multiples of these:

{
"id": 2,
"name": "MagicMiso",
"owner": "magic",
"location": "NewYork",
"type": "Cuisine",
"created_on": "07/10/2023 - 12:36",
"is_owner": true,
"employee_count": 0
},
The company list view lists all companies in the database, all users can view this list.
'/companies/' POST Create Create {
"name": "string",
"location": "string",
"type": "string"
}
- Logged in users have the ability to create a company, additionally each profile can only add a maximum of 3 companies.
'/companies/pk/' GET Read Retrieve - {
"id": 2,
"name": "MagicMiso",
"owner": "magic",
"location": "NewYork",
"type": "Cuisine",
"created_on": "07/10/2023 - 12:36",
"is_owner": true,
"employee_count": 0
}
Company details retrieval, displays one specific post details.
'/companies/pk/' PUT Update Update {
"name": "string",
"location": "string",
"type": "string"
}
- The owner of a company has the ability to update the company details.
'/companies/pk/' DELETE Delete Destroy - - Owners of a company instance can delete the company.
Approvals Endpoints
'/approvals/' GET Read List - {
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 5,
"owner": "magic",
"profile": "admin",
"created_on": "1\u00A0month, 1\u00A0week ago"
},
{
"id": 3,
"owner": "admin",
"profile": "magic",
"created_on": "1\u00A0month, 1\u00A0week ago"
}
]
}
All users can view a list of approval instances. The list view includes a count of approvals and pagination.
'/approvals/' POST Create Create {
"profile": profile instance
}
- Logged in users can create an approval when specifying another profile, users can not approve their own profile.
'/approvals/pk/' GET Read Retrieve - {
"id": 5,
"owner": "magic",
"profile": "admin",
"created_on": "1\u00A0month, 1\u00A0week ago"
}
Users can view a single specified approval instance.
'/approvals/pk/' DELETE Delete Destroy - - The owner of a particular instance has the ability to delete the instance.
Followers Endpoints
'/followers/' GET Read List - {
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 4,
"owner": "magic",
"followed": 1,
"created_on": "09/10/2023 - 18:19",
"followed_profile": "admin"
},
{
"id": 3,
"owner": "admin",
"followed": 2,
"created_on": "09/10/2023 - 13:03",
"followed_profile": "magic"
}
]
}
All users can view a list of follower instance, with a count field and pagination specified. Here the owner is the 'follower' and the followed_profile is the 'following'.
'/followers/' POST Create Create {
"followed": profile instance
}
- A logged in user can create a follower instance by specifying a profile instance they wish to follow, they can not follow their own profile.
'/followers/pk/' GET Read Retrieve - {
"id": 4,
"owner": "magic",
"followed": 1,
"created_on": "09/10/2023 - 18:19",
"followed_profile": "admin"
}
A specified follower instance can be viewd with all its details.
'/followers/pk/' DELETE Delete Destroy - - The owner of a follower instance can also delete it.
Likes Endpoints
'/likes/' GET Read List - {
"count": 3,
"next": null,
"previous": null,
"results": [
{
"id": 4,
"owner": "admin",
"post": 2,
"created_on": "14/10/2023 - 07:31"
},
{
"id": 3,
"owner": "admin",
"post": 3,
"created_on": "10/10/2023 - 05:03"
},
{
"id": 2,
"owner": "magic",
"post": 2,
"created_on": "09/10/2023 - 14:14"
}
]
}
All users can view a list of likes including the count and pagination fields. The liked post is defined by the post pk.
'/likes/' POST Create Create {
"post": post instance pk
}
- A like can be created by a logged in user, when they specify a post instance to like.
'/likes/pk/' GET Read Retrieve - {
"id": 2,
"owner": "magic",
"post": 2,
"created_on": "09/10/2023 - 14:14"
}
Users can view a single like instances data.
'/likes/pk/' DELETE Delete Destroy - - The owner of a like can also delete the like.

The endpoints table was created at Table Generators.com

⏫ top

⏪ Main README