openapi: 3.0.0
servers:
  - url: https://api.fungenerators.com
  - url: http://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: openapi
      url: https://fungenerators.com/yaml/riddle.yaml
      version: "3.0"
  x-providerName: fungenerators.com
  x-serviceName: riddle
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_apis.guru_assets_images_no-logo.svg
tags:
  - description: Generate Random Riddles
    externalDocs:
      description: Find out more
      url: http://fungenerators.com/api/riddle
    name: Random Riddle
  - description: Store and Retrive your Riddles
    externalDocs:
      description: Find out more
      url: http://fungenerators.com/api/riddle
    name: Private Riddles
paths:
  /riddle:
    delete:
      description: Create a random Riddle entry.
      parameters:
        - description: Riddle ID
          in: query
          name: id
          required: true
          schema:
            format: string
            type: string
      responses:
        "200":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                        "success": {
                            "total": 1
                        },
                        "contents": {
                            "mesg": "Riddle 62D6iKM9GSlJxK5nrMf9XwrE is deleted"
                        }
                    }
          description: 200  response
        "401":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                        "error": {
                            "code": 401,
                            "message": "Unauthorized"
                        }
                    }
          description: 401  response
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Private Riddles
    get:
      description: Get a Riddle entry for a given id. Retrieves a riddle question and answer based on the id.
      parameters:
        - description: ID of the riddle to fetch
          in: query
          name: id
          required: false
          schema:
            format: string
            type: string
      responses:
        "200":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                      "success": {
                        "total": 1
                      },
                      "contents": [
                        {
                          "id": "1g58pgg30eUKunTSqJNLgAeF",
                          "riddle": "Why should you always carry a watch when crossing a desert?",
                          "answers": [
                            "It has a spring in it"
                          ],
                          "category": "",
                          "category_name": ""
                        }
                      ]
                    }
          description: 200  response
        "401":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                        "error": {
                            "code": 401,
                            "message": "Unauthorized"
                        }
                    }
          description: 401  response
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Private Riddles
    post:
      description: Create a random Riddle entry. Same as 'PUT' but can be used when some of the client libraries don't support 'PUT'.
      parameters:
        - description: Riddle Question
          in: query
          name: question
          required: true
          schema:
            format: string
            type: string
        - description: Category of the riddle
          in: query
          name: category
          required: true
          schema:
            format: string
            type: string
        - description: Answer(s) to the riddle question
          in: query
          name: answer
          required: true
          schema:
            format: string
            type: string
      responses:
        "200":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                        "success": {
                            "total": 1
                        },
                        "contents": {
                            "id": "62D6iKM9GSlJxK5nrMf9XwrE"
                        }
                    }
          description: 200  response
        "401":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                        "error": {
                            "code": 401,
                            "message": "Unauthorized"
                        }
                    }
          description: 401  response
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Private Riddles
    put:
      description: Create a random Riddle entry.
      parameters:
        - description: Riddle Question
          in: query
          name: question
          required: true
          schema:
            format: string
            type: string
        - description: Category of the riddle
          in: query
          name: category
          required: true
          schema:
            format: string
            type: string
        - description: Answer(s) to the riddle question
          in: query
          name: answer
          required: true
          schema:
            format: string
            type: string
      responses:
        "200":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                        "success": {
                            "total": 1
                        },
                        "contents": {
                            "id": "62D6iKM9GSlJxK5nrMf9XwrE"
                        }
                    }
          description: 200  response
        "401":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                        "error": {
                            "code": 401,
                            "message": "Unauthorized"
                        }
                    }
          description: 401  response
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Private Riddles
  /riddle/random:
    get:
      description: Get a random riddle for a given category(optional)
      parameters:
        - description: Category to get the riddle from
          in: query
          name: category
          required: false
          schema:
            format: string
            type: string
      responses:
        "200":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                      "success": {
                        "total": 1
                      },
                      "contents": [
                        {
                          "id": "1g58pgg30eUKunTSqJNLgAeF",
                          "riddle": "Why should you always carry a watch when crossing a desert?",
                          "answers": [
                            "It has a spring in it"
                          ],
                          "category": "",
                          "category_name": ""
                        }
                      ]
                    }
          description: 200  response
        "401":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                        "error": {
                            "code": 401,
                            "message": "Unauthorized"
                        }
                    }                    
          description: 401  response
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Random Riddle
  /riddle/search:
    get:
      description: Search for random riddle which has the text in the query, for a given category(optional).
      parameters:
        - description: Text to search for in the riddle
          in: query
          name: query
          required: false
          schema:
            format: string
            type: string
        - description: Category to get the riddle from
          in: query
          name: category
          required: false
          schema:
            format: string
            type: string
      responses:
        "200":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                      "success": {
                        "total": 1
                      },
                      "contents": [
                        {
                          "id": "1g58pgg30eUKunTSqJNLgAeF",
                          "riddle": "Why should you always carry a watch when crossing a desert?",
                          "answers": [
                            "It has a spring in it"
                          ],
                          "category": "",
                          "category_name": ""
                        }
                      ]
                    }
          description: 200  response
        "401":
          content:
            application/json:
              examples:
                response:
                  value: |-
                    {
                        "error": {
                            "code": 401,
                            "message": "Unauthorized"
                        }
                    }                                   
          description: 401  response
      security:
        - X-Fungenerators-Api-Secret: []
      tags:
        - Random Riddle
components:
  securitySchemes:
    X-Fungenerators-Api-Secret:
      in: header
      name: X-Fungenerators-Api-Secret
      type: apiKey
