{"schemaVersion":1,"resourceType":"connector","slug":"us-elections","name":"US elections","catalog":"us_elections","description":"US federal election results, House apportionment, district maps and FEC campaign finance","language":"Python","categories":["civic"],"repository":"https://github.com/Query-farm/vgi-us-elections","license":"0BSD","generatedAt":"2026-12-01T18:22:16+00:00","runtime":{"engineVersion":"2.0.1","protocolVersion":"3.4"},"release":{"tag":"v0.2.0","publishedAt":"2026-11-25T19:39:19Z","url":"https://github.com/Query-farm/vgi-us-elections/releases/tag/v0.2.0"},"links":{"html":"https://query.farm/products/orchard/connectors/us-elections/","llms":"https://query.farm/products/orchard/connectors/us-elections/llms.txt","markdown":"https://query.farm/products/orchard/connectors/us-elections/index.md","json":"https://query.farm/products/orchard/api/v1/connectors/us-elections.json","objects":"https://query.farm/products/orchard/api/v1/connectors/us-elections/objects.json","search":"https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=us-elections&q={query}"},"authentication":{"mode":"optional","guidance":"Election results need no key; the FEC campaign-finance tables need a free api.data.gov key.","interpretation":"Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute(\"CREATE SECRET stripe (TYPE stripe, api_key ?)\", [os.environ[\"STRIPE_API_KEY\"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.","secrets":[{"type":"us_elections_fec","description":"api.data.gov API key for the FEC OpenFEC API (free at https://api.data.gov/signup/).","documentation":"https://github.com/Query-farm/vgi-us-elections#fec-api-key","parameters":[{"name":"api_key","type":"VARCHAR","required":false,"redact":true,"description":"api.data.gov key sent as the api_key query parameter."}],"requiredBy":["fec_candidates","fec_candidate_totals","fec_committees","fec_contributions_by_state"],"createSql":"CREATE SECRET us_elections_fec (\n    TYPE us_elections_fec,\n    api_key '<US_ELECTIONS_FEC_API_KEY>'  -- secret\n);"}]},"deployment":{"local":{"methods":[{"id":"uvx","label":"uvx","icon":"simple-icons:python","steps":[{"title":"Attach with uvx","description":"Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.","lang":"sql","code":"ATTACH 'us_elections' AS us_elections (\n  TYPE vgi,\n  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-us-elections@v0.2.0 vgi-us-elections-worker'\n);"}]},{"id":"docker","label":"Docker","icon":"simple-icons:docker","steps":[{"title":"Attach the signed image","description":"Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.","lang":"sql","code":"ATTACH 'us_elections' AS us_elections (\n  TYPE vgi,\n  LOCATION 'oci://ghcr.io/query-farm/vgi-us-elections:0.2.0'\n);"}]}],"pinnedMethods":[{"id":"uvx","label":"uvx","icon":"simple-icons:python","steps":[{"title":"Attach with uvx","description":"Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.","lang":"sql","code":"ATTACH 'us_elections' AS us_elections (\n  TYPE vgi,\n  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-us-elections@v0.2.0 vgi-us-elections-worker'\n);"}]},{"id":"docker","label":"Docker","icon":"simple-icons:docker","steps":[{"title":"Attach the signed image","description":"Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.","lang":"sql","code":"ATTACH 'us_elections' AS us_elections (\n  TYPE vgi,\n  LOCATION 'oci://ghcr.io/query-farm/vgi-us-elections:0.2.0'\n);"}]}]},"selfHost":{"instructions":"https://github.com/Query-farm/vgi-us-elections","connectionGuide":"https://query.farm/vgi/connect-to-a-worker/","guidance":"Deploy using the connector repository instructions and use its supported HTTP or SSH transport. Replace example URLs with your actual deployment; configure its authentication."},"queryFarm":{"available":true,"console":"https://auth.queryfarm.cloud/console/new?worker=us-elections","organizationMonthlyMinimumUsd":10,"pricing":"https://query.farm/products/orchard/hosted/"},"publicDemo":null},"setup":{"extensions":{"duckdb":"SET allow_extension_repositories = 'allowed';\n\nCREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm\n    WITH PREFIX 'https://duckdb-extensions.query.farm';\n\nINSTALL vgi FROM query_farm;\nLOAD vgi FROM query_farm;","haybarn":"INSTALL vgi FROM community;\nLOAD vgi;"},"attachSql":"ATTACH 'us_elections' AS us_elections (\n  TYPE vgi,\n  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-us-elections@v0.2.0 vgi-us-elections-worker'\n);","attachOptions":[{"name":"cache_dir","type":"VARCHAR","description":"Directory for downloaded upstream files. Default: the per-user cache directory, e.g. ~/Library/Caches/vgi-us-elections or ~/.cache/vgi-us-elections.","required":false,"default":null},{"name":"max_age_days","type":"BIGINT","description":"Re-check Harvard Dataverse for a newer MEDSL release once a cached file is this old.","required":false,"default":"30"},{"name":"offline","type":"BOOLEAN","description":"Never download; use cached files only (fails for anything not cached).","required":false,"default":"false"},{"name":"dataverse_url","type":"VARCHAR","description":"Base URL of the Dataverse installation holding the MEDSL datasets.","required":false,"default":"https://dataverse.harvard.edu"},{"name":"lewis_base_url","type":"VARCHAR","description":"Base URL of the Lewis et al. boundary repository (raw files at the pinned commit).","required":false,"default":"https://raw.githubusercontent.com/JeffreyBLewis/congressional-district-boundaries/3c663a8098b58156601e0893f0e67b502f7f8354"},{"name":"census_cd_base_url","type":"VARCHAR","description":"Base URL of the Census cartographic boundary shapefiles (GENZ2024/shp).","required":false,"default":"https://www2.census.gov/geo/tiger/GENZ2024/shp"},{"name":"fec_base_url","type":"VARCHAR","description":"Base URL of the OpenFEC API.","required":false,"default":"https://api.open.fec.gov/v1"},{"name":"guestbook_name","type":"VARCHAR","description":"Your name, for the Harvard Dataverse guestbook that gates the House and county files.","required":false,"default":null},{"name":"guestbook_email","type":"VARCHAR","description":"Your email, for the Dataverse guestbook.","required":false,"default":null},{"name":"guestbook_institution","type":"VARCHAR","description":"Your institution, for the Dataverse guestbook.","required":false,"default":null},{"name":"guestbook_position","type":"VARCHAR","description":"Your position, for the Dataverse guestbook.","required":false,"default":null},{"name":"dataverse_api_token","type":"VARCHAR","description":"Optional Harvard Dataverse API token, sent with guestbook downloads.","required":false,"default":null}],"note":"Install and load VGI, attach the connector using the catalog alias shown here, then create required secrets. Replace placeholders and omit unused optional secret parameters. Satisfy file, network and credential prerequisites before executing a query."},"example":{"title":"Delaware's at-large district in the 118th Congress","sql":"SELECT congress, state_po, district, start_congress, end_congress FROM us_elections.main.districts(118, state := 'DE') ORDER BY district","requiresCredentials":null,"note":null,"objects":[{"name":"us_elections.main.districts","kind":"table_function","links":{"html":"https://query.farm/products/orchard/connectors/us-elections/#obj-main-districts","markdown":"https://query.farm/products/orchard/connectors/us-elections/objects/table_function.bWFpbg.ZGlzdHJpY3Rz.md","json":"https://query.farm/products/orchard/api/v1/connectors/us-elections/objects/table_function.bWFpbg.ZGlzdHJpY3Rz.json"}}],"evidence":{"status":"captured_result","capturedAt":"2026-12-01T06:24:17+00:00","engineVersion":"2.0.1","protocolVersion":"3.4.0","releaseTag":"v0.2.0","sample":{"columns":["congress","state_po","district","start_congress","end_congress"],"types":["INTEGER","VARCHAR","VARCHAR","INTEGER","INTEGER"],"rows":[[118,"DE","00",115,119]],"more":false}},"artifact":null},"objects":{"total":15,"index":"https://query.farm/products/orchard/api/v1/connectors/us-elections/objects.json","search":"https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=us-elections&q={query}"},"agentTasks":["Using the us_elections worker, what share of Delaware's 2024 presidential vote did the Democratic candidate receive? Give it as a percentage rounded to one decimal place.","Using the us_elections worker, which states gained House seats in the 2020 apportionment, and how many did each gain?","How many US House seats did California have after each census from 1950 through 2020?","Using the us_elections worker, list the 2024 regular general-election US Senate races where the winner's margin over the runner-up was under 2 percentage points.","Using the us_elections worker, which numbered Congress was elected in the November 2022 elections?","Using the us_elections worker, what is Nebraska's two-digit FIPS state code?","Using the us_elections worker, how many congressional districts did Wyoming have in the 100th Congress, and what district code does it use?","Using the us_elections worker, which 119th Congress district has the largest land area? Give its state code and district."],"provenance":{"generatedAt":"2026-12-01T18:22:16+00:00","repository":"https://github.com/Query-farm/vgi-us-elections","harvest":{"status":"ok","method":"subprocess","error":null,"vgi_version":"9773130dde"},"catalogVerification":{"verified":true,"status":"passed","total":7,"passed":7,"failed":0,"needs_credentials":0,"location":"uvx --from git+https://github.com/Query-farm/vgi-us-elections@v0.2.0 vgi-us-elections-worker","transport":"subprocess","environment":{"vgi_extension_version":"9773130dde","haybarn_version":"2.0.1rc3","engine_version":"v2.0.1","python":"3.12.4","platform":"darwin_arm64","protocol_version":"3.4.0"},"checked_at":"2026-12-01T06:21:40+00:00"},"interpretation":"Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."},"interpretation":["Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.","Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.","A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.","Service credentials, external data availability and deployment authentication are separate requirements."]}