@maxim_mazurok/gapi.client.civicinfo

TypeScript typings for Google Civic Information API v2

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@maxim_mazurok/gapi.client.civicinfo
35152.0.202208092 months ago2 years agoMinified + gzip package size for @maxim_mazurok/gapi.client.civicinfo in KB

Readme

TypeScript typings for Google Civic Information API v2
Provides polling places, early vote locations, contest data, election officials, and government representatives for U.S. residential addresses. For detailed description please check documentation.

Installing

Install typings for Google Civic Information API:
npm install @types/gapi.client.civicinfo@v2 --save-dev

Usage

You need to initialize Google API client in your code:
gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:
gapi.client.load('civicinfo', 'v2', () => {
  // now we can use gapi.client.civicinfo
  // ...
});

After that you can use Google Civic Information API resources:
/*
Searches for political divisions by their natural name or OCD ID.
*/
await gapi.client.civicinfo.divisions.search({  });

/*
List of available elections to query.
*/
await gapi.client.civicinfo.elections.electionQuery({  });

/*
Looks up information relevant to a voter based on the voter's registered address.
*/
await gapi.client.civicinfo.elections.voterInfoQuery({ address: "address",  });

/*
Looks up political geography and representative information for a single address.
*/
await gapi.client.civicinfo.representatives.representativeInfoByAddress({  });

/*
Looks up representative information for a single geographic division.
*/
await gapi.client.civicinfo.representatives.representativeInfoByDivision({ ocdId: "ocdId",  });