openapi: 3.0.0
info:
  title: Kaggle Dataset API
  description: |
    Look up one public Kaggle dataset by its ref or kaggle.com URL. Returns its metadata (title, subtitle, Markdown description, owner, creator, licence, votes, downloads, views, notebook and discussion counts, usability rating out of 10, total size of its files, last update, current version, tags and up to 10 of its most recent versions) and a page of its files with their sizes, 200 files per page.

    Kaggle leaves out counters that are zero, so they are returned as `0`. A dataset that doesn't exist or isn't public returns an `error` message, the same for both.

    **Cross-linking**: `dataset_id` takes the `dataset_results[].dataset_id` that the Kaggle Dataset Search API returns.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Kaggle Dataset
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `kaggle_dataset`'
          schema:
            type: string
            enum: ["kaggle_dataset"]
        - name: dataset_id
          in: query
          required: true
          description: Kaggle's ref for the dataset (`owner/slug`), such as `imdevskp/corona-virus-report`, or its kaggle.com/datasets URL. Any path after the slug, such as `/data`, and any query are ignored.
          schema:
            type: string
        - name: version
          in: query
          required: false
          description: Version whose files to list. The metadata always describes the current version. A version the dataset doesn't have returns an error naming the current one.
          schema:
            type: integer
            minimum: 1
            maximum: 2147483647
        - name: next_page_token
          in: query
          required: false
          description: The `pagination.next_page_token` of a previous response, for the next 200 files. It only works with the `dataset_id` and `version` of that response.
          schema:
            type: string
            maxLength: 2048
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Timeout. We could not retrieve results in 90 seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        dataset:
          $ref: '#/components/schemas/Dataset'
        files:
          type: array
          description: Files of the current version, or of `version`, up to 200 per page. Omitted when Kaggle has no file list, such as for a BigQuery dataset.
          items:
            $ref: '#/components/schemas/File'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Message saying why no dataset was returned.
    Dataset:
      type: object
      required: [dataset_id, id, title, link, owner, votes, downloads, views, notebooks, discussions]
      properties:
        dataset_id:
          type: string
          description: Kaggle's ref for the dataset, its owner's slug and the dataset's slug.
        id:
          type: integer
          description: Kaggle's numeric id for the dataset.
        title:
          type: string
          description: Title of the dataset.
        subtitle:
          type: string
          description: Subtitle the owner gave the dataset.
        description:
          type: string
          description: Description of the dataset in Markdown, as its owner wrote it.
        link:
          type: string
          description: Link to the dataset's page on Kaggle.
        owner:
          $ref: '#/components/schemas/Owner'
        creator:
          $ref: '#/components/schemas/Creator'
        license:
          type: string
          description: Name of the dataset's licence.
        votes:
          type: integer
          description: Number of upvotes.
        downloads:
          type: integer
          description: Number of downloads.
        views:
          type: integer
          description: Number of views.
        notebooks:
          type: integer
          description: Number of public notebooks that use the dataset.
        discussions:
          type: integer
          description: Number of discussion topics about the dataset.
        usability_rating:
          type: number
          description: Kaggle's usability rating out of 10, with one decimal.
        files_size_bytes:
          type: integer
          description: Total size of the current version's files, in bytes.
        last_updated:
          type: string
          format: date-time
          description: Time of the dataset's last update, in UTC.
        version:
          type: integer
          description: Number of the dataset's current version.
        tags:
          type: array
          description: Names of the tags the dataset carries.
          items:
            type: string
        versions:
          type: array
          description: Up to 10 of the dataset's most recent versions, newest first.
          items:
            $ref: '#/components/schemas/Version'
        thumbnail:
          type: string
          description: Link to the dataset's thumbnail image.
    Owner:
      type: object
      required: [username]
      properties:
        username:
          type: string
          description: Kaggle username or organization slug of the owner, the first part of `dataset_id`.
        name:
          type: string
          description: Display name of the owner.
    Creator:
      type: object
      required: [name]
      properties:
        name:
          type: string
          description: Display name of the user who created the dataset.
    Version:
      type: object
      required: [version]
      properties:
        version:
          type: integer
          description: Number of the version.
        created_at:
          type: string
          format: date-time
          description: Time the version was created, in UTC.
        notes:
          type: string
          description: Notes the author gave the version.
        status:
          type: string
          description: Kaggle's status for the version, such as `Ready`.
    File:
      type: object
      required: [path, size_bytes]
      properties:
        path:
          type: string
          description: Path of the file inside the dataset, folders included.
        size_bytes:
          type: integer
          description: Size of the file in bytes.
        created_at:
          type: string
          format: date-time
          description: Time the file was added, in UTC.
    Pagination:
      type: object
      required: [next_page_token]
      properties:
        next_page_token:
          type: string
          description: Token for the next page of files, to send as `next_page_token`.
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: "Unique identifier for the search request"
        status:
          type: string
          description: "Status of the search request"
        created_at:
          type: string
          format: date-time
          description: "Timestamp when the search was created"
        request_time_taken:
          type: number
          description: "Time taken to make the request in seconds"
        parsing_time_taken:
          type: number
          description: "Time taken to parse the results in seconds"
        total_time_taken:
          type: number
          description: "Total time taken for the search in seconds"
        request_url:
          type: string
          description: "Kaggle page of the dataset, or of the version asked for"
        html_url:
          type: string
          description: "URL to view HTML results"
        json_url:
          type: string
          description: "URL to view JSON results"
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used
        dataset_id:
          type: string
          description: Kaggle's ref for the dataset looked up
        version:
          type: integer
          description: Version whose files were listed
        next_page_token:
          type: string
          description: Token of the page of files listed
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
