Skip to main content
CivicGate

API keys

An API key lets CivicGate widgets and the JavaScript SDK run on your site, reading data as your CivicGate account. Create and manage keys at Account → API keys.

What a key can and can't do

Stated plainly, because you may end up pasting one into a public web page:

Create a key

  1. Go to Account → API keys.
  2. Give it a name that says where it will live ("my blog's sidebar").
  3. Optionally list the origins allowed to use it — e.g. https://example.com, or .example.com to include subdomains.
  4. Copy the key immediately. It is not shown again.

Use it — the widget bundle

Configure once; every CivicGate widget on the page picks it up.

<script src="https://www.civicgate.org/widget/civicgate-widget.js"></script>
<script>CivicGate.configure({ apiKey: "cg_live_…" })</script>

<!-- Your Following feed -->
<div data-civicgate-widget="feed" data-limit="10"></div>

<!-- One subject's public activity (no key needed) -->
<div data-civicgate-widget="subject" data-subject-type="bill" data-subject-id="hr-22-119"></div>

Use it — the iframe

No script at all. The key travels in the URL, so only use this on a page you control.

<iframe src="https://www.civicgate.org/embed/feed?key=cg_live_…&limit=10"
        width="100%" height="520" style="border:0" loading="lazy"
        title="CivicGate feed"></iframe>

Use it — the SDK

The same client the widgets use, for your own UI.

import { createClient, createFeedStore } from "@cg/sdk";

const cg = createClient({ apiKey: "cg_live_…" });

// One page of your feed, filtered and cursor-paged
const page = await cg.feed({ subjectGroups: ["bills", "people"], limit: 10 });
page.events.forEach(e => console.log(e.title, e.occurredAt));

// Or a self-refreshing store (instant paint, background refresh every ~12s)
const store = createFeedStore(cg, { refreshMs: 12000 });
store.subscribe(state => render(state.events));
store.start();

Filter vocabulary — subject types, event types, and groups — is discoverable via cg.catalog(), so you never hard-code a type string. Full field reference: API reference.

Limits