Comparing Google Civic API and Cicero API for availability
Tags: api, opensource, tutorial, civictech
Published: 2022-12-22 19:50:59

By [Param Siddharth](https://www.linkedin.com/in/paramsiddharth?miniProfileUrn=urn%3Ali%3Afs_miniProfile%3AACoAAC4hDwMBBWmTXsv695FE_QL8W9jLliSPZ3c&lipi=urn%3Ali%3Apage%3Ad_flagship3_search_srp_all%3BhoTI%2FCIGTNWwEjjxuvEsGw%3D%3D) 

**Roadmap:**

* What is civictech? 
* Comparing Google Civic API or Cicero 
* What was the app structure we’re modifying from 
* Why we chose Cicero 


### Open source is the perfect home for civictech..what is it?

Over the years, an interesting ecosystem is emerging within open source projects - civictech. Whether its your local C4A or universities looking to engage in their communities..the spirit of open source and the space of technology bettering our communal infrastructure are deeply in alignment. 

An example I was hands on via the [MLH Fellows in the ProgramEquity experience](https://github.blog/2022-09-23-meet-the-github-campus-experts-selected-for-the-fall-2022-mlh-fellowship-cohort-powered-by-github/) was the Amplify App which is powering the streamlining of civic engagement data so advocacy groups can accelerate their social impact. 

Like any civictech project, a large element of data gathering is connected to mapping jurisdictions to the correct stakeholders - the feedback loop with public sector organizations. Many APIs offer various degrees of 


#### General comparison of Civic Data APIs 


<table>
  <tr>
   <td>
   </td>
   <td>Cicero
   </td>
   <td>Google Civic
   </td>
   <td>Open States
   </td>
  </tr>
  <tr>
   <td>Cost
   </td>
   <td>$388 for 5000 credits \
($348 for non-profits)
   </td>
   <td>Free
   </td>
   <td>Free
   </td>
  </tr>
  <tr>
   <td>Completeness of representative profiles 
   </td>
   <td>Very complete and comprehensive, social media and photos \
 \
Filtering options
   </td>
   <td>Lacks social media profiles, most photos; Missing contact information \
 \
No unique identifier
   </td>
   <td>Comprehensive information, including photos, several personal details (professions, nicknames)
   </td>
  </tr>
  <tr>
   <td>Queryability 
   </td>
   <td>By address, zip code, and co-ordinates \
 \
Supports `qs` for extended querying
   </td>
   <td>By address, zip code
   </td>
   <td>By co-ordinates
   </td>
  </tr>
  <tr>
   <td>Included Jurisdictions 
   </td>
   <td>Federal, state, and local
   </td>
   <td>Federal, state, and local
   </td>
   <td>State and local
   </td>
  </tr>
  <tr>
   <td>API limitations 
   </td>
   <td>Not free
   </td>
   <td>Lacks photos \
 \
No unique identifiers
<p>
Information is often missing
   </td>
   <td>Can’t query by zip code (geocoding API needed to resolve co-ordinates) \
 \
Daily request limit
   </td>
  </tr>
</table>



### Amplify App Use Case 


![CRUD App](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6humsbka0sr75tm4ftrx.png)


Amplify has a CRUD App structure using multiple APIs. All APIs are part of a codespaces dev container so maintainers are able to contribute directly via a web editor. 

**When considering our decision matrix:**


* Difficulty of API Configuration was less of a concern as we can bypass the need of local setup 
* Focus was on speed of data callback as the app is used in events and other dynamic instances 
* Scope became availability of localized data as our partners continue to focus on civic engagement within municipalities and cities 


#### Choosing Cicero creates a consistent and more local experience 

Its less costly to build with all open source tools - however, we appreciated Cicero having a credits program for nonprofits which allowed us to overcome cost and tap into the following benefits 



* Continuity of maintenance: a completeness of each representative profile allows for a more dependable user experience  
* Had pictures in their datasets 
* Scope: local enough upto school districts


Fetching the data from the Google Civic API in Amplify used to look like:

* We are only passing the zip code and the filter as the query parameters in addition to the key.
* We can’t sort or limit the results.
* We plan to skip the president and vice president from the results. Here, we skip the first two in case of unfiltered results, assuming they will be the president and vice president.

Updated approach using Cicero’s API:
* We are using `qs` for the query parameters. It is a non-standard approach to have more power over customized query parameters. That’s how we’re able to pass arrays into the query parameters.
* We can pass multiple district types as a filter. In the Google Civic API we could only pass one district type in the filter.

For all the responses that we get, we fit them into a certain specific object schema that the front-end expects us the return.

**Here’s now we did while using the Civic API:**

* There’s no guarantee we will have the social media information.
* The e-mail and photo are absent for most cases.
* There’s no unique identifier.

![code snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e2rwlzsecc040rl2tknq.png)




**And here’s how we do it in using the Cicero API:**
* Photos are consistently available.
* We have a unique identifier for each representative (helpful for caching).
* The address is being returned in well-formatted sections from the Cicero API.
* Social media information is more readily available.
![code snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uc0ep8x0ssr5u8327isq.png)




The limitations of the Google Civic API and the lack of consistent information is what led us to move to using the Cicero API for fetching data. We eventually plan to harness the capabilities of the response of the Cicero API for:



* Implementing a caching strategy to avoid spending too many credits.
* Style the images in the perfect fashion using the co-ordinate and dimension information we receive from the API response to configure individual CSS parameters.