Search

Search bills, members, committees and pages...

API

The API request that returns the numbers on the page, ready to copy and try.

curl https://gov.nysgpt.com/api/policy/bills?state=US&limit=5

On the site it lives at /home. Open it on the canvas, where it can be sized, coloured and rearranged with the rest.

Installation

pnpm dlx shadcn@latest add @44gov/api

Or copy the source into your project and update the import paths to match it.

components/cards/api.tsx
"use client" import Link from "next/link" import * as F from "@/lib/fixtures"import { useJurisdiction } from "@/lib/policy/jurisdiction"import { CardFrame, ComponentActions } from "@/components/card-frame"import { CopyButton } from "@/components/copy-button"import { CardAnchor } from "@/components/admin/blocks/card-tools"import { Button } from "@govblock/ui/components/button"import { CardAction, CardContent, CardHeader, CardTitle } from "@govblock/ui/components/card"import { CardFoot } from "@/components/card-foot" // API — the same numbers this page renders, as JSON, for the scope in the// header. The card is the documentation: the URL it shows is meant to be live.export function ApiCard() {  const { state } = useJurisdiction()  const path = `/api/policy/bills?state=${state}&limit=5`  const command = `curl https://gov.nysgpt.com${path}`  return (    <CardFrame id="api">      <CardHeader>        <CardAnchor>API</CardAnchor>        <CardAction>          <ComponentActions />        </CardAction>      </CardHeader>      <CardContent>        <div className="relative rounded-lg bg-muted p-3 pr-10 font-mono text-xs break-all">          {command}          <CopyButton value={command} className="absolute top-2 right-2" variant="ghost" />        </div>      </CardContent>      <CardFoot href="/docs/api" label="The API">        <Button size="sm" nativeButton={false} render={<Link href={path} target="_blank" />}>          Try it        </Button>      </CardFoot>    </CardFrame>  )} 

Usage

import { ApiCard } from "@/components/cards/api"
<ApiCard />

Composition

The parts the block is built from, in the order they appear.

ApiCard├── CardHeader├── CardAction└── CardContent

Data

The block reads no route of its own. What it shows comes from the page that holds it.

API Reference

ApiCard takes no props. It reads the jurisdiction and year from the page.