:D
Base path: /api/user/:username/location
GET /api/user/:username/location
username
(URL path): The username to query.{ "success": true, "username": "testuser", "location": "City, Country" }
or{ "success": true, "username": "testuser", "location": null }
{ "success": false, "error": "Failed to fetch location" }
POST /api/user/:username/location
username
(URL path): The username to update.{
"location": "New City, Country",
"hidden": false // Optional, boolean
}
{ "success": true, "username": "testuser", "location": "New City, Country", "hidden": false }
{ "success": false, "error": "Location is required" }
{ "success": false, "error": "Failed to set location" }
DELETE /api/user/:username/location
null
).username
(URL path): The username whose location should be deleted.{ "success": true, "username": "testuser", "message": "Location deleted" }
{ "success": false, "error": "Failed to delete location" }
Base path: /api/user/:username/lastfm
GET /api/user/:username/lastfm
username
(URL path): The username to query.{ "success": true, "username": "testuser", "lastfmUsername": "lastfmuser" }
or{ "success": true, "username": "testuser", "lastfmUsername": null }
{ "success": false, "error": "Failed to fetch LastFM username" }
POST /api/user/:username/lastfm
username
(URL path): The username to update.{
"lastfmUsername": "newlastfmuser"
}
{ "success": true, "username": "testuser", "lastfmUsername": "newlastfmuser" }
{ "success": false, "error": "LastFM username is required" }
{ "success": false, "error": "Failed to set LastFM username" }
DELETE /api/user/:username/lastfm
null
).username
(URL path): The username whose Last.fm username should be deleted.{ "success": true, "username": "testuser", "message": "LastFM username deleted" }
{ "success": false, "error": "Failed to delete LastFM username" }
Base path: /api/user/:username/preferences
GET /api/user/:username/preferences
username
(URL path): The username to query.{
"success": true,
"username": "testuser",
"optedOutCommands": ["command1", "command2"]
}
or (if no preferences found){
"success": true,
"username": "testuser",
"optedOutCommands": []
}
{ "success": false, "error": "Failed to fetch user preferences" }
GET /api/user/:username/preferences/:command
username
(URL path): The username to query.command
(URL path): The command name to check.{ "success": true, "username": "testuser", "command": "command1", "isOptedOut": true }
{ "success": false, "error": "Failed to check opt-out status" }
POST /api/user/:username/optout
username
(URL path): The username to update.{
"command": "command_to_opt_out"
}
{ "success": true, "username": "testuser", "command": "command_to_opt_out", "action": "opted-out" }
{ "success": false, "error": "Command name is required" }
{ "success": false, "error": "Failed to opt out of command" }
POST /api/user/:username/optin
username
(URL path): The username to update.{
"command": "command_to_opt_in"
}
{ "success": true, "username": "testuser", "command": "command_to_opt_in", "action": "opted-in" }
{ "success": false, "error": "Command name is required" }
{ "success": false, "error": "Failed to opt in to command" }
POST /api/user/:username/preferences
username
(URL path): The username to update.{
"optedOutCommands": ["new_command1", "new_command2"]
}
{
"success": true,
"username": "testuser",
"optedOutCommands": ["new_command1", "new_command2"],
"message": "Preferences updated successfully"
}
{ "success": false, "error": "optedOutCommands must be an array" }
{ "success": false, "error": "Failed to update user preferences" }
Base path: /api/reminders
and /api/user/:username/reminders
GET /api/user/:username/reminders
user_reminders
and reminders
.username
(URL path): The username to query.type
(optional): Filter reminders by type (sent
, received
, self
). If omitted, returns all types.{
"success": true,
"username": "testuser",
"reminders": [
{
"id": "abc123xyz", // friendlyId
"type": "sent", // or "received", "self"
"message": "Reminder message",
"createdAt": "2025-04-14T18:00:00.000Z",
"reminderTime": "2025-04-14T18:00:00.000Z", // or createdAt for self/user reminders
"delivered": false, // or true
"fromUser": "testuser", // or sender if type is 'received'
"targetUser": "anotheruser", // or recipient if type is 'sent', or self if type is 'self'
"channel": "#channelname" // Optional
},
// ... more reminders
]
}
{ "success": false, "error": "Failed to fetch reminders" }
GET /api/reminders/:friendlyId
friendlyId
. Checks both user_reminders
and reminders
collections.friendlyId
(URL path): The unique ID of the reminder.{
"success": true,
"reminder": {
"id": "abc123xyz",
"type": "user", // or "self"
"message": "Reminder message",
"createdAt": "2025-04-14T18:00:00.000Z",
"reminderTime": "2025-04-14T18:00:00.000Z",
"delivered": false,
"fromUser": "sender",
"targetUser": "recipient", // or self username
"channel": "#channelname"
}
}
{ "success": false, "error": "Reminder not found" }
{ "success": false, "error": "Failed to fetch reminder" }
PUT /api/reminders/:id
:id
as the friendlyId
for lookup. Only the sender of a user reminder or the owner of a self-reminder can update it. Delivered user reminders cannot be edited.id
(URL path): The friendlyId
of the reminder to update.{
"message": "Updated reminder message",
"username": "testuser" // The username attempting the update
}
{
"success": true,
"reminder": { ... updated reminder object ... }
}
{ "success": false, "error": "Message is required" }
{ "success": false, "error": "Cannot edit a reminder that has already been delivered" }
{ "success": false, "error": "Reminder not found or you do not have permission to update it" }
{ "success": false, "error": "Failed to update reminder" }
DELETE /api/reminders/:id
friendlyId
. Only the sender/owner can delete it. Uses the URL parameter :id
as the friendlyId
. Includes extensive logging and multiple query attempts to handle potential ID type mismatches.id
(URL path): The friendlyId
of the reminder to delete.{
"username": "testuser" // The username attempting the deletion
}
{ "success": true, "message": "Reminder deleted successfully" }
{ "success": false, "error": "Username is required" }
{ "success": false, "error": "Reminder not found or you do not have permission to delete it" }
{ "success": false, "error": "Failed to delete reminder" }
Base path: /api/stats
GET /api/stats/commands
command_stats
collection.{
"success": true,
"data": [
{
"command": "weather",
"useCount": 150,
"successCount": 145,
"failureCount": 5,
"lastUsed": "2025-04-19T01:20:00.000Z"
},
{
"command": "time",
"useCount": 120,
"successCount": 120,
"failureCount": 0,
"lastUsed": "2025-04-19T01:15:00.000Z"
}
// ... more commands sorted by useCount descending
]
}
{ "success": false, "error": "Failed to fetch command stats" }
GET /api/stats/commands/:commandName
command_stats
collection, including recent usage examples.commandName
(URL path): The name of the command (case-insensitive).{
"success": true,
"data": {
"command": "weather",
"useCount": 150,
"successCount": 145,
"failureCount": 5,
"lastUsed": "2025-04-19T01:20:00.000Z",
"recentUsage": [
{ "username": "user1", "channel": "channel1", "timestamp": "2025-04-19T01:20:00.000Z", "success": true },
{ "username": "user2", "channel": "channel2", "timestamp": "2025-04-19T01:18:00.000Z", "success": false }
// ... up to 100 recent usages
]
}
}
command_usage_logs
but not command_stats
:{
"success": true,
"data": {
"command": "somecommand",
"useCount": 5,
"successCount": 0,
"failureCount": 0,
"lastUsed": null,
"recentUsage": []
},
"message": "Stats summary not generated, returning basic count from logs."
}
{ "success": false, "error": "Stats not found for command: <commandName>" }
{ "success": false, "error": "Failed to fetch command stats" }
GET /api/stats/users/:username
command_usage_logs
collection.username
(URL path): The username to query (case-insensitive).{
"success": true,
"data": [
{
"command": "weather",
"totalUses": 25,
"successfulUses": 24,
"failedUses": 1,
"lastUsed": "2025-04-19T01:20:00.000Z",
"avgResponseTime": 150.5 // milliseconds, null if no response times logged
},
{
"command": "time",
"totalUses": 10,
"successfulUses": 10,
"failedUses": 0,
"lastUsed": "2025-04-18T23:55:00.000Z",
"avgResponseTime": 50.0
}
// ... more commands sorted by totalUses descending
]
}
{ "success": false, "error": "Failed to fetch user stats" }
GET /api/stats/channels/:channelName
command_usage_logs
collection.channelName
(URL path): The channel name to query (case-insensitive).{
"success": true,
"data": [
{
"command": "weather",
"totalUses": 50,
"uniqueUserCount": 15,
"successfulUses": 48,
"failedUses": 2,
"lastUsed": "2025-04-19T01:20:00.000Z"
},
{
"command": "followage",
"totalUses": 30,
"uniqueUserCount": 20,
"successfulUses": 30,
"failedUses": 0,
"lastUsed": "2025-04-19T00:10:00.000Z"
}
// ... more commands sorted by totalUses descending
]
}
{ "success": false, "error": "Failed to fetch channel stats" }
GET /api/stats/global
command_usage_logs
collection.{
"success": true,
"data": {
"totalCommands": 10532,
"uniqueUsers": 521,
"uniqueChannels": 85,
"uniqueCommands": 45,
"successRate": 98.5, // Percentage
"avgResponseTime": 112.7 // milliseconds, null if no response times logged
}
}
or (if no logs exist yet){
"success": true,
"data": {}
}
{ "success": false, "error": "Failed to fetch global stats" }
GET /api/stats/logs
command_usage_logs
collection, with filtering options.startDate
(string): Filter logs on or after this date/time (ISO 8601 or YYYY-MM-DD format).endDate
(string): Filter logs on or before this date/time (ISO 8601 or YYYY-MM-DD format). If YYYY-MM-DD, includes the entire day.limit
(integer): Maximum number of logs to return (default: 100, max: 1000).username
(string): Filter logs by username (case-insensitive).channel
(string): Filter logs by channel name (case-insensitive).command
(string): Filter logs by command name (case-insensitive).success
(boolean): Filter logs by success status (true
or false
).{
"success": true,
"data": [
{
"command": "weather",
"username": "user1",
"channel": "channel1",
"args": ["London"],
"success": true,
"responseTime": 180, // milliseconds
"timestamp": "2025-04-19T01:20:00.000Z",
"date": "2025-04-19"
},
{
"command": "time",
"username": "user2",
"channel": "channel2",
"args": [],
"success": true,
"responseTime": 45,
"timestamp": "2025-04-19T01:15:00.000Z",
"date": "2025-04-19"
}
// ... more logs sorted by timestamp descending, up to the limit
]
}
{ "success": false, "error": "Invalid <parameter> format..." }
{ "success": false, "error": "Failed to fetch command usage logs" }