SimpleFunctions
TECHNICALS/GUIDE·3 min read

Querying Congressional Legislation Data with the SF API

How to search bills, cross-reference prediction markets, and look up Congress members — three endpoints, no API key required.

By Patrick LiuApril 14, 2026

SimpleFunctions exposes three public endpoints for congressional data. No API key required. All data comes from Congress.gov, cross-referenced against our legislation_market_pairs table (143 bill and nomination matches on Kalshi).

1. Legislation Search

# Default: recent bills from 119th Congress
curl https://simplefunctions.dev/api/public/legislation

# Search by keyword
curl https://simplefunctions.dev/api/public/legislation?q=SAVE+Act

# Only bills with prediction markets
curl https://simplefunctions.dev/api/public/legislation?hasMarket=true

# Pagination
curl https://simplefunctions.dev/api/public/legislation?limit=20&offset=40

The hasMarket=true flag switches the data source. Without it, the endpoint queries Congress.gov in real time and enriches results with market cross-references. With it, the endpoint reads directly from our legislation_market_pairs table — faster, but limited to bills we have already matched.

Response shape:

{
  "bills": [
    {
      "id": "119-hr-22",
      "congress": 119,
      "type": "hr",
      "number": 22,
      "title": "SAVE Act",
      "policyArea": "Government Operations and Politics",
      "latestAction": {
        "actionDate": "2025-02-11",
        "text": "Received in the Senate."
      },
      "hasMarket": true,
      "market": {
        "ticker": "KXSAVEACT-27-JAN04",
        "title": "Will SAVE Act become law before Jan 4, 2027?",
        "venue": "kalshi"
      }
    }
  ],
  "pagination": { "total": 250, "limit": 20, "offset": 0 },
  "meta": { "source": "congress.gov", "latencyMs": 340 }
}

The market field is null for bills without a matched prediction market contract.

2. Congress Members

# List members (default: 50)
curl https://simplefunctions.dev/api/public/congress/members

# Filter by state
curl https://simplefunctions.dev/api/public/congress/members?state=TX

# Current members only
curl https://simplefunctions.dev/api/public/congress/members?currentMember=true

# Pagination
curl https://simplefunctions.dev/api/public/congress/members?limit=100&offset=0

Response includes bioguide ID, name, party, state, chamber, and photo URL.

3. Member Detail

# By bioguide ID
curl https://simplefunctions.dev/api/public/congress/member/R000614

This endpoint does a parallel fan-out:

  1. Fetches member bio, terms, and party history from Congress.gov
  2. Fetches their sponsored legislation (up to 20 bills)
  3. Searches our database for election/nomination markets mentioning this member

The electionMarkets array in the response links the member to any Kalshi contracts about their elections or confirmations. This uses a word-boundary regex match on the member's last name to avoid false positives ("Roy" will not match "McIlroy").

Response shape (abbreviated):

{
  "member": {
    "bioguideId": "R000614",
    "name": "Chip Roy",
    "party": "Republican",
    "state": "TX",
    "chamber": "House of Representatives",
    "terms": [{ "chamber": "House", "startYear": 2019 }]
  },
  "electionMarkets": [
    { "ticker": "KXSENATECONFIRM-...", "title": "...", "venue": "kalshi" }
  ],
  "sponsoredBills": [
    {
      "id": "119-hr-123",
      "title": "...",
      "latestAction": { "actionDate": "...", "text": "..." }
    }
  ]
}

4. Combining with Other SF Endpoints

The legislation data becomes more useful when combined with market indicators:

# Get the bill's prediction market price + indicators
sf inspect KXSAVEACT-27-JAN04

# Or via API
curl https://simplefunctions.dev/api/public/market/KXSAVEACT-27-JAN04

# Search for related markets
sf query "SAVE Act prediction market"

The sf inspect command returns the full dossier: current price, orderbook depth, implied yield, regime label, and a machine-generated trading suggestion. Cross-referencing this with the bill's legislative status from /api/public/legislation gives you both the political context and the market context in two API calls.

Caching and Freshness

Legislation endpoints cache for 1 hour server-side with 2-hour stale-while-revalidate. Member endpoints cache for 24 hours. Our cron job refreshes bill status weekly by re-querying Congress.gov for every tracked bill.

For real-time market prices on legislation contracts, use the market endpoints (/api/public/market/{ticker}) which update every 15 minutes.

legislationcongressAPItutorialprediction markets