swagger: "2.0"
schemes:
  - https
  - http
host: api.fungenerators.com
info:
  description: |
    Below is the documentation for the API calls. You can try them out right here. 
  title: Fun Generators API
  version: "1.5"
  x-apisguru-categories:
    - text
  x-origin:
    - format: swagger
      url: https://fungenerators.com/yaml/trivia.yaml
      version: "2.0"
  x-providerName: fungenerators.com
  x-serviceName: trivia
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_apis.guru_assets_images_no-logo.svg
consumes:
  - application/json
produces:
  - application/json
  - application/xml
  - application/js
securityDefinitions:
  X-Fungenerators-Api-Secret:
    in: header
    name: X-Fungenerators-Api-Secret
    type: apiKey
tags:
  - description: Trivia API
    externalDocs:
      description: Find out more
      url: http://fungenerators.com/api/trivia
    name: Trivia
paths:
  /trivia:
    delete:
      description: Create a random Trivia entry.
      parameters:
        - description: Trivia ID
          format: string
          in: query
          name: id
          required: true
          type: string
      produces:
        - application/json
        - application/xml
        - application/js
      responses:
        "200":
          description: 200  response
          examples:
            application/json: |-
              {
                  "success": {
                      "total": 1
                  },
                  "contents": {
                      "mesg": "Trivia 62D6iKM9GSlJxK5nrMf9XwrE is deleted"
                  }
              }
        "401":
          description: 401  response
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Trivia
    get:
      description: Get a Trivia entry for a given id. Retrieves a trivia question and answer based on the id.
      parameters:
        - description: ID of the trivia to fetch
          format: string
          in: query
          name: id
          required: false
          type: string
      produces:
        - application/json
        - application/xml
        - application/js
      responses:
        "200":
          description: 200  response
          examples:
            application/json: |-
              {
                  "success": {
                      "total": 1
                  },
                  "contents": [
                      {
                          "id": "VO_foToeaTPvaDn_utYcOweF",
                          "question": "What is the unit of currency in the United States of America",
                          "category": "usa",
                          "category_name": "USA",
                          "answer": [
                              "Dollar"
                          ]
                      }
                  ]
              }
        "401":
          description: 401  response
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Trivia
    put:
      description: Create a random Trivia entry.
      parameters:
        - description: Trivia Question
          format: string
          in: query
          name: question
          required: true
          type: string
        - description: Category of the trivia
          format: string
          in: query
          name: category
          required: true
          type: string
        - description: Answer(s) to the trivia question
          format: string
          in: query
          name: answer
          required: true
          type: string
      produces:
        - application/json
        - application/xml
        - application/js
      responses:
        "200":
          description: 200  response
          examples:
            application/json: |-
              {
                  "success": {
                      "total": 1
                  },
                  "contents": {
                      "id": "62D6iKM9GSlJxK5nrMf9XwrE"
                  }
              }
        "401":
          description: 401  response
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Trivia
  /trivia/categories:
    get:
      description: Get a random Trivia.
      parameters:
        - description: start
          format: integer
          in: query
          name: start
          required: false
          type: integer
      produces:
        - application/json
        - application/xml
        - application/js
      responses:
        "200":
          description: 200  response
          examples:
            application/json: |-
              {
                  "success": {
                      "total": 1
                  },
                  "contents": [
                      {
                          "id": "VO_foToeaTPvaDn_utYcOweF",
                          "question": "What is the unit of currency in the United States of America",
                          "category": "usa",
                          "category_name": "USA",
                          "answer": [
                              "Dollar"
                          ]
                      }
                  ]
              }
        "401":
          description: 401  response
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Trivia
  /trivia/random:
    get:
      description: Get a random trivia for a given category(optional)
      parameters:
        - description: Category to get the trivia from
          format: string
          in: query
          name: category
          required: false
          type: string
      produces:
        - application/json
        - application/xml
        - application/js
      responses:
        "200":
          description: 200  response
          examples:
            application/json: |-
              {
                "success": {
                  "total": 1
                },
                "contents": [
                  {
                    "id": "YYUsmCE2ztoACb_smt0PrgeF",
                    "question": "Which country won the World Cup of Soccer in 1982",
                    "category": "sports",
                    "category_name": "Sports",
                    "answer": [
                      "Italy"
                    ]
                  }
                ]
              }
        "401":
          description: 401  response
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }                    
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Trivia
  /trivia/search:
    get:
      description: Search for random trivia which has the text in the query, for a given category(optional).
      parameters:
        - description: Text to search for in the trivia
          format: string
          in: query
          name: query
          required: false
          type: string
        - description: Category to get the trivia from
          format: string
          in: query
          name: category
          required: false
          type: string
      produces:
        - application/json
        - application/xml
        - application/js
      responses:
        "200":
          description: 200  response
          examples:
            application/json: |-
              {
                "success": {
                  "total": 1
                },
                "contents": {
                  "trivia": "What natural hydrocarbon polymer comes from the hevea brasiliensis tree",
                  "id": "DFoazRj5O7x8PAVib9wROweF",
                  "category": "Whatnot",
                  "subcategory": null
                }
              }
        "401":
          description: 401  response
          examples:
            application/json: |-
              {
                  "error": {
                      "code": 401,
                      "message": "Unauthorized"
                  }
              }                                   
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Trivia
