SDK quickstart
Install the TypeScript SDK, initialize the API client, and cast your first vote. The SDK talks only to the Vocdoni SaaS API - never the blockchain directly.
The TypeScript SDK is the client-side half of an integration: it runs in the voter's browser to authenticate against the Credential Service Provider (CSP), encode the ballot and sign the vote transaction. It talks only to the Vocdoni SaaS API - it never reaches the chain directly. For the server-side lifecycle (organizations, members, censuses, processes and results) use the REST API; see SDKs and tools for when to use each.
This page is the bare minimum to get a client running. For the complete casting flow, see Casting votes.
Two small packages, not one monolith
The SDK ships as tree-shakeable packages that replace the older @vocdoni/sdk:
@vocdoni/api-client (typed HTTP client for the SaaS API) and @vocdoni/api-voting (CSP auth,
ballot encoding and vote signing). The api-client surface is still evolving - check the
SDK repository for the current method names.
Install
Add the two packages with your package manager of choice.
npm install @vocdoni/api-client @vocdoni/api-voting
pnpm add @vocdoni/api-client @vocdoni/api-voting
yarn add @vocdoni/api-client @vocdoni/api-voting
Initialize the client
Create a VocdoniApiClient pointing at the SaaS API. For public voter flows you don't need a token;
pass one only for authenticated (integrator or logged-in user) calls.
import { VocdoniApiClient } from '@vocdoni/api-client'
const client = new VocdoniApiClient({ apiUrl: 'https://saas-api-stg.vocdoni.net' })
The client exposes typed sub-clients for each part of the API - client.processes,
client.organizations, client.elections, client.jobs and client.auth.
Cast a vote
Casting adds @vocdoni/api-voting on top of the client. Every vote follows the same path:
authenticate once against the process census, check the voter's per-question eligibility, get a CSP
signature for that question's election, then build and relay the transaction. This is the condensed
version - Casting votes covers 2FA censuses, encrypted questions
and error handling.
import { VocdoniApiClient } from '@vocdoni/api-client'
import { EphemeralSigner, VotingClient } from '@vocdoni/api-voting'
const client = new VocdoniApiClient({ apiUrl: 'https://saas-api-stg.vocdoni.net' })
const voting = new VotingClient({ client })
// Both reported by the (public) process read.
const processId = '<processId>'
const chainId = '<chainId>'
// 1. Authenticate once against the process census (auth-only census - no 2FA step)
const { authToken } = await client.processes.authStep0(processId, { memberNumber: '42' })
// 2. Check the voter's standing - census membership plus, per question,
// eligibility and that question's on-chain election id (upstreamId)
const { belongsToProcess, questions } = await client.processes.check(processId, { authToken })
const question = questions.find((q) => q.canVote && !q.hasVoted)
if (!belongsToProcess || !question?.upstreamId) throw new Error('Cannot vote')
// 3. Get a CSP signature over a fresh ephemeral address for that question's election
const signer = new EphemeralSigner()
const { signature, weight } = await client.processes.sign(processId, {
authToken,
electionId: question.upstreamId,
payload: signer.address,
})
// 4. Build, relay and poll for the vote nullifier
const jobId = await voting.vote({
processId: question.upstreamId, // the vote goes to the question's election
chainId,
choices: [0],
signer,
cspSignature: signature,
cspWeight: weight,
})
const job = await client.jobs.waitFor(jobId)
console.log('voteID:', job.result?.voteID)
Building with React
@vocdoni/react-providers wraps the client in context providers and hooks that authenticate,
sign and relay for you, and @vocdoni/react-components adds unstyled UI on top. See the
SDK repository for the React packages.
AI agent skills
If you build with an AI coding agent, Vocdoni publishes Agent Skills - focused guides the agent loads on demand so it writes correct Vocdoni code without guessing the API shapes. The ones most relevant to the SDK:
- integrator-sdk - the SaaS-first flow: API client, CSP auth, vote relay, job polling and React providers. Currently in the integrator SDK repo, soon in the marketplace.
- vocdoni-ballot-protocol - how a ballot encodes and how the results matrix aggregates per voting type.
They are packaged as a Claude Code plugin marketplace, and installable via npx for any client that reads a skills directory (Cursor, Cline, Zed and similar):
# Claude Code: add the marketplace, then install integrator-sdk once it lands
claude plugin marketplace add vocdoni/skills
claude plugin install integrator-sdk@vocdoni
# Any skills-directory client
npx @vocdoni/skills install