Incorrect API response for representativeInfoByDivision

108 views
Skip to first unread message

Josh Evans

unread,
Aug 16, 2016, 6:31:43 PM8/16/16
to Google Civic Information API
Hitting the representativeInfoByDivision endpoint with ocdId "ocd-division/country:us/state:ak/cd:1", I get back an empty hash with status code 200 OK. This also applies for many other ocdIds, such as "ocd-division/country:us/state:az/sldl:1" and all other Arizona sldl divisions. I would expect the data returned to be consistent with other ocdIds (i.e., a Representatives Resource) instead of being an empty hash. 

Jason Rosenbaum

unread,
Aug 16, 2016, 6:33:15 PM8/16/16
to google-civ...@googlegroups.com
Alaska has no congressional districts (just an at-large district) so that congressperson is returned on ocd-division/country:us/state:ak since it's a statewide office. Arizona has no lower level legislative districts, rather it has multi-member districts based on Senate districts, so all info is returned in sldu calls, not sldl.


_________________________________
Jason Rosenbaum
Director of Technology
The Action Network

Email/GChat: ja...@actionnetwork.org
Cell: 914.806.1939



On Aug 16, 2016, at 3:31 PM, Josh Evans <josh....@brigade.com> wrote:

Hitting the representativeInfoByDivision endpoint with ocdId "ocd-division/country:us/state:ak/cd:1", I get back an empty hash with status code 200 OK. This also applies for many other ocdIds, such as "ocd-division/country:us/state:az/sldl:1" and all other Arizona sldl divisions. I would expect the data returned to be consistent with other ocdIds (i.e., a Representatives Resource) instead of being an empty hash. 

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh Evans

unread,
Aug 16, 2016, 6:50:22 PM8/16/16
to Google Civic Information API
Hi Jason,

While I understand that Alaska's congressional district division may be an alias for the state division, there still is an issue with the API. The documentation clearly states: "If successful, this method returns a Representatives resource in the response body." The endpoint returned a 200OK (success) with no Representatives resource in the response body (it just gives an empty hash). Therefore either the API or the documentation is incorrect. It would make sense to me that in the case of aliases roughly the same data should be returned no matter which alias the data is accessed from. 

Thanks for your help,

Josh
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

Jason Rosenbaum

unread,
Aug 16, 2016, 6:51:36 PM8/16/16
to google-civ...@googlegroups.com
Agree there, 404 would probably be a better response.



_________________________________
Jason Rosenbaum
Director of Technology
The Action Network

Email/GChat: ja...@actionnetwork.org
Cell: 914.806.1939



To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.

Tom Dooner

unread,
Aug 16, 2016, 8:26:03 PM8/16/16
to google-civ...@googlegroups.com
Is there a reason that OCDID aliases are treated the same as invalid OCDIDs?

I could see an argument that ocd-division/country:us/state:ak/cd:1 is semantically incorrect. However, whether or not it is proper to use "cd:1" (or for many OCDIDs "sldl:1" instead of "sldu:1"), it would be more useful if the API knew about the aliases and would return a helpful response, such as:

{
"divisions": {
"ocd-division/country:us/state:ak/cd:1": {
"name": "Alaska",
"alsoKnownAs": [
"ocd-division/country:us/state:ak"
],
"officeIndices": [ 0, 1, 2, 3 ]
},
"offices": [ ... ],
"officials": [ ... ],
}

i.e. the same response, but for the aliased OCDID.

The use-case would be that occasionally it's helpful to iterate through OCDIDs in a structured way. For example if you download some CSV that tells you how many congressional districts each state
has, you could make API queries easily with just string interpolation: "ocd-division/country:us/state:" + state + "/cd:" + i
Cheers,
Tom



To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Rosenbaum

unread,
Aug 16, 2016, 8:28:26 PM8/16/16
to google-civ...@googlegroups.com
Folks from google would have to answer that one. All I know is we don't rely on aliases because as you've noted, they're not really useful.

It's not particularly hard to come up with a list of all available CDs (or leg districts). You start with the machine iteration then you make hand edits for some places. There aren't many in the country. Here's ours for state level (state leg, both houses), for example: https://github.com/j-ro/congress-forms-data/blob/master/ocdids_statelevel.csv


_________________________________
Jason Rosenbaum
Director of Technology
The Action Network

Email/GChat: ja...@actionnetwork.org
Cell: 914.806.1939



Chetan Sabnis

unread,
Aug 17, 2016, 9:55:37 AM8/17/16
to Google Civic Information API
Thanks for reporting this.  We'll look into providing a response for OCD ID aliases.  It is very reasonable to want to query by a non-canonical OCD ID.

To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

Tom Dooner

unread,
Aug 17, 2016, 3:11:43 PM8/17/16
to Google Civic Information API
Thanks, Chetan and Jason!

This is somewhat off-topic, but: You say "non-canonical OCD ID". Is that an actual thing?

Is there some way to tell that given two OCDID aliases, say ocd-division/country:us/state:ca/place:san_francisco and ocd-division/country:us/state:ca/county:san_francisco, that one or the other is "canonical"?

Intuitively, it seems like the canonical-ness ("canon"?) depends on your use-case -- if you are looking to display a set of counties then the "county:san_francisco" one is canonical; if you are looking to display a set of census places, then "place:san_francisco" is canonical.

Tom

To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo...@googlegroups.com.

Chetan Sabnis

unread,
Aug 17, 2016, 4:13:30 PM8/17/16
to Google Civic Information API
Yes, there is always a canonical OCD ID in that there is one OCD ID that doesn't have any aliases.  You can't have OCD ID A be an alias for OCD ID B and vice versa.  It is a directed acyclic graph.

There is a very long thread about the what led to the creation of OCD ID aliases here: https://groups.google.com/d/msg/open-civic-data/G70l60xqO3A/3e4pN5Zxx5UJ

On Wed, Aug 17, 2016 at 3:11 PM, Tom Dooner <tom.d...@brigade.com> wrote:
Thanks, Chetan and Jason!

This is somewhat off-topic, but: You say "non-canonical OCD ID". Is that an actual thing?

Is there some way to tell that given two OCDID aliases, say ocd-division/country:us/state:ca/place:san_francisco and ocd-division/country:us/state:ca/county:san_francisco, that one or the other is "canonical"?

Intuitively, it seems like the canonical-ness ("canon"?) depends on your use-case -- if you are looking to display a set of counties then the "county:san_francisco" one is canonical; if you are looking to display a set of census places, then "place:san_francisco" is canonical.

Tom
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsub...@googlegroups.com.

Chetan Sabnis

unread,
Aug 25, 2016, 7:15:36 PM8/25/16
to Google Civic Information API
Note:  We have pushed a fix for this issue that now allows you to query non-canonical OCD IDs in the representativesByDivision query.  It has been updated to return a 404 for OCD IDs that cannot be found (but can be parsed). 

Let us know what you think!

To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Civic Information API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-civicinfo-api+unsubscrib...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages