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', () => {
});
Then load api client wrapper:
gapi.client.load(
'https://civicinfo.googleapis.com/$discovery/rest?version=v2',
() => {
}
);
gapi.client.load('civicinfo', 'v2', () => {
});
After that you can use Google Civic Information API resources:
await gapi.client.civicinfo.divisions.search({});
await gapi.client.civicinfo.elections.electionQuery({});
await gapi.client.civicinfo.elections.voterInfoQuery({address: 'address'});
await gapi.client.civicinfo.representatives.representativeInfoByAddress({});
await gapi.client.civicinfo.representatives.representativeInfoByDivision({
ocdId: 'ocdId',
});