This REST API provides access to various insights based on data pulled from the Campuswire forums. It allows users to retrieve valuable metrics related to traffic and student or staff activity. This documentation outlines the endpoints, request/response examples, and error handling methods specific to this API.
The calculations performed within these requests are extensive and aim to make it simple for the users to easily retrieve necessary statistics. Please refer to the following sections for detailed information on the available endpoints, request and response examples, and error handling.
Code | HTTP Status |
---|---|
200 | OK |
400 | BAD REQUEST |
Return all published posts ordered by post number.
None
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
None Required
Return all registered authors (students and staff).
None
{
"slug": string,
"posts": list[int],
"comments": list[string],
"firstName": string,
"lastName": string,
"moderator": boolean,
"endorsed_comments": list[string],
"answered_posts": list[int]
}
None Required
Return all published comments.
None
{
"comment_id": string,
"endorsed": boolean,
"is_answer": boolean,
"body": string,
"publishedAt": string,
"author": string,
"post": number
}
None Required
Return the post with the specified number.
Parameter | Type | Description |
---|---|---|
<post_id> |
int |
Post Number |
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if post with specified <post_id>
does not exist.
{
"err": "Post #<post_id> does not exist."
}
Return all posts published by the author with the specified <author_id>
.
Parameter | Type | Description |
---|---|---|
<author_id> |
string |
Author Slug |
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if author with specified <author_id>
does not exist or no posts were published by this author.
{
"err": "No posts were published by this author or author with id <author_id> does not exist."
}
Return all posts published between the specified <start_time>
and <end_time>
.
Parameter | Type | Format | Description |
---|---|---|---|
<start_time> |
string |
YYYY-MM-DD |
Start Time as a Date String |
<end_time> |
string |
YYYY-MM-DD |
End Time as a Date String |
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if <end_time>
occurs after <start_time>
, parameters are invalid date strings, or no posts were published in the specified timeframe.
{
"err": "Date string not in specified format: YYYY-MM-DD, <start_time> and <end_time> are not in chronological order, or no posts were made in this time frame."
}
Return all posts with no published answers (by students or staff).
None
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if there exist no unanswered posts.
{
"err": "There are currently no unanswered posts."
}
Return at most ten posts with the most views in descending order.
None
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if there exist no posts.
{
"err": "There are currently no posts."
}
Return at most ten posts with the most unique views in descending order.
None
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if there exist no posts.
{
"err": "There are currently no posts."
}
Return at most ten posts with the most likes in descending order.
None
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if there exist no posts.
{
"err": "There are currently no posts."
}
Return at most ten posts with the most answers (by students or staff) in descending order.
None
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if there exist no posts.
{
"err": "There are currently no posts."
}
Return the number of posts made at each hour, day, and week.
None
{
"per_hour": {
"0": list[string],
"1": list[int]
},
"per_day": {
"0": list[string],
"1": list[int]
},
"per_week": {
"0": list[string],
"1": list[int]
}
}
None Required
Return statistics for each post useful for calculating response times.
None
{
"number": int,
"publishedAt": string,
"modAnsweredAt": string
}
Return the following with a 400
status code if there exist no posts.
{
"err": "There are currently no posts."
}
Return posts filtered by whether they were posted by a student or a staff member.
Parameter | Type | Description |
---|---|---|
student_or_mod |
string |
student or moderator |
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"modAnsweredAt": string,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if there exist no posts based on the filter.
{
"err": "No Matching Posts Found."
}
Return the number of views registered between the specified <start_time>
and <end_time>
.
Parameter | Type | Format | Description |
---|---|---|---|
<start_time> |
string |
YYYY-MM-DD |
Start Time as a Date String |
<end_time> |
string |
YYYY-MM-DD |
End Time as a Date String |
{
"views": int,
"unique_views": int
}
Return the following with a 400
status code if <end_time>
occurs after <start_time>
, parameters are invalid date strings, or no views were registered in the specified timeframe.
{
"err": "Date string not in specified format: YYYY-MM-DD, <start_time> and <end_time> are not in chronological order, or no views were registered in this time frame."
}
Return all posts with no published answers by staff.
None
{
"number": int,
"comments": list[string],
"post_slug": string,
"title": string,
"body": string,
"type": string,
"public": boolean,
"publishedAt": string,
"viewsCount": int,
"uniqueViewsCount": int,
"read": boolean,
"answersCount": int,
"likesCount": int,
"author": string
}
Return the following with a 400
status code if there exist no posts unanswered by staff.
{
"err": "There are currently no posts unanswered by staff."
}
Return the number of views registered at each hour, day, and week.
None
{
"per_hour": {
"0": list[string],
"1": list[int]
},
"per_day": {
"0": list[string],
"1": list[int]
},
"per_week": {
"0": list[string],
"1": list[int]
}
}
None Required
There are several tests that have been already written in backend/tests
that test basic functionality of these endpoints and the models used by them. They can be run using the following command from the main TeamPalm
folder:
python backend/manage.py test