Our backend API empowers users to create topics, message others, and manage discussions across different categories. Administrators can oversee user activity and maintain forum security.
Registers a new user with the system.
- Method:
POST
- Path:
/users/register
- Content Type:
application/json
Field | Type | Description |
---|---|---|
username | string | The username of the user (unique identifier). |
string | The email address of the user (unique identifier). | |
password | string | The password for the user's account. |
firstname | string | The first name of the user. |
lastname | string | The last name of the user. |
{
"username": "john_doe",
"password": "P@ssw0rd",
"firstname": "John",
"lastname": "Doe",
"email": "[email protected]"
}
- 200 OK: User successfully registered.
- 400 Bad Request: If the username is already taken or the email is already associated with an existing user.
Response Body (Success)
- Content Type:
text/plain
Status Code | Message |
---|---|
200 | User with id:{id} and username:{username} was created |
Response Body (Error)
- Content Type:
text/plain
Status Code | Message |
---|---|
400 | Bad Request: Username is taken. |
400 | Bad Request: User with this email already exists |
Logs in a user to the system and generates an authentication token.
- Method:
POST
- Path:
/users/login
- Content Type:
application/json
Field | Type | Description |
---|---|---|
username | string | The username of the user. |
password | string | The password for the user's account. |
{
"username": "john_doe",
"password": "P@ssw0rd"
}
- 200 OK: User successfully logged in and authentication token generated.
- 400 Bad Request: If the login data provided is invalid.
Response Body (Success)
- Content Type: application/json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Response Body (Error)
- Content Type: application/json
{
"detail": "Invalid login data"
}
Creates a new category. Requires admin access/token.
- Method:
POST
- Path:
/categories
Key | Value | Description |
---|---|---|
x-token | string | the token of the user, generated by the login |
- Content Type:
application/json
Field | Type | Description |
---|---|---|
name | string | the name of the category we want to create |
description | string | optional; more info about the category |
status | string | optional; either unlocked(default) or locked |
privacy | string | optional; either public(default) or private |
{
"name": "Medieval Times",
"description": "All about the medieval time period in history"
}
- 201 Created: Category created successfully.
- 401 Unauthorized: If the user has failed to login.
- 403 Forbidden: If the user is not an admin.
Status Code | Message |
---|---|
201 | Category 11 created successfuly! |
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
403 | You are not admin! |
Creates a new topic. Requires standard (user) authentication.
- Method:
POST
- Path:
/topics
- Content Type:
application/json
Field | Type | Description |
---|---|---|
title | string | the title of the topic we want to create |
category_id | int | the id of the category this topic will belong to |
description | string | the topic content |
status | string | optional; either unlocked(default) or locked |
{
"title": "How many hours did people sleep during the Medieval time period?",
"category_id": 11,
"description": "I saw this tv program on the History Channel once. It mentioned medieval people went to bed right after sundown. They would wake up sometime before sunrise. They would hire a 'knocker-upper' to wake them up. So in Europe, the nights could be as long as 16 hours in winter. The same tv show mentioned people would wake-up in the middle of the night & have a snack."
}
- 201 Created: Topic created successfully.
- 401 Unauthorized: If the user has failed to login.
- 403 Forbidden: If the category is locked or is private and the user does not have access.
- 404 Not Found: If the category id is not in the database.
Response Body (Success)
- Content Type:
text/plain
Status Code | Message |
---|---|
201 | Topic {id} created successfuly! |
Response Body (Error)
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
403 | The category is locked and does not accept any further topics! |
403 | You don't have writing access for the category of this topic! |
404 | This category does not exist! |
Creates a new reply. Requires standard (user) authentication.
- Method:
POST
- Path:
/topics/{topic_id}/replies
- Content Type:
text/plain
Just put the string with the content of the reply in the Body.
"More or less like us. What changed was how they slept.
Sleeping was likely as seasonal as their food. In summer they would go to sleep late to better use the hours of sunlight."
- 201 Created: Reply created successfully.
- 401 Unauthorized: If the user has failed to login.
- 403 Forbidden: If the topic locked or if the category it belongs to is private and the user does not have access.
- 404 Not Found: If the topic id is not in the database.
- Content Type:
text/plain
Status Code | Message |
---|---|
201 | Reply {id} created successfuly! |
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
403 | The topic is locked and does not accept any further replies! |
403 | You don't have writing access for the category of this topic! |
404 | This topic does not exist! |
View a specific category and its topics. Requires standard (user) authentication.
- Method:
GET
- Path:
/categories/{category_id}
- 200 OK: Displaying the category with its topics.
- 401 Unauthorized: If the user has failed to login.
- 403 Forbidden: If the category is private and the user does not have read or write access.
- 404 Not Found: If the category id is not in the database.
- Content Type:
application/json
{
"category": {
"id": 1,
"name": "Art History",
"description": "All about visual art",
"status": "unlocked",
"privacy": "public"
},
"topics": [
{
"id": 1,
"title": "Was Van Gogh a better artist than Da Vinci?",
"category_id": 1,
"user_id": 1,
"date": "2024-05-09T16:23:35",
"description": "",
"status": "unlocked",
"best_reply": 3
},
{
"id": 2,
"title": "I just got rejected from the Academy of Fine Arts Vienna. What do I do now?",
"category_id": 1,
"user_id": 6,
"date": "2024-05-10T09:24:47",
"description": "I recently applied to the Academy of Fine Arts Vienna, but I just received a rejection letter. I'm feeling pretty down and unsure about my next steps. Has anyone else experienced this, and what did you do to stay motivated? I'd appreciate any advice on other art schools or alternative paths in the art world.",
"status": "unlocked",
"best_reply": 4
}
]
}
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to view category. |
403 | You don't have access to this category! |
404 | This category does not exist! |
View a specific topic and its replies. Requires standard (user) authentication.
- Method:
GET
- Path:
/topics/{topic_id}
- 200 OK: Displaying the topic and its replies.
- 401 Unauthorized: If the user has failed to login.
- 403 Forbidden: If the category the topic belongs to is private and the user does not have read or write access.
- 404 Not Found: If the topic id is not in the database.
- Content Type:
application/json
{
"topic": {
"id": 4,
"title": "What are the best ways to think of ideas for a startup?",
"category_id": 2,
"user_id": 6,
"date": "2024-05-10T10:22:46",
"description": "",
"status": "locked",
"best_reply": 9
},
"replies": [
{
"id": 9,
"user_id": 7,
"date": "2024-05-10T10:23:32",
"topic_id": 4,
"content": "A startup idea is derived out of discomfort or a gap you see in the existing market. So don’t go looking here and there for that billion idea, just be more attentive and observant while looking around you, it is right there.",
"upvotes": 2,
"downvotes": 0
},
{
"id": 10,
"user_id": 8,
"date": "2024-05-10T10:24:23",
"topic_id": 4,
"content": "Make sure your solution is unique, and you don't have a ton of competition. Use Google to search for competitors",
"upvotes": 2,
"downvotes": 2
},
{
"id": 11,
"user_id": 7,
"date": "2024-05-10T10:24:59",
"topic_id": 4,
"content": "Validate demand (prove people will buy it). You can pre-sell with crowdfunding to prove this, or you can make a landing page that looks like your product is ready to go. Have your price on the landing page. When a user tries to buy capture their email, and inform them that they caught you right before launch",
"upvotes": 0,
"downvotes": 0
}
]
}
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to view topic. |
403 | You don't have access to the category this topic belongs to! |
404 | There is no such topic! |
View all topics. Open access: no token necessary.
- Method:
GET
- Path:
/topics
Key | Value | Description |
---|---|---|
page | integer | The page number to display results. |
limit | integer | The number of topics to display on the page. |
- 200 OK: Displaying the list of topics.
- Content Type: application/json
[
{
"id": 1,
"title": "Was Van Gogh a better artist than Da Vinci?",
"category_id": 1,
"user_id": 1,
"date": "2024-05-09T16:23:35",
"description": "",
"status": "unlocked",
"best_reply": 3
}
]
View all categories. Open access: no token necessary.
- Method:
GET
- Path:
/categories
Key | Value | Description |
---|---|---|
page | integer | The page number to display results. |
limit | integer | The number of categories to display on the page. |
- 200 OK: Displaying the list of topics.
- Content Type:: application/json
[
{
"id": 1,
"name": "Art History",
"description": "All about visual art",
"status": "unlocked",
"privacy": "public"
}
]
Grants or revokes access to a category for a specific user. Requires admin access/token.
- Method:
PUT
- Path:
/categories/{category_id}/users/{user_id}
Parameter | Type | Description |
---|---|---|
category_id | int | The ID of the category. |
user_id | int | The ID of the user to grant access. |
- Content Type:
text/plain
Type | Description |
---|---|
string | The type of access to grant("read", "write"). |
"read"
- 200 OK: Access successfully granted or revoked.
- 400 Bad Request: If the request body or parameters are invalid.
- 401 Unauthorized: If the user is not authenticated.
- 403 Forbidden: If the authenticated user is not an admin.
- 404 Not Found: If the category specified does not exist.
Response Body (Success)
- Content Type:
text/plain
Status Code | Message |
---|---|
200 | User {user_id} has been granted {write/read} access! |
Response Body (Error)
- Content Type:
text/plain
Status Code | Message |
---|---|
400 | Invalid access_type: please choose between read and write!. |
401 | Token header is missing! You must be logged in to gain access |
403 | You are not admin! |
404 | This category does not exist! |
400 | The category is public! No need to give explicit access. |
Revokes access to a category for a specific user. Requires admin access/token.
- Method:
DELETE
- Path:
/categories/{category_id}/users/{user_id}
Parameter | Type | Description |
---|---|---|
category_id | int | The ID of the category. |
user_id | int | The ID of the user to revoke access. |
- 200 OK: Access successfully revoked.
- 401 Unauthorized: If the user is not authenticated.
- 403 Forbidden: If the authenticated user is not an admin.
- 404 Not Found: If the category specified does not exist.
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
403 | You are not admin! |
404 | This category does not exist! |
Changes the accessibility status of a category. Requires admin access/token.
- Method:
PUT
- Path:
/categories/{id}/status
Parameter | Type | Description |
---|---|---|
id | int | The ID of the category. |
- 200 OK: Accessibility status successfully changed.
- 401 Unauthorized: If the user is not authenticated.
- 403 Forbidden: If the authenticated user is not an admin.
- 404 Not Found: If the category specified does not exist.
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
403 | You are not admin! |
404 | This category does not exist! |
Changes the status of a topic. Requires admin access/token.
- Method:
PUT
- Path:
/topics/{id}/status
Parameter | Type | Description |
---|---|---|
id | int | The ID of the topic. |
- 200 OK: Status successfully changed.
- 401 Unauthorized: If the user is not authenticated.
- 403 Forbidden: If the authenticated user is not an admin.
- 404 Not Found: If the topic specified does not exist.
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
403 | You are not admin! |
404 | This topic does not exist! |
A logged in user creates a message to another existing user in the database.
- Method:
POST
- Path:
/messages
Key | Value | Description |
---|---|---|
x-token | string | the token of the user, generated by the login |
- Content Type:
application/json
Field | Type | Description |
---|---|---|
text | string | Content of the message |
receiver_id | string | Recipient of the message |
{
"text": "Hi.",
"receiver_id": 5
}
- 201 Created: Message has been sucessfully created.
- 401 Unauthorised - Invalid token or user is not our database.
- 404 Not Found Username is not found.
Response Body (Success)
- Content Type:
text/plain
Status Code | Message |
---|---|
201 | Message to User {user_id} successfully sent (ID {message_id})! |
Response Body(Error)
- Content Type:
json/application
{
"detail": "Invalid token"
}
Status Code | Message |
---|---|
401 | Token header is missing! You need to log in first! |
404 | No such recipient exists! |
Find a list of conversations a logged in user has with other users.
- Method:
GET
- Path:
/conversations
Key | Value | Description |
---|---|---|
x-token | string | the token of the user, generated by the login |
- 200 OK - List of conversations is provided.
- 401 Unauthorised - Invalid token or user is not our database.
Response Body (Success)
- Content Type::
application/json
[
"User 4(you) has conversations with the following users:",
[
{
"receiver_id": 5,
"username": "geomilev"
}
]
]
Response Body(Error)
- Content Type::
application/json
{
"detail": "Invalid token"
}
- Content Type:
text/plain
| Status Code | Message | |-------------| ---------------------------------------------------------- | | 401 | Token header is missing! You must be logged in to gain access |
View the conversation between a logged in user and another registered user in the database.
- Method:
GET
- Path:
/conversation/{id}
- 200 OK The sought conversation is provided.
- 401 Unauthorised - Invalid token or user is not our database.
Response Body (Success)
- Content Type::
application/json
[
{
"id": 9,
"sender_id": 5,
"text": "Anyway. Nashledanou.",
"date": "2024-05-10T12:23:01",
"receiver_id": 4
},
{
"id": 8,
"sender_id": 4,
"text": "Bad day?",
"date": "2024-05-10T12:21:31",
"receiver_id": 5
}
]
Response Body(Error)
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
- Content Type::
application/json
{
"detail": "Invalid token"
}
A logged in user can upvote or downvote on an existing reply in the system.
- Method:
PUT
- Path:
/replies/{id}/vote
Key | Value | Description |
---|---|---|
x-token | string | the token of the user, generated by the login |
- Content Type:
text/plain
"up" for upvote or "down" for downvote
"up"
- 200 OK Vote is casted.
- 401 Unauthorised Invalid token.
- 404 Not Found Username is not found.
No written response.
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
- Content Type:
json/application
{
"detail": "Invalid token"
}
- Content Type:
json/application
{
"detail": [
{
"type": "missing",
"loc": [
"body"
],
"msg": "Field required",
"input": null
}
]
}
- Content Type:
json/application
{
"detail": [
{
"type": "string_type",
"loc": [
"body"
],
"msg": "Input should be a valid string",
"input": 1
}
]
}
An author to a topic can select a reply as the best reply.
- Method:
PUT
- Path:
/topics/{id}/bestreply
Key | Value | Description |
---|---|---|
x-token | string | the token of the user, generated by the login |
- Content Type:
text/plain
ID number of the reply.
5
- 200 OK: Best Reply is selected.
- 401 Unauthorised: Invalid token or user is not our database.
- 404 Not Found: Username is not found.
- Content Type:
text/plain
Status Code | Message |
---|---|
200 | You have successfully chosen the reply ID {reply_id} as the best! |
- Content Type:
json/application
{
"detail": "Invalid token"
}
- Content Type:
text/plain
Token header is missing! You must be logged in to gain access
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
Changing the privacy to categories between public and private. Requires admin access/token.
- Method:
PUT
- Path:
/categories/{id}/privacy
Key | Value | Description |
---|---|---|
x-token | string | the token of the user, generated by the login |
- 200 OK: Category Privacy is amended.
- 401 Unauthorised: Invalid token or user is not our database.
- 404 Not Found: Username is not found.
- Content Type:
text/plain
Status Code | Message |
---|---|
200 | Privacy status changed to public for category Art History! |
200 | Privacy status changed to private for category Art History! |
- Content Type:
json/application
{
"detail": "Invalid token"
}
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
404 | This category does not exist! |
List of users who have read or write access for private categories.
- Method:
GET
- Path:
/categories/{id}/priviliged
- 200 OK: List of privileged users is provided.
- 401 Unauthorised: Invalid token or user is not our database.
- 403 Forbidden: You are not an admin to check the list of priviliged users.
Response Body (Success)
- Content Type:
application/json
{
"category": {
"id": 2,
"name": "Startups",
"description": "Why we make one and how to succeed..",
"status": "unlocked",
"privacy": "private"
},
"users": [
{
"id": 4,
"access_type": "read"
},
{
"id": 6,
"access_type": "write"
}
]
}
Response Body(Error)
- Content Type:
text/plain
Status Code | Message |
---|---|
401 | Token header is missing! You must be logged in to gain access |
403 | You are not admin! |
- Content Type::
application/json
{
"detail": "Invalid token"
}