diff --git a/docs/api-introduction.mdx b/docs/api-introduction.mdx index 44e7a92..6fbf59e 100644 --- a/docs/api-introduction.mdx +++ b/docs/api-introduction.mdx @@ -28,6 +28,7 @@ The API is organized into the following categories: - `/api/auth/*` - Authentication endpoints - `/api/chat/*` - Chat functionality - `/api/users/*` - User management -- `/api/users/stats/*` - User statistics +- `/api/teams/*` - Team and user information endpoints +- `/api/teams/stats` - User and team statistics For detailed information about specific endpoints, see their respective documentation pages. diff --git a/docs/api-teams.mdx b/docs/api-teams.mdx new file mode 100644 index 0000000..d9cf1a5 --- /dev/null +++ b/docs/api-teams.mdx @@ -0,0 +1,132 @@ +--- +title: 'Teams API' +description: 'API endpoints for managing teams and user information' +--- + +# Teams API + +The Teams API provides endpoints for retrieving user information and statistics. These endpoints are useful for team management and analytics. + +## Get User by ID + +Retrieve detailed information about a specific user by their ID. + +### Endpoint + +``` +GET /api/teams/[id] +``` + +### Parameters + +| Parameter | Type | Required | Description | +|-----------|--------|----------|-----------------------| +| `id` | string | Yes | The unique user ID | + +### Response + +Returns a user object with the following structure: + +```json +{ + "id": "user_123", + "name": "John Doe", + "email": "john@example.com", + "posts": [ + { + "id": "post_456", + "title": "Example Post", + "content": "Post content..." + } + ], + "accounts": [ + { + "id": "account_789", + "provider": "google", + "providerAccountId": "123456789" + } + ] +} +``` + +### Error Responses + +| Status Code | Description | +|-------------|----------------------------| +| 404 | User not found | +| 500 | Error fetching user | + +### Example Request + +```bash +curl -X GET https://your-domain.com/api/teams/user_123 \ + -H "Authorization: Bearer YOUR_ACCESS_TOKEN" +``` + +## Get User Statistics + +Retrieve statistics about users in the system. This endpoint requires authentication. + +### Endpoint + +``` +GET /api/teams/stats +``` + +### Authentication + +This endpoint requires a valid session. The user must be authenticated to access this endpoint. + +### Response + +Returns statistics about users: + +```json +{ + "totalUsers": 150, + "activeUsers": 45, + "recentUsers": 12, + "timestamp": "2025-10-19T03:38:15.760Z" +} +``` + +### Response Fields + +| Field | Type | Description | +|---------------|--------|------------------------------------------------| +| `totalUsers` | number | Total number of users in the system | +| `activeUsers` | number | Number of users with active sessions | +| `recentUsers` | number | Number of users created in the last 7 days | +| `timestamp` | string | ISO 8601 timestamp of when stats were generated| + +### Error Responses + +| Status Code | Description | +|-------------|----------------------------| +| 401 | Unauthorized (no session) | +| 500 | Failed to fetch stats | + +### Example Request + +```bash +curl -X GET https://your-domain.com/api/teams/stats \ + -H "Authorization: Bearer YOUR_ACCESS_TOKEN" +``` + +### Example Response + +```json +{ + "totalUsers": 150, + "activeUsers": 45, + "recentUsers": 12, + "timestamp": "2025-10-19T03:38:15.760Z" +} +``` + +## Notes + +- The `/api/teams/[id]` endpoint returns user information including related posts and accounts +- The `/api/teams/stats` endpoint requires authentication and provides real-time statistics +- Active users are determined by checking for non-expired sessions +- Recent users are those created within the last 7 days diff --git a/docs/introduction.mdx b/docs/introduction.mdx index dc4ecd9..1a8f730 100644 --- a/docs/introduction.mdx +++ b/docs/introduction.mdx @@ -27,6 +27,7 @@ app/ ├── api/ # API routes │ ├── auth/ # Authentication endpoints │ ├── chat/ # Chat endpoints +│ ├── teams/ # Team and user information endpoints │ └── users/ # User management endpoints ├── components/ # Reusable components └── settings/ # User settings diff --git a/docs/mint.json b/docs/mint.json index a12b686..6093c64 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -31,7 +31,7 @@ }, { "group": "API Reference", - "pages": ["api-introduction", "api-authentication", "api-chat", "api-users"] + "pages": ["api-introduction", "api-authentication", "api-chat", "api-users", "api-teams"] } ] }