congress-api-docs icon indicating copy to clipboard operation
congress-api-docs copied to clipboard

Vote API has inconsistent types for "results" and "votes"

Open konklone opened this issue 8 years ago • 2 comments

Generally, the top-level results field on API responses is an array, even on endpoints where the goal is fetching one specific object (like a bill).

However, on the endpoint for fetching specific votes, the results field is an object and not an array:

{
   "status":"OK",
   "copyright":"Copyright (c) 2017 Pro Publica Inc. All Rights Reserved.",
   "results": {
      "votes": {
        "vote": {

The API should consistently have results be either an array or an object. An array seems like the logical choice.

konklone avatar Aug 05 '17 18:08 konklone

I'm renaming this to focus on the broader inconsistency in the API endpoints around voting.

The results field and the votes field are both inconsistently set as objects or arrays, and in the case of votes by date, it lists members instead of votes.

Votes by date are basically listing a separate kind of object than the other vote endpoints. But even within the other 3 endpoints, this inconsistency makes client code error-prone and requires a lot of custom parsing code.

Fetching a specific vote:

{
    "status": "OK",
    "copyright": "Copyright (c) 2017 Pro Publica Inc. All Rights Reserved.",
    "results": {
        "votes": {
            "vote": {
                "congress": "115",

Votes by type:

{
    "status": "OK",
    "copyright": "Copyright (c) 2017 Pro Publica Inc. All Rights Reserved.",
    "results": [{
        "congress": "114",
        "chamber": "House",
        "num_results": "450",
        "offset": "0",
        "members": [{
                "id": "B000589",

Votes by date:

{
    "status": "OK",
    "copyright": "Copyright (c) 2017 Pro Publica Inc. All Rights Reserved.",
    "results": {
        "chamber": "Senate",
        "year": "2017",
        "month": "Jan.",
        "num_results": "35",
        "votes": [{
            "congress": "115"

Senate nomination votes:

{
  "status": "OK",
  "copyright": "Copyright (c) 2016 Pro Publica Inc. All Rights Reserved.",
  "results": [
    {
      "total_votes": "37",
      "offset": "0",
      "votes": [
        {
          "congress": "114",
          "session": "2",

konklone avatar Aug 05 '17 18:08 konklone

I'll also note the member position list, which has a nearly-identical but also-different hierarchy:

{
    "status": "OK",
    "copyright": "Copyright (c) 2017 Pro Publica Inc. All Rights Reserved.",
    "results": [{
        "member_id": "K000388",
        "total_votes": "100",
        "offset": "0",
        "votes": [{
            "member_id": "K000388",

konklone avatar Aug 05 '17 20:08 konklone