Build on Democracy Infrastructure

Access Votigram's APIs, SDKs, and Base contracts to integrate secure voting and civic engagement into your applications.

Core APIs

Polls API

Create, manage, and retrieve polls with advanced configuration options including geolocation, time limits, and verification levels.

POST /api/polls
GET /api/polls/:id
GET /api/polls/search

Voting API

Cast votes securely with human verification, track voting status, and retrieve results with privacy-preserving aggregation.

POST /api/votes
GET /api/votes/status/:id
GET /api/polls/:id/results

Verification API

Integrate WorldID and other verification systems to ensure human-only participation with configurable trust levels.

POST /api/verify/worldid
GET /api/verify/status
POST /api/verify/phone

Live Streams API

Create live audio/video rooms with integrated polling, real-time chat, and participation tracking.

POST /api/streams
GET /api/streams/:id/join
POST /api/streams/:id/poll

Quick Start

Get Started in 5 Minutes

1 Get your API key from the developer dashboard
2 Install the Votigram SDK for your platform
3 Create your first poll and start collecting votes

Code Examples

Creating a Poll

import { ethers } from 'ethers'; import { VotigramPoll } from '@votigram/contracts'; const provider = new ethers.JsonRpcProvider('https://base-sepolia.g.alchemy.com/v2/your-api-key'); const votigram = new Votigram({ apiKey: 'your-api-key', provider, contractAddress: '0x1234567890123456789012345678901234567890' }); const poll = await votigram.polls.create({ title: 'Community Budget Allocation', description: 'How should we allocate the community development budget?', options: [ 'Education Infrastructure', 'Healthcare Facilities', 'Transportation' ], verification: 'worldid', geoRestriction: { country: 'KE', region: 'nairobi' }, duration: 7 * 24 * 60 * 60, // 7 days in seconds wallet: myWallet }); console.log('Poll created on Base:', poll.address);

Casting a Vote

const vote = await votigram.votes.cast({ pollAddress: '0x1234567890123456789012345678901234567890', optionIndex: 0, // Education Infrastructure wallet: voterWallet, verification: { type: 'worldid', proof: worldIdProof } }); if (vote.txHash) { console.log('Vote cast successfully! Transaction:', vote.txHash); // Wait for confirmation await vote.wait(); } else { console.error('Vote failed:', vote.error); }

Getting Results

const pollContract = await votigram.polls.fetch( '0x1234567890123456789012345678901234567890' ); const totalVotes = pollContract.voteCount.reduce((sum, count) => sum + count, 0); console.log('Total votes:', totalVotes); console.log('Options:'); pollContract.options.forEach((option, index) => { const votes = pollContract.voteCount[index]; const percentage = totalVotes > 0 ? (votes / totalVotes * 100).toFixed(2) : 0; console.log(`${option}: ${votes} votes (${percentage}%)`); });

SDKs & Tools

Official SDKs and tools to integrate Votigram into your applications across multiple platforms and programming languages.

Base Contract Integration

VotigramPoll Contract

Deploy polls directly on Base with automatic vote counting and result aggregation using Solidity smart contracts.

// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; contract VotigramPoll { struct Poll { string title; string[] options; uint256[] voteCount; uint256 endTime; address creator; bool active; } mapping(uint256 => Poll) public polls; mapping(uint256 => mapping(address => bool)) public hasVoted; uint256 public pollCount; event PollCreated(uint256 indexed pollId, string title, address creator); event VoteCast(uint256 indexed pollId, uint256 optionIndex, address voter); function createPoll( string memory title, string[] memory options, uint256 duration ) external { require(options.length > 1, "Need at least 2 options"); polls[pollCount] = Poll({ title: title, options: options, voteCount: new uint256[](options.length), endTime: block.timestamp + duration, creator: msg.sender, active: true }); emit PollCreated(pollCount, title, msg.sender); pollCount++; } function castVote(uint256 pollId, uint256 optionIndex) external { require(polls[pollId].active, "Poll not active"); require(block.timestamp < polls[pollId].endTime, "Poll ended"); require(!hasVoted[pollId][msg.sender], "Already voted"); require(optionIndex < polls[pollId].options.length, "Invalid option"); polls[pollId].voteCount[optionIndex]++; hasVoted[pollId][msg.sender] = true; emit VoteCast(pollId, optionIndex, msg.sender); } }

USSD & SMS Integration

Offline Voting

Enable voting through USSD and SMS for users without internet access.

// Handle USSD callback app.post('/ussd', (req, res) => { const { sessionId, phoneNumber, text } = req.body; const response = votigram.ussd.handleSession({ sessionId, phoneNumber, input: text, polls: await votigram.polls.getActive({ region: getRegionFromPhone(phoneNumber) }) }); res.send(response); }); // Handle SMS vote app.post('/sms', (req, res) => { const { from, body } = req.body; const vote = votigram.sms.parseVote(body); if (vote.valid) { await votigram.votes.cast({ pollId: vote.pollId, option: vote.option, phoneNumber: from }); } });

Ready to Build?

Join our developer community and start integrating democratic participation into your applications.

Get API Access View Documentation Join Discord