swagger: "2.0"
schemes:
  - http
  - https
host: commonsvotes-api.parliament.uk
info:
  contact:
    email: softwareengineering@parliament.uk
    name: UK Parliament
    url: https://www.parliament.uk/
  description: An API that allows querying of Commons Votes data.
  title: Commons Votes API
  version: v1
  x-apisguru-categories:
    - open_data
  x-origin:
    - format: swagger
      url: https://commonsvotes-api.parliament.uk/swagger/docs/v1
      version: "2.0"
  x-providerName: parliament.uk
  x-serviceName: commonsvotes
paths:
  "/data/division/{divisionId}.{format}":
    get:
      consumes: []
      description: Single Division which has the specified Id
      operationId: Divisions_GetDivisionById
      parameters:
        - description: Id number of a Division whose records are to be returned
          format: int32
          in: path
          name: divisionId
          required: true
          type: integer
        - description: xml or json
          in: path
          name: format
          required: true
          type: string
      produces:
        - application/json
        - text/json
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/PublishedDivision"
        "400":
          description: BadRequest
        "404":
          description: NotFound
      summary: Return a Division
      tags:
        - Divisions
  "/data/divisions.{format}/groupedbyparty":
    get:
      consumes: []
      description: Division results which meet the specified criteria grouped by parties
      operationId: Divisions_GetDivisionsGroupsByParty
      parameters:
        - description: xml or json
          in: path
          name: format
          required: true
          type: string
        - description: Divisions containing search term within title or number
          in: query
          name: queryParameters.searchTerm
          required: false
          type: string
        - description: Divisions returning Member with Member ID voting records
          format: int32
          in: query
          name: queryParameters.memberId
          required: false
          type: integer
        - description: Divisions where member was a teller as well as if they actually voted
          in: query
          name: queryParameters.includeWhenMemberWasTeller
          required: false
          type: boolean
        - description: Divisions where division date in one or after date provided. Date format is yyyy-MM-dd
          format: date-time
          in: query
          name: queryParameters.startDate
          required: false
          type: string
        - description: Divisions where division date in one or before date provided. Date format is yyyy-MM-dd
          format: date-time
          in: query
          name: queryParameters.endDate
          required: false
          type: string
        - description: Division Number - as specified by the House, unique within a session. This is different to the division id which uniquely identifies a division in this system and is passed to the GET division endpoint
          format: int32
          in: query
          name: queryParameters.divisionNumber
          required: false
          type: integer
      produces:
        - application/json
        - text/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: "#/definitions/DivisionGroupedByParty"
            type: array
        "400":
          description: BadRequest
      summary: Return Divisions results grouped by party
      tags:
        - Divisions
  "/data/divisions.{format}/membervoting":
    get:
      consumes: []
      description: List of voting records for a member which meet the specified criteria.
      operationId: Divisions_GetVotingRecordsForMember
      parameters:
        - description: xml or json
          in: path
          name: format
          required: true
          type: string
        - description: Id number of a Member whose voting records are to be returned
          format: int32
          in: query
          maximum: 2147483647
          minimum: 1
          name: queryParameters.memberId
          required: true
          type: integer
        - description: The number of records to skip. Default is 0
          format: int32
          in: query
          name: queryParameters.skip
          required: false
          type: integer
        - description: The number of records to return per page. Default is 25
          format: int32
          in: query
          name: queryParameters.take
          required: false
          type: integer
        - description: Divisions containing search term within title or number
          in: query
          name: queryParameters.searchTerm
          required: false
          type: string
        - description: Divisions where member was a teller as well as if they actually voted
          in: query
          name: queryParameters.includeWhenMemberWasTeller
          required: false
          type: boolean
        - description: Divisions where division date in one or after date provided. Date format is yyyy-MM-dd
          format: date-time
          in: query
          name: queryParameters.startDate
          required: false
          type: string
        - description: Divisions where division date in one or before date provided. Date format is yyyy-MM-dd
          format: date-time
          in: query
          name: queryParameters.endDate
          required: false
          type: string
        - description: Division Number - as specified by the House, unique within a session. This is different to the division id which uniquely identifies a division in this system and is passed to the GET division endpoint
          format: int32
          in: query
          name: queryParameters.divisionNumber
          required: false
          type: integer
      produces:
        - application/json
        - text/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: "#/definitions/MemberVotingRecord"
            type: array
        "400":
          description: BadRequest
      summary: Return voting records for a Member
      tags:
        - Divisions
  "/data/divisions.{format}/search":
    get:
      consumes: []
      description: List of Divisions which meet the specified criteria
      operationId: Divisions_SearchDivisions
      parameters:
        - description: json or xml
          in: path
          name: format
          required: true
          type: string
        - description: The number of records to skip. Default is 0
          format: int32
          in: query
          name: queryParameters.skip
          required: false
          type: integer
        - description: The number of records to return per page. Default is 25
          format: int32
          in: query
          name: queryParameters.take
          required: false
          type: integer
        - description: Divisions containing search term within title or number
          in: query
          name: queryParameters.searchTerm
          required: false
          type: string
        - description: Divisions returning Member with Member ID voting records
          format: int32
          in: query
          name: queryParameters.memberId
          required: false
          type: integer
        - description: Divisions where member was a teller as well as if they actually voted
          in: query
          name: queryParameters.includeWhenMemberWasTeller
          required: false
          type: boolean
        - description: Divisions where division date in one or after date provided. Date format is yyyy-MM-dd
          format: date-time
          in: query
          name: queryParameters.startDate
          required: false
          type: string
        - description: Divisions where division date in one or before date provided. Date format is yyyy-MM-dd
          format: date-time
          in: query
          name: queryParameters.endDate
          required: false
          type: string
        - description: Division Number - as specified by the House, unique within a session. This is different to the division id which uniquely identifies a division in this system and is passed to the GET division endpoint
          format: int32
          in: query
          name: queryParameters.divisionNumber
          required: false
          type: integer
      produces:
        - application/json
        - text/json
      responses:
        "200":
          description: OK
          schema:
            items:
              $ref: "#/definitions/PublishedDivision"
            type: array
        "400":
          description: BadRequest
      summary: Return a list of Divisions
      tags:
        - Divisions
  "/data/divisions.{format}/searchTotalResults":
    get:
      consumes: []
      description: Total count of Divisions meeting the specified criteria
      operationId: Divisions_SearchTotalResults
      parameters:
        - description: json or xml
          in: path
          name: format
          required: true
          type: string
        - description: Divisions containing search term within title or number
          in: query
          name: queryParameters.searchTerm
          required: false
          type: string
        - description: Divisions returning Member with Member ID voting records
          format: int32
          in: query
          name: queryParameters.memberId
          required: false
          type: integer
        - description: Divisions where member was a teller as well as if they actually voted
          in: query
          name: queryParameters.includeWhenMemberWasTeller
          required: false
          type: boolean
        - description: Divisions where division date in one or after date provided. Date format is yyyy-MM-dd
          format: date-time
          in: query
          name: queryParameters.startDate
          required: false
          type: string
        - description: Divisions where division date in one or before date provided. Date format is yyyy-MM-dd
          format: date-time
          in: query
          name: queryParameters.endDate
          required: false
          type: string
        - description: Division Number - as specified by the House, unique within a session. This is different to the division id which uniquely identifies a division in this system and is passed to the GET division endpoint
          format: int32
          in: query
          name: queryParameters.divisionNumber
          required: false
          type: integer
      produces:
        - application/json
        - text/json
      responses:
        "200":
          description: OK
          schema:
            format: int32
            type: integer
        "400":
          description: BadRequest
      summary: Return total results count
      tags:
        - Divisions
definitions:
  DivisionGroupedByParty:
    properties:
      AyeCount:
        format: int32
        type: integer
      Ayes:
        description: Counts of all members who voted 'Aye', grouped by party
        items:
          $ref: "#/definitions/PartyVoteResult"
        type: array
      Date:
        format: date-time
        type: string
      DivisionId:
        format: int32
        type: integer
      NoCount:
        format: int32
        type: integer
      Noes:
        description: Counts of all members who voted 'Noe', grouped by party
        items:
          $ref: "#/definitions/PartyVoteResult"
        type: array
      Number:
        format: int32
        type: integer
      Title:
        type: string
    type: object
  MemberSearchQueryParameters:
    properties:
      DivisionNumber:
        description: Division Number - as specified by the House, unique within a session. This is different to the division id which uniquely identifies a division in this system and is passed to the GET division endpoint
        format: int32
        type: integer
      EndDate:
        description: Divisions where division date in one or before date provided. Date format is yyyy-MM-dd
        format: date-time
        type: string
      IncludeWhenMemberWasTeller:
        description: Divisions where member was a teller as well as if they actually voted
        type: boolean
      MemberId:
        description: Id number of a Member whose voting records are to be returned
        format: int32
        maximum: 2147483647
        minimum: 1
        type: integer
      SearchTerm:
        description: Divisions containing search term within title or number
        type: string
      Skip:
        description: The number of records to skip. Default is 0
        format: int32
        type: integer
      StartDate:
        description: Divisions where division date in one or after date provided. Date format is yyyy-MM-dd
        format: date-time
        type: string
      Take:
        description: The number of records to return per page. Default is 25
        format: int32
        type: integer
    required:
      - MemberId
    type: object
  MemberVotingRecord:
    properties:
      MemberId:
        format: int32
        type: integer
      MemberVotedAye:
        type: boolean
      MemberWasTeller:
        type: boolean
      PublishedDivision:
        $ref: "#/definitions/PublishedDivision"
    type: object
  PartyVoteResult:
    properties:
      PartyName:
        type: string
      VoteCount:
        format: int32
        type: integer
    type: object
  PublishedDivision:
    properties:
      AyeCount:
        format: int32
        type: integer
      AyeTellers:
        items:
          $ref: "#/definitions/RecordedMember"
        type: array
      Ayes:
        items:
          $ref: "#/definitions/RecordedMember"
        type: array
      Date:
        format: date-time
        type: string
      DivisionId:
        format: int32
        type: integer
      DoubleMajorityAyeCount:
        format: int32
        type: integer
      DoubleMajorityNoCount:
        format: int32
        type: integer
      EVELCountry:
        type: string
      EVELType:
        type: string
      FriendlyDescription:
        type: string
      FriendlyTitle:
        type: string
      IsDeferred:
        type: boolean
      NoCount:
        format: int32
        type: integer
      NoTellers:
        items:
          $ref: "#/definitions/RecordedMember"
        type: array
      NoVoteRecorded:
        items:
          $ref: "#/definitions/RecordedMember"
        type: array
      Noes:
        items:
          $ref: "#/definitions/RecordedMember"
        type: array
      Number:
        format: int32
        type: integer
      PublicationUpdated:
        format: date-time
        type: string
      RemoteVotingEnd:
        format: date-time
        type: string
      RemoteVotingStart:
        format: date-time
        type: string
      Title:
        type: string
    type: object
  QueryParameters:
    properties:
      DivisionNumber:
        description: Division Number - as specified by the House, unique within a session. This is different to the division id which uniquely identifies a division in this system and is passed to the GET division endpoint
        format: int32
        type: integer
      EndDate:
        description: Divisions where division date in one or before date provided. Date format is yyyy-MM-dd
        format: date-time
        type: string
      IncludeWhenMemberWasTeller:
        description: Divisions where member was a teller as well as if they actually voted
        type: boolean
      MemberId:
        description: Divisions returning Member with Member ID voting records
        format: int32
        type: integer
      SearchTerm:
        description: Divisions containing search term within title or number
        type: string
      StartDate:
        description: Divisions where division date in one or after date provided. Date format is yyyy-MM-dd
        format: date-time
        type: string
    type: object
  RecordedMember:
    properties:
      ListAs:
        type: string
      MemberFrom:
        type: string
      MemberId:
        format: int32
        type: integer
      Name:
        type: string
      Party:
        type: string
      PartyAbbreviation:
        type: string
      PartyColour:
        type: string
      ProxyName:
        type: string
      SubParty:
        type: string
    type: object
  SearchQueryParameters:
    properties:
      DivisionNumber:
        description: Division Number - as specified by the House, unique within a session. This is different to the division id which uniquely identifies a division in this system and is passed to the GET division endpoint
        format: int32
        type: integer
      EndDate:
        description: Divisions where division date in one or before date provided. Date format is yyyy-MM-dd
        format: date-time
        type: string
      IncludeWhenMemberWasTeller:
        description: Divisions where member was a teller as well as if they actually voted
        type: boolean
      MemberId:
        description: Divisions returning Member with Member ID voting records
        format: int32
        type: integer
      SearchTerm:
        description: Divisions containing search term within title or number
        type: string
      Skip:
        description: The number of records to skip. Default is 0
        format: int32
        type: integer
      StartDate:
        description: Divisions where division date in one or after date provided. Date format is yyyy-MM-dd
        format: date-time
        type: string
      Take:
        description: The number of records to return per page. Default is 25
        format: int32
        type: integer
    type: object
