Embed Ballot Measures on Your Site
A lightweight, embeddable widget that displays live ballot measure data. Free for election offices, newsrooms, and civic organizations.
Live Demo
Below is a live preview of the widget for California. The widget loads data directly from the Ballot Explorer API.
Quick Start
Add a single script tag anywhere in your HTML. The widget renders automatically next to the script element.
Embed Code
<script src="https://ballotexplorer.org/widget.js" data-state="CA"></script>Replace CA with any two-letter US state code.
Customization
State
Set the data-state attribute to any two-letter US state code (e.g., CA, OR, WA).
Theme
Add data-theme="dark" for dark mode. Defaults to light theme.
<script src="https://ballotexplorer.org/widget.js" data-state="CA" data-theme="dark"></script>API Reference
The widget fetches data from a public JSON API. You can also use this API directly.
GET /api/widget?state=CA
| Parameter | Type | Description |
|---|---|---|
state | string | Required. Two-letter US state code. |
limit | number | Optional. Max results (1-50, default 10). |
Example Response
{
"state": "CA",
"measures": [
{
"id": "abc-123",
"measure_code": "Prop 1",
"official_title": "Infrastructure Bond Act",
"status": "on_ballot",
"url": "https://ballotexplorer.org/measure/abc-123"
}
]
}CORS & Security
- The widget API sets
Access-Control-Allow-Origin: *so it can be loaded from any domain. - Responses are cached for 1 hour (
Cache-Control: public, max-age=3600). - The API is read-only and requires no authentication. No cookies or user data are collected.
- The widget script is lightweight vanilla JavaScript with no external dependencies.
- All links open in a new tab with
rel="noopener"for security.