Hugging Face Data Access API

Row-level data access and preview endpoints

Documentation

Specifications

SDKs

Other Resources

OpenAPI Specification

hugging-face-data-access-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Hugging Face Dataset Viewer Audio Data Access API
  description: Query and visualize datasets stored on the Hugging Face Hub through a lightweight REST API. Get dataset splits, preview rows, search and filter data, access Parquet files, retrieve size statistics, and obtain Croissant metadata - all without downloading the entire dataset.
  version: 1.0.0
  termsOfService: https://huggingface.co/terms-of-service
  contact:
    name: Hugging Face Support
    url: https://huggingface.co/support
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
servers:
- url: https://datasets-server.huggingface.co
  description: Hugging Face Dataset Viewer production server
security:
- {}
- bearerAuth: []
tags:
- name: Data Access
  description: Row-level data access and preview endpoints
paths:
  /first-rows:
    get:
      summary: Get First Rows of a Split
      description: Get the first 100 rows of a dataset split. Useful for previewing data structure and content.
      operationId: getFirstRows
      tags:
      - Data Access
      parameters:
      - name: dataset
        in: query
        required: true
        description: The dataset ID
        schema:
          type: string
        example: squad
      - name: config
        in: query
        required: true
        description: The subset (configuration) name
        schema:
          type: string
        example: plain_text
      - name: split
        in: query
        required: true
        description: The split name
        schema:
          type: string
        example: train
      responses:
        '200':
          description: First rows of the dataset split
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RowsResponse'
              examples:
                Getfirstrows200Example:
                  summary: Default getFirstRows 200 response
                  x-microcks-default: true
                  value:
                    features:
                    - feature_idx: 10
                      name: Example Title
                      type:
                        dtype: example_value
                        _type: example_value
                    rows:
                    - row_idx: 10
                      row: example_value
                      truncated_cells:
                      - {}
                    num_rows_total: 10
                    num_rows_per_page: 10
                    partial: true
        '400':
          description: Bad request - missing or invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Getfirstrows400Example:
                  summary: Default getFirstRows 400 response
                  x-microcks-default: true
                  value:
                    error: example_value
                    cause_exception: example_value
                    cause_message: example_value
                    cause_traceback:
                    - example_value
        '404':
          description: Dataset, config, or split not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Getfirstrows404Example:
                  summary: Default getFirstRows 404 response
                  x-microcks-default: true
                  value:
                    error: example_value
                    cause_exception: example_value
                    cause_message: example_value
                    cause_traceback:
                    - example_value
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /rows:
    get:
      summary: Get a Slice of Rows
      description: Get a slice of rows from a dataset split with pagination support. Returns up to 100 rows per request.
      operationId: getRows
      tags:
      - Data Access
      parameters:
      - name: dataset
        in: query
        required: true
        description: The dataset ID
        schema:
          type: string
        example: squad
      - name: config
        in: query
        required: true
        description: The subset (configuration) name
        schema:
          type: string
        example: plain_text
      - name: split
        in: query
        required: true
        description: The split name
        schema:
          type: string
        example: train
      - name: offset
        in: query
        required: false
        description: Row offset to start from
        schema:
          type: integer
          default: 0
          minimum: 0
        example: 10
      - name: length
        in: query
        required: false
        description: Number of rows to return (max 100)
        schema:
          type: integer
          default: 100
          maximum: 100
          minimum: 1
        example: 10
      responses:
        '200':
          description: Slice of rows from the dataset
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RowsResponse'
              examples:
                Getrows200Example:
                  summary: Default getRows 200 response
                  x-microcks-default: true
                  value:
                    features:
                    - feature_idx: 10
                      name: Example Title
                      type:
                        dtype: example_value
                        _type: example_value
                    rows:
                    - row_idx: 10
                      row: example_value
                      truncated_cells:
                      - {}
                    num_rows_total: 10
                    num_rows_per_page: 10
                    partial: true
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Getrows400Example:
                  summary: Default getRows 400 response
                  x-microcks-default: true
                  value:
                    error: example_value
                    cause_exception: example_value
                    cause_message: example_value
                    cause_traceback:
                    - example_value
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
          example: example_value
        cause_exception:
          type: string
          description: Underlying exception type
          example: example_value
        cause_message:
          type: string
          description: Underlying exception message
          example: example_value
        cause_traceback:
          type: array
          items:
            type: string
          description: Stack trace (only in development)
          example: []
    RowsResponse:
      type: object
      properties:
        features:
          type: array
          items:
            type: object
            properties:
              feature_idx:
                type: integer
                description: Feature index
              name:
                type: string
                description: Column name
              type:
                type: object
                description: Column data type information
                properties:
                  dtype:
                    type: string
                  _type:
                    type: string
          description: Column definitions and types
          example: []
        rows:
          type: array
          items:
            type: object
            properties:
              row_idx:
                type: integer
                description: Row index in the split
              row:
                type: object
                additionalProperties: true
                description: Row data as key-value pairs
              truncated_cells:
                type: array
                items:
                  type: string
                description: List of cell names that were truncated
          description: Row data
          example: []
        num_rows_total:
          type: integer
          description: Total number of rows in the split
          example: 10
        num_rows_per_page:
          type: integer
          description: Number of rows per page
          example: 10
        partial:
          type: boolean
          description: Whether this is a partial result
          example: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: HF Token
      description: Optional Hugging Face API token. Required for private and gated datasets.