Getting Started
Get up and running with Senra IO API in 5 minutes
Overview
The Senra IO API provides programmatic access to UK Parliament bill predictions, including Royal Assent probability, next stage timing, and next stage ETA estimates. Get started in 5 simple steps.
API Access: Available for Pilot and Pro subscribers. Free tier users can explore predictions on the website.
Step 1: Create an Account
Sign up for a free account to get started. You'll need to verify your email address.
After signup, check your email and click the verification link.
Step 2: Get Your API Key
API keys are available for Pilot and Pro subscribers. Once you have a subscription:
- Navigate to Dashboard → API Keys
- Click "Create API Key"
- Give it a name (e.g., "Production", "Development")
- Copy the key immediately - you won't be able to see it again!
sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSecurity: Keep your API key secret. Never commit it to version control or share it publicly.
Step 3: Make Your First API Request
Test your API key by getting predictions for a bill. Here's a simple example using cURL:
curl -X GET "https://api.senraio.com/api/v1/predict/12345" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json"
{
"bill_id": "12345",
"mode": "nowcast",
"reference_date": "2025-12-18",
"predictions": {
"royal_assent": {
"probability": 0.87
},
"next_stage_30d": {
"probability": 0.92
},
"timeline_eta": {
"days": 14.5
},
"stall_risk": {
"probability": 0.15
},
"amendment_risk": {
"probability": 0.32
},
"close_vote": {
"probability": 0.28
},
"withdrawal_risk": {
"probability": 0.08
}
},
"risk_indicators": {
"controversy_score": 0.45,
"momentum_score": 0.72,
"stall_risk_level": "low",
"withdrawal_risk_level": "low"
}
}New: Risk Prediction Models
The API response now includes 4 risk prediction models: Stall Risk (predicts bills that may stall >200 days), Amendment Risk (predicts significant amendments), Close Vote (predicts contentious votes <10% margin), and Withdrawal Risk (predicts bills likely to be withdrawn). Risk indicators provide additional context with controversy and momentum scores. These help identify bills at risk before problems occur.
Step 4: Python Integration Example
Here's a complete Python example to get you started:
import requests
# Your API key from dashboard
API_KEY = "sk_live_your_api_key_here"
BASE_URL = "https://api.senraio.com/api/v1"
# Get predictions for a bill
bill_id = 12345
response = requests.get(
f"{BASE_URL}/predict/{bill_id}",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
)
if response.status_code == 200:
prediction = response.json()
print(f"Royal Assent Probability: {prediction['royal_assent_probability']:.1%}")
print(f"Next Stage (30d): {prediction['next_stage_30d_probability']:.1%}")
print(f"Timeline ETA: {prediction['timeline_eta_days']:.1f} days")
else:
print(f"Error: {response.status_code} - {response.text}")Step 5: Set Up Predictive Alerts (Pilot+)
Get notified before bills change. Set up alerts to monitor bills you care about.
curl -X POST "https://api.senraio.com/api/v1/predictions/alerts/thresholds" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"watchlist_id": 1,
"alert_type": "timeline_eta",
"threshold_value": 7.0,
"comparison": "less_than"
}'This creates an alert that triggers when any bill in watchlist #1 is predicted to progress within 7 days. See the Predictive Alerts guide for more details.
Risk-Based Alerts:
You can also create alerts based on risk predictions. For example, alert when stall_risk exceeds 70% or withdrawal_risk exceeds 40%. See the Predictive Alerts guide for risk alert examples.
Batch Predictions (Pilot+)
Get predictions for up to 100 bills in a single request. Batch predictions include all risk predictions and risk indicators, making it easy to analyze multiple bills at once.
curl -X POST "https://api.senraio.com/api/v1/predictions/batch" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"bill_ids": [12345, 12346, 12347],
"reference_date": "2025-12-18"
}'Risk Predictions in Batch:
Each result in the batch response includes all 4 risk predictions (stall_risk,amendment_risk, close_vote,withdrawal_risk) and risk_indicatorsfor comprehensive risk analysis. See the API Reference for the complete response structure.
Next Steps
Need API Access?
API access is available for Pilot (£500, 30 days) and Pro (£1,500/month) subscribers.