Public-facing API endpoints for the Discord bot integration.
Base URL: /api/bot
The Bot API provides public access to game data including users, parties, and game state information. All endpoints use GET requests with query parameters and return JSON responses.
No authentication required - all endpoints are publicly accessible.
Retrieve information about users in the game.
GET /api/bot?endpoint=users
Response:
[
{
"id": 1,
"username": "john_doe",
"bio": "Political enthusiast from California",
"role": "Representative",
"partyId": 5,
"politicalLeaning": "Center Left",
"isActive": true,
"lastActivity": 0,
"partyName": "Progressive Party",
"partyColor": "#3B82F6"
}
]GET /api/bot?endpoint=users&id=1
Parameters:
id(integer) - User ID
Response:
{
"id": 1,
"username": "john_doe",
"bio": "Political enthusiast from California",
"role": "Senator",
"partyId": 5,
"politicalLeaning": "Center Left",
"isActive": true,
"lastActivity": 0,
"partyName": "Progressive Party",
"partyColor": "#3B82F6"
}User Fields:
id- Unique user identifierusername- Display namebio- User biography/descriptionrole- Position in government (Representative,Senator,President)partyId- ID of party membership (null if independent)politicalLeaning- Political ideologyisActive- Whether user is currently activelastActivity- Days since last activity (0 = today)partyName- Name of party (null if independent)partyColor- Hex color code of party
Retrieve information about political parties.
GET /api/bot?endpoint=parties
Response:
[
{
"id": 5,
"name": "Progressive Party",
"color": "#3B82F6",
"bio": "Fighting for progress and equality",
"leaderId": 12,
"politicalLeaning": "Left",
"leaning": "Center Left",
"logo": "progressive-logo.png",
"discord": "https://discord.gg/example",
"memberCount": 15
}
]GET /api/bot?endpoint=parties&id=5
Parameters:
id(integer) - Party ID
Response:
{
"id": 5,
"name": "Progressive Party",
"color": "#3B82F6",
"bio": "Fighting for progress and equality",
"leaderId": 12,
"politicalLeaning": "Left",
"leaning": "Center Left",
"logo": "progressive-logo.png",
"discord": "https://discord.gg/example",
"memberCount": 15,
"members": [
{
"id": 1,
"username": "john_doe",
"role": "Representative"
},
{
"id": 12,
"username": "jane_smith",
"role": "Senator"
}
]
}Party Fields:
id- Unique party identifiername- Party namecolor- Hex color code for party brandingbio- Party description/platformleaderId- User ID of party leaderpoliticalLeaning- Political ideologyleaning- Specific political positionlogo- Logo filenamediscord- Discord invite linkmemberCount- Total number of party membersmembers- Array of member objects (only in specific party query)
Retrieve information about bills in the legislative process.
GET /api/bot?endpoint=bills
Response:
{
"House": [
{
"id": 1,
"status": "Voting",
"stage": "House",
"title": "Infrastructure Investment Act",
"creatorId": 5,
"content": "A comprehensive bill to improve national infrastructure...",
"createdAt": "2026-02-01T10:30:00.000Z",
"pool": 1,
"creatorUsername": "john_doe"
}
],
"Senate": [
{
"id": 2,
"status": "Voting",
"stage": "Senate",
"title": "Healthcare Reform Bill",
"creatorId": 12,
"content": "Reforms to the national healthcare system...",
"createdAt": "2026-01-28T14:20:00.000Z",
"pool": 1,
"creatorUsername": "jane_smith"
}
],
"Presidency": [
{
"id": 3,
"status": "Awaiting Signature",
"stage": "Presidency",
"title": "Education Funding Act",
"creatorId": 8,
"content": "Increases funding for public education...",
"createdAt": "2026-01-25T09:15:00.000Z",
"pool": 1,
"creatorUsername": "alex_johnson"
}
]
}GET /api/bot?endpoint=bills&stage=House
Parameters:
stage(string) - Legislative stage (House,Senate, orPresidency)
Response:
[
{
"id": 1,
"status": "Voting",
"stage": "House",
"title": "Infrastructure Investment Act",
"creatorId": 5,
"content": "A comprehensive bill to improve national infrastructure...",
"createdAt": "2026-02-01T10:30:00.000Z",
"pool": 1,
"creatorUsername": "john_doe"
}
]GET /api/bot?endpoint=bills&stage=House&status=Voting
Parameters:
stage(string, optional) - Legislative stage (House,Senate, orPresidency)status(string, optional) - Bill status (e.g.,Queued,Voting,Awaiting Signature)
Both parameters can be used independently or together to filter bills.
Response:
[
{
"id": 1,
"status": "Voting",
"stage": "House",
"title": "Infrastructure Investment Act",
"creatorId": 5,
"content": "A comprehensive bill to improve national infrastructure...",
"createdAt": "2026-02-01T10:30:00.000Z",
"pool": 1,
"creatorUsername": "john_doe"
}
]Bill Fields:
id- Unique bill identifierstatus- Current status (Queued,Voting,Awaiting Signature, etc.)stage- Legislative stage (House,Senate,Presidency)title- Bill titlecreatorId- ID of user who created the billcontent- Full text of the billcreatedAt- Timestamp of bill creationpool- Bill pool numbercreatorUsername- Username of bill creator
Retrieve information about election candidates with their vote counts and campaign statistics.
GET /api/bot?endpoint=candidates
Response:
[
{
"id": 15,
"userId": 42,
"username": "john_doe",
"election": "President",
"votes": 1250,
"donations": 50000,
"votesPerHour": 45,
"donationsPerHour": 1200,
"partyId": 5,
"partyName": "Progressive Party",
"partyColor": "#3B82F6"
},
{
"id": 22,
"userId": 38,
"username": "jane_smith",
"election": "Senate",
"votes": 890,
"donations": 35000,
"votesPerHour": 32,
"donationsPerHour": 950,
"partyId": null,
"partyName": null,
"partyColor": null
}
]GET /api/bot?endpoint=candidates&election=President
Parameters:
election(string) - Election type (President,Senate, orHouse)
Response:
[
{
"id": 15,
"userId": 42,
"username": "john_doe",
"election": "President",
"votes": 1250,
"donations": 50000,
"votesPerHour": 45,
"donationsPerHour": 1200,
"partyId": 5,
"partyName": "Progressive Party",
"partyColor": "#3B82F6"
},
{
"id": 16,
"userId": 38,
"username": "jane_smith",
"election": "President",
"votes": 980,
"donations": 42000,
"votesPerHour": 38,
"donationsPerHour": 1100,
"partyId": null,
"partyName": null,
"partyColor": null
}
]Candidate Fields:
id- Candidate IDuserId- User ID of the candidateusername- Candidate's usernameelection- Election type (President,Senate,House)votes- Current vote countdonations- Total campaign donations receivedvotesPerHour- Rate of votes gained per hourdonationsPerHour- Rate of donations gained per hourpartyId- ID of candidate's party (null if independent)partyName- Name of candidate's party (null if independent)partyColor- Hex color of candidate's party (null if independent)
Candidates are sorted by vote count in descending order (highest votes first).
Retrieve current election states for game update posts. When elections are in Voting or Concluded status, candidate information with vote counts is included.
GET /api/bot?endpoint=game-state
Response (with candidates for Voting/Concluded elections):
[
{
"election": "President",
"status": "Voting",
"seats": null,
"daysLeft": 3,
"candidates": [
{
"id": 15,
"userId": 42,
"username": "john_doe",
"election": "President",
"votes": 1250,
"donations": 50000,
"partyId": 5,
"partyName": "Progressive Party",
"partyColor": "#3B82F6"
},
{
"id": 16,
"userId": 38,
"username": "jane_smith",
"election": "President",
"votes": 980,
"donations": 42000,
"partyId": null,
"partyName": null,
"partyColor": null
}
]
},
{
"election": "Senate",
"status": "Candidate",
"seats": 10,
"daysLeft": 5
}
]Election State Fields:
election- Election type (President,Senate,House)status- Current phase (Candidate,Voting,Concluded, etc.)seats- Number of available seats (primarily for Senate)daysLeft- Days remaining in current phasecandidates- Array of candidate objects (only present when status isVotingorConcluded)
Candidate Fields (when included):
id- Candidate IDuserId- User ID of the candidateusername- Candidate's usernameelection- Election typevotes- Current vote countdonations- Total campaign donations receivedpartyId- ID of candidate's party (null if independent)partyName- Name of candidate's party (null if independent)partyColor- Hex color of candidate's party (null if independent)
Candidates are sorted by vote count in descending order (highest votes first).
{
"error": "Invalid endpoint",
"available": ["users", "parties", "game-state"],
"usage": {
"users": "/api/bot?endpoint=users or /api/bot?endpoint=users&id=1",
"parties": "/api/bot?endpoint=parties or /api/bot?endpoint=parties&id=1",
"gameState": "/api/bot?endpoint=game-state"
}
}{
"error": "Invalid user ID"
}{
"error": "Invalid stage",
"validStages": ["House", "Senate", "Presidency"]
}{
"error": "Invalid election type",
"validElections": ["President", "Senate", "House"]
}{
"error": "User not found"
}{
"error": "Internal server error",
"message": "Detailed error message"
}200- Success400- Bad request (invalid endpoint or ID)404- Resource not found500- Internal server error
Currently no rate limiting is implemented. Please be respectful with request frequency.
curl "https://democracyonline.io/api/bot?endpoint=users"curl "https://democracyonline.io/api/bot?endpoint=parties&id=5"curl "https://democracyonline.io/api/bot?endpoint=game-state"curl "https://democracyonline.io/api/bot?endpoint=bills"curl "https://democracyonline.io/api/bot?endpoint=bills&stage=House"curl "https://democracyonline.io/api/bot?endpoint=bills&stage=House&status=Voting"curl "https://democracyonline.io/api/bot?endpoint=bills&status=Voting"curl "https://democracyonline.io/api/bot?endpoint=candidates&election=President"curl "https://democracyonline.io/api/bot?endpoint=candidates"Use game-state endpoint to generate daily game update messages showing election progress.
Use users endpoint with ID to display detailed user information in Discord.
Use parties endpoint to show party details, member lists, and recruitment information.
Use bills endpoint to track bills moving through the legislative process and display voting information.
Use candidates endpoint to display election leaderboards and track campaign progress with real-time vote and donation statistics.
The Bot API is implemented in /src/routes/api/bot.ts using TanStack Start server routes with direct database queries via Drizzle ORM.