GET /api/profile/activity
Fetches activity data for the authenticated user, supporting multiple activity types with pagination.
Authentication
Valid NextAuth session token required
Query Parameters
type
string
default:"questions"
Type of activity to retrieve. Options:
questions - Questions created by the user
answers - Answers/messages posted by the user
debates - Debates initiated by the user
likes - Questions and answers the user has liked
favorites - Questions and answers the user has favorited
Page number for pagination (min: 1, max: 1000)
Number of items per page (min: 1, max: 50)
Response
Array of activity items. Structure varies by activity type.
Total count of items matching the query
Indicates whether more items are available on subsequent pages
Response Structures by Type
Show Questions (type=questions)
Returns question objects with fields:
id - Question ID
title - Question title
description - Question description
upvotes - Number of upvotes
createdAt - Creation timestamp
author - Author information
{
"items": [
{
"id": "q_123",
"title": "如何实现高效的 AI Agent?",
"description": "想了解实现高效 AI Agent 的最佳实践",
"upvotes": 15,
"createdAt": "2026-03-01T10:00:00.000Z",
"author": {
"id": "user_123",
"name": "张三"
}
}
],
"total": 1,
"hasMore": false
}
Show Answers (type=answers)
Returns answer/message objects with fields:
id - Message ID
content - Answer content
upvotes - Number of upvotes
createdAt - Creation timestamp
questionId - Associated question ID
questionTitle - Associated question title
{
"items": [
{
"id": "msg_456",
"content": "可以使用 LangChain 框架来实现...",
"upvotes": 8,
"createdAt": "2026-03-01T11:00:00.000Z",
"questionId": "q_123",
"questionTitle": "如何实现高效的 AI Agent?"
}
],
"total": 1,
"hasMore": false
}
Show Debates (type=debates)
Returns debate objects created by the user.{
"items": [
{
"id": "debate_789",
"userId": "user_123",
"topic": "AI 伦理问题讨论",
"createdAt": "2026-03-01T09:00:00.000Z"
}
],
"total": 1,
"hasMore": false
}
Returns mixed array of liked questions and answers, sorted by creation time:
- Questions include:
id, title, description, upvotes, createdAt, _type: 'question'
- Answers include:
id, content, upvotes, createdAt, questionId, questionTitle, author.name, _type: 'answer'
{
"items": [
{
"id": "q_123",
"title": "如何实现高效的 AI Agent?",
"description": "想了解实现高效 AI Agent 的最佳实践",
"upvotes": 15,
"createdAt": "2026-03-01T10:00:00.000Z",
"_type": "question"
},
{
"id": "msg_456",
"content": "可以使用 LangChain 框架来实现...",
"upvotes": 8,
"createdAt": "2026-03-01T11:00:00.000Z",
"questionId": "q_123",
"questionTitle": "如何实现高效的 AI Agent?",
"author": {
"name": "李四"
},
"_type": "answer"
}
],
"total": 2,
"hasMore": false
}
The likes endpoint limits to 50 most recent items before pagination is applied.
Show Favorites (type=favorites)
Returns mixed array of favorited questions and answers with the same structure as likes.
Uses the favorite creation timestamp for sorting.{
"items": [
{
"id": "q_789",
"title": "深度学习最佳实践",
"description": "分享深度学习项目的经验",
"upvotes": 20,
"createdAt": "2026-03-02T14:00:00.000Z",
"_type": "question"
}
],
"total": 1,
"hasMore": false
}
The favorites endpoint limits to 100 most recent items before pagination is applied.
Error Responses
Returned when the type parameter is not one of the valid options.
Returned when no valid session is found.
Show 500 Internal Server Error
Returned when the database query fails.
Usage Example
curl "https://api.example.com/api/profile/activity?type=questions&page=1&limit=10" \
-H "Cookie: next-auth.session-token=..."
Pagination parameters are automatically clamped to safe ranges: page (1-1000) and limit (1-50).