# Read

Launch stage: GA

`GET /api/2.0/dbfs/read`

Returns the contents of a file. If the file does not exist, this call throws an exception with `RESOURCE_DOES_NOT_EXIST`.
 If the path is a directory, the read length is negative, or if the offset is negative, this call throws an exception with
 `INVALID_PARAMETER_VALUE`. If the read length exceeds 1 MB, this call throws an
 exception with `MAX_READ_SIZE_EXCEEDED`.

 If `offset + length` exceeds the number of bytes in a file, it reads the contents until the end of file.

API scopes: files

## Query parameters

- `path` (string, optional)
  The path of the file to read. The path should be the absolute DBFS path.
  Example: `/mnt/foo`
- `offset` (int64, optional)
  The offset to read from in bytes.
  Default: `0`
- `length` (int64, optional)
  The number of bytes to read starting from the offset. This has a limit of 1 MB, and a default
   value of 0.5 MB.
  Default: `524288`

## Returns

- `bytes_read` (int64, optional)
  The number of bytes read (could be less than ``length`` if we hit end of file). This refers to
   number of bytes read in unencoded version (response data is base64-encoded).
- `data` (string, optional)
  The base64-encoded contents of the file read.

## Response

```json
{
  "bytes_read": 0,
  "data": "string"
}
```

