openapi: 3.0.1
info:
  contact:
    email: softwareengineering@parliament.uk
    name: UK Parliament
    url: https://www.parliament.uk/
  description: Data around written questions and answers, as well as written ministerial statements.
  title: Written Questions Service API
  version: v1
  x-apisguru-categories:
    - open_data
  x-origin:
    - format: openapi
      url: https://writtenquestions-api.parliament.uk/swagger/v1/swagger.json
      version: "3.0"
  x-providerName: parliament.uk
  x-serviceName: writtenquestions
paths:
  /api/dailyreports/dailyreports:
    get:
      parameters:
        - description: Daily report with report date on or after the date specified. Date format yyyy-mm-dd
          in: query
          name: dateFrom
          schema:
            description: Daily report with report date on or after the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Daily report with report date on or before the date specified. Date format yyyy-mm-dd
          in: query
          name: dateTo
          schema:
            description: Daily report with report date on or before the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Daily report relating to the House specified. Defaults to Bicameral
          in: query
          name: house
          schema:
            $ref: "#/components/schemas/HouseEnum"
        - description: Number of records to skip, default is 0
          in: query
          name: skip
          schema:
            description: Number of records to skip, default is 0
            format: int32
            maximum: 2147483647
            minimum: 0
            nullable: true
            type: integer
        - description: Number of records to take, default is 20
          in: query
          name: take
          schema:
            description: Number of records to take, default is 20
            format: int32
            maximum: 2147483647
            minimum: 0
            nullable: true
            type: integer
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DailyReportViewModelSearchResult"
            text/json:
              schema:
                $ref: "#/components/schemas/DailyReportViewModelSearchResult"
            text/plain:
              schema:
                $ref: "#/components/schemas/DailyReportViewModelSearchResult"
          description: Success
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Bad Request
      summary: Returns a list of daily reports
      tags:
        - DailyReports
  /api/writtenquestions/questions:
    get:
      parameters:
        - description: Written questions asked by member with member ID specified
          in: query
          name: askingMemberId
          schema:
            description: Written questions asked by member with member ID specified
            format: int32
            maximum: 2147483647
            minimum: 1
            nullable: true
            type: integer
        - description: Written questions answered by member with member ID specified
          in: query
          name: answeringMemberId
          schema:
            description: Written questions answered by member with member ID specified
            format: int32
            maximum: 2147483647
            minimum: 1
            nullable: true
            type: integer
        - description: Written questions tabled on or after the date specified. Date format yyyy-mm-dd
          in: query
          name: tabledWhenFrom
          schema:
            description: Written questions tabled on or after the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Written questions tabled on or before the date specified. Date format yyyy-mm-dd
          in: query
          name: tabledWhenTo
          schema:
            description: Written questions tabled on or before the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Written questions that have been answered, unanswered or either.
          in: query
          name: answered
          schema:
            $ref: "#/components/schemas/Answered"
        - description: Written questions answered on or after the date specified. Date format yyyy-mm-dd
          in: query
          name: answeredWhenFrom
          schema:
            description: Written questions answered on or after the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Written questions answered on or before the date specified. Date format yyyy-mm-dd
          in: query
          name: answeredWhenTo
          schema:
            description: Written questions answered on or before the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Written questions with the status specified
          in: query
          name: questionStatus
          schema:
            $ref: "#/components/schemas/QuestionStatusEnum"
        - description: Include written questions that have been withdrawn
          in: query
          name: includeWithdrawn
          schema:
            description: Include written questions that have been withdrawn
            type: boolean
        - description: Expand the details of Members in the results
          in: query
          name: expandMember
          schema:
            description: Expand the details of Members in the results
            type: boolean
        - description: Written questions corrected on or after the date specified. Date format yyyy-mm-dd
          in: query
          name: correctedWhenFrom
          schema:
            description: Written questions corrected on or after the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Written questions corrected on or before the date specified. Date format yyyy-mm-dd
          in: query
          name: correctedWhenTo
          schema:
            description: Written questions corrected on or before the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Written questions / statements containing the search term specified, searches item content
          in: query
          name: searchTerm
          schema:
            description: Written questions / statements containing the search term specified, searches item content
            nullable: true
            type: string
        - description: Written questions / statements with the uin specified
          in: query
          name: uIN
          schema:
            description: Written questions / statements with the uin specified
            nullable: true
            type: string
        - description: Written questions / statements relating to the answering bodies with the IDs specified
          in: query
          name: answeringBodies
          schema:
            description: Written questions / statements relating to the answering bodies with the IDs specified
            items:
              format: int32
              type: integer
            nullable: true
            type: array
        - description: Written questions / statements relating to the members with the IDs specified
          in: query
          name: members
          schema:
            description: Written questions / statements relating to the members with the IDs specified
            items:
              format: int32
              type: integer
            nullable: true
            type: array
        - description: Written questions / statements relating to the House specified
          in: query
          name: house
          schema:
            $ref: "#/components/schemas/HouseEnum"
        - description: Number of records to skip, default is 0
          in: query
          name: skip
          schema:
            description: Number of records to skip, default is 0
            format: int32
            maximum: 2147483647
            minimum: 0
            nullable: true
            type: integer
        - description: Number of records to take, default is 20
          in: query
          name: take
          schema:
            description: Number of records to take, default is 20
            format: int32
            maximum: 2147483647
            minimum: 0
            nullable: true
            type: integer
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/QuestionsViewModelSearchResult"
            text/json:
              schema:
                $ref: "#/components/schemas/QuestionsViewModelSearchResult"
            text/plain:
              schema:
                $ref: "#/components/schemas/QuestionsViewModelSearchResult"
          description: Success
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Bad Request
      summary: Returns a list of written questions
      tags:
        - WrittenQuestions
  "/api/writtenquestions/questions/{date}/{uin}":
    get:
      parameters:
        - description: Written question on date specified
          in: path
          name: date
          required: true
          schema:
            description: Written question on date specified
            format: date-time
            type: string
        - description: Written question with uid specified
          in: path
          name: uin
          required: true
          schema:
            description: Written question with uid specified
            nullable: true
            type: string
        - description: Expand the details of Members in the results
          in: query
          name: expandMember
          schema:
            description: Expand the details of Members in the results
            type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/QuestionsViewModelItem"
            text/json:
              schema:
                $ref: "#/components/schemas/QuestionsViewModelItem"
            text/plain:
              schema:
                $ref: "#/components/schemas/QuestionsViewModelItem"
          description: Success
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Bad Request
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Not Found
      summary: Returns a written question
      tags:
        - WrittenQuestions
  "/api/writtenquestions/questions/{id}":
    get:
      parameters:
        - description: written question with ID specified
          in: path
          name: id
          required: true
          schema:
            description: written question with ID specified
            format: int32
            type: integer
        - description: Expand the details of Members in the result
          in: query
          name: expandMember
          schema:
            description: Expand the details of Members in the result
            type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/QuestionsViewModelItem"
            text/json:
              schema:
                $ref: "#/components/schemas/QuestionsViewModelItem"
            text/plain:
              schema:
                $ref: "#/components/schemas/QuestionsViewModelItem"
          description: Success
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Bad Request
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Not Found
      summary: Returns a written question
      tags:
        - WrittenQuestions
  /api/writtenstatements/statements:
    get:
      parameters:
        - description: Written statements made on or after the date specified. Date format yyyy-mm-dd
          in: query
          name: madeWhenFrom
          schema:
            description: Written statements made on or after the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Written statements made on or before the date specified. Date format yyyy-mm-dd
          in: query
          name: madeWhenTo
          schema:
            description: Written statements made on or before the date specified. Date format yyyy-mm-dd
            format: date-time
            nullable: true
            type: string
        - description: Written questions / statements containing the search term specified, searches item content
          in: query
          name: searchTerm
          schema:
            description: Written questions / statements containing the search term specified, searches item content
            nullable: true
            type: string
        - description: Written questions / statements with the uin specified
          in: query
          name: uIN
          schema:
            description: Written questions / statements with the uin specified
            nullable: true
            type: string
        - description: Written questions / statements relating to the answering bodies with the IDs specified
          in: query
          name: answeringBodies
          schema:
            description: Written questions / statements relating to the answering bodies with the IDs specified
            items:
              format: int32
              type: integer
            nullable: true
            type: array
        - description: Written questions / statements relating to the members with the IDs specified
          in: query
          name: members
          schema:
            description: Written questions / statements relating to the members with the IDs specified
            items:
              format: int32
              type: integer
            nullable: true
            type: array
        - description: Written questions / statements relating to the House specified
          in: query
          name: house
          schema:
            $ref: "#/components/schemas/HouseEnum"
        - description: Number of records to skip, default is 0
          in: query
          name: skip
          schema:
            description: Number of records to skip, default is 0
            format: int32
            maximum: 2147483647
            minimum: 0
            nullable: true
            type: integer
        - description: Number of records to take, default is 20
          in: query
          name: take
          schema:
            description: Number of records to take, default is 20
            format: int32
            maximum: 2147483647
            minimum: 0
            nullable: true
            type: integer
        - description: Expand the details of Members in the results
          in: query
          name: expandMember
          schema:
            description: Expand the details of Members in the results
            type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StatementsViewModelSearchResult"
            text/json:
              schema:
                $ref: "#/components/schemas/StatementsViewModelSearchResult"
            text/plain:
              schema:
                $ref: "#/components/schemas/StatementsViewModelSearchResult"
          description: Success
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Bad Request
      summary: Returns a list of written statements
      tags:
        - WrittenStatements
  "/api/writtenstatements/statements/{date}/{uin}":
    get:
      parameters:
        - description: Written statement on date specified
          in: path
          name: date
          required: true
          schema:
            description: Written statement on date specified
            format: date-time
            type: string
        - description: Written statement with uid specified
          in: path
          name: uin
          required: true
          schema:
            description: Written statement with uid specified
            nullable: true
            type: string
        - description: Expand the details of Members in the results
          in: query
          name: expandMember
          schema:
            description: Expand the details of Members in the results
            type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StatementsViewModelItem"
            text/json:
              schema:
                $ref: "#/components/schemas/StatementsViewModelItem"
            text/plain:
              schema:
                $ref: "#/components/schemas/StatementsViewModelItem"
          description: Success
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Bad Request
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Not Found
      summary: Returns a written statemnet
      tags:
        - WrittenStatements
  "/api/writtenstatements/statements/{id}":
    get:
      parameters:
        - description: Written statement with ID specified
          in: path
          name: id
          required: true
          schema:
            description: Written statement with ID specified
            format: int32
            type: integer
        - description: Expand the details of Members in the results
          in: query
          name: expandMember
          schema:
            description: Expand the details of Members in the results
            type: boolean
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StatementsViewModelSearchResult"
            text/json:
              schema:
                $ref: "#/components/schemas/StatementsViewModelSearchResult"
            text/plain:
              schema:
                $ref: "#/components/schemas/StatementsViewModelSearchResult"
          description: Success
        "400":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Bad Request
        "404":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            text/plain:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
          description: Not Found
      summary: Returns a written statement
      tags:
        - WrittenStatements
components:
  schemas:
    Answered:
      enum:
        - Any
        - Answered
        - Unanswered
      type: string
    AttachmentViewModel:
      additionalProperties: false
      properties:
        fileSizeBytes:
          format: int64
          type: integer
        fileType:
          nullable: true
          type: string
        title:
          nullable: true
          type: string
        url:
          nullable: true
          type: string
      type: object
    DailyReportViewModel:
      additionalProperties: false
      properties:
        date:
          format: date-time
          type: string
        fileSizeBytes:
          format: int64
          type: integer
        house:
          $ref: "#/components/schemas/HouseEnum"
        url:
          nullable: true
          type: string
      type: object
    DailyReportViewModelItem:
      additionalProperties: false
      properties:
        links:
          items:
            $ref: "#/components/schemas/Link"
          nullable: true
          type: array
        value:
          $ref: "#/components/schemas/DailyReportViewModel"
      type: object
    DailyReportViewModelSearchResult:
      additionalProperties: false
      properties:
        results:
          items:
            $ref: "#/components/schemas/DailyReportViewModelItem"
          nullable: true
          type: array
        totalResults:
          format: int32
          type: integer
      type: object
    GroupedQuestionViewModel:
      additionalProperties: false
      properties:
        dateTabled:
          format: date-time
          type: string
        questionUin:
          nullable: true
          type: string
      type: object
    HouseEnum:
      enum:
        - Bicameral
        - Commons
        - Lords
      type: string
    Link:
      additionalProperties: false
      properties:
        href:
          nullable: true
          type: string
        method:
          nullable: true
          type: string
        rel:
          nullable: true
          type: string
      type: object
    LinkedStatements:
      additionalProperties: false
      properties:
        linkDate:
          format: date-time
          type: string
        linkType:
          $ref: "#/components/schemas/StatementLinkTypeEnum"
        linkedStatementId:
          format: int32
          type: integer
      type: object
    MemberViewModel:
      additionalProperties: false
      properties:
        id:
          format: int32
          type: integer
        listAs:
          nullable: true
          type: string
        memberFrom:
          nullable: true
          type: string
        name:
          nullable: true
          type: string
        party:
          nullable: true
          type: string
        partyAbbreviation:
          nullable: true
          type: string
        partyColour:
          nullable: true
          type: string
        thumbnailUrl:
          nullable: true
          type: string
      type: object
    ProblemDetails:
      additionalProperties:
        additionalProperties: false
        type: object
      properties:
        detail:
          nullable: true
          type: string
        instance:
          nullable: true
          type: string
        status:
          format: int32
          nullable: true
          type: integer
        title:
          nullable: true
          type: string
        type:
          nullable: true
          type: string
      type: object
    QuestionStatusEnum:
      enum:
        - NotAnswered
        - AnsweredOnly
        - AllQuestions
      type: string
    QuestionsViewModel:
      additionalProperties: false
      properties:
        answerIsCorrection:
          nullable: true
          type: boolean
        answerIsHolding:
          nullable: true
          type: boolean
        answerText:
          nullable: true
          type: string
        answeringBodyId:
          format: int32
          type: integer
        answeringBodyName:
          nullable: true
          type: string
        answeringMember:
          $ref: "#/components/schemas/MemberViewModel"
        answeringMemberId:
          format: int32
          nullable: true
          type: integer
        askingMember:
          $ref: "#/components/schemas/MemberViewModel"
        askingMemberId:
          format: int32
          type: integer
        attachmentCount:
          format: int32
          type: integer
        attachments:
          items:
            $ref: "#/components/schemas/AttachmentViewModel"
          nullable: true
          type: array
        comparableAnswerText:
          nullable: true
          type: string
        correctingMember:
          $ref: "#/components/schemas/MemberViewModel"
        correctingMemberId:
          format: int32
          nullable: true
          type: integer
        dateAnswerCorrected:
          format: date-time
          nullable: true
          type: string
        dateAnswered:
          format: date-time
          nullable: true
          type: string
        dateForAnswer:
          format: date-time
          type: string
        dateHoldingAnswer:
          format: date-time
          nullable: true
          type: string
        dateTabled:
          format: date-time
          type: string
        groupedQuestions:
          items:
            type: string
          nullable: true
          type: array
        groupedQuestionsDates:
          items:
            $ref: "#/components/schemas/GroupedQuestionViewModel"
          nullable: true
          type: array
        heading:
          nullable: true
          type: string
        house:
          $ref: "#/components/schemas/HouseEnum"
        id:
          format: int32
          type: integer
        isNamedDay:
          type: boolean
        isWithdrawn:
          type: boolean
        memberHasInterest:
          type: boolean
        originalAnswerText:
          nullable: true
          type: string
        questionText:
          nullable: true
          type: string
        uin:
          nullable: true
          type: string
      type: object
    QuestionsViewModelItem:
      additionalProperties: false
      properties:
        links:
          items:
            $ref: "#/components/schemas/Link"
          nullable: true
          type: array
        value:
          $ref: "#/components/schemas/QuestionsViewModel"
      type: object
    QuestionsViewModelSearchResult:
      additionalProperties: false
      properties:
        results:
          items:
            $ref: "#/components/schemas/QuestionsViewModelItem"
          nullable: true
          type: array
        totalResults:
          format: int32
          type: integer
      type: object
    StatementLinkTypeEnum:
      enum:
        - CorrectedStatement
        - CorrectedAnswer
        - JointStatement
      type: string
    StatementsViewModel:
      additionalProperties: false
      properties:
        answeringBodyId:
          format: int32
          type: integer
        answeringBodyName:
          nullable: true
          type: string
        attachments:
          items:
            $ref: "#/components/schemas/AttachmentViewModel"
          nullable: true
          type: array
        dateMade:
          format: date-time
          type: string
        hasAttachments:
          type: boolean
        hasLinkedStatements:
          type: boolean
        house:
          $ref: "#/components/schemas/HouseEnum"
        id:
          format: int32
          type: integer
        linkedStatements:
          items:
            $ref: "#/components/schemas/LinkedStatements"
          nullable: true
          type: array
        member:
          $ref: "#/components/schemas/MemberViewModel"
        memberId:
          format: int32
          type: integer
        memberRole:
          nullable: true
          type: string
        noticeNumber:
          format: int32
          type: integer
        text:
          nullable: true
          type: string
        title:
          nullable: true
          type: string
        uin:
          nullable: true
          type: string
      type: object
    StatementsViewModelItem:
      additionalProperties: false
      properties:
        links:
          items:
            $ref: "#/components/schemas/Link"
          nullable: true
          type: array
        value:
          $ref: "#/components/schemas/StatementsViewModel"
      type: object
    StatementsViewModelSearchResult:
      additionalProperties: false
      properties:
        results:
          items:
            $ref: "#/components/schemas/StatementsViewModelItem"
          nullable: true
          type: array
        totalResults:
          format: int32
          type: integer
      type: object
