# Files ## List files `client.files.list(FileListParamsquery?, RequestOptionsoptions?): CursorIDPage` **get** `/v1/files` List all files uploaded by the current user. ### Parameters - `query: FileListParams` - `after?: string | null` A cursor for pagination. Use the `last_id` from a previous response to fetch the next page. - `limit?: number` Maximum number of files to return. ### Returns - `File` Response representing an uploaded file. This is returned from POST (upload), GET (retrieve), and list endpoints. - `id: string` The unique identifier for this file. - `content_type: string` The MIME type of the file. - `created_at: string` The timestamp when the file was uploaded. - `file_name: string` The original filename of the uploaded file. - `object: "file"` The object type, which is always 'file'. - `"file"` - `size: number` The size of the file in bytes. ### Example ```typescript import DeepTable from '@deeptable/deeptable'; const client = new DeepTable({ apiKey: process.env['DEEPTABLE_API_KEY'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const file of client.files.list()) { console.log(file.id); } ``` #### Response ```json { "data": [ { "id": "file_01kfxgjd94fn9stqm414vjb0s8", "content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "created_at": "2024-01-15T10:30:00Z", "file_name": "financial_report.xlsx", "object": "file", "size": 1048576 } ], "has_more": false, "object": "list", "first_id": "file_01kfxgjd94fn9stqm414vjb0s8", "last_id": "file_01kfxgjd94fn9stqm414vjb0s8" } ``` ## Upload a file `client.files.upload(FileUploadParamsbody, RequestOptionsoptions?): File` **post** `/v1/files` Upload an Excel spreadsheet file for later processing. Supported formats: - Excel (.xlsx) Maximum file size: 100 MB ### Parameters - `body: FileUploadParams` - `file: Uploadable` The spreadsheet file to upload ### Returns - `File` Response representing an uploaded file. This is returned from POST (upload), GET (retrieve), and list endpoints. - `id: string` The unique identifier for this file. - `content_type: string` The MIME type of the file. - `created_at: string` The timestamp when the file was uploaded. - `file_name: string` The original filename of the uploaded file. - `object: "file"` The object type, which is always 'file'. - `"file"` - `size: number` The size of the file in bytes. ### Example ```typescript import DeepTable from '@deeptable/deeptable'; const client = new DeepTable({ apiKey: process.env['DEEPTABLE_API_KEY'], // This is the default and can be omitted }); const file = await client.files.upload({ file: fs.createReadStream('path/to/file') }); console.log(file.id); ``` #### Response ```json { "id": "file_01kfxgjd94fn9stqm414vjb0s8", "content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "created_at": "2024-01-15T10:30:00Z", "file_name": "financial_report.xlsx", "object": "file", "size": 1048576 } ``` ## Delete a file `client.files.delete(stringfileID, RequestOptionsoptions?): FileDeleteResponse` **delete** `/v1/files/{file_id}` Delete a file. This cannot be undone. ### Parameters - `fileID: string` The unique identifier of the file. ### Returns - `FileDeleteResponse` Response from deleting a file. Following the OpenAI API convention for delete responses. - `id: string` The unique identifier of the deleted file. - `deleted: true` Whether the file was successfully deleted. - `true` - `object: "file"` The object type, which is always 'file'. - `"file"` ### Example ```typescript import DeepTable from '@deeptable/deeptable'; const client = new DeepTable({ apiKey: process.env['DEEPTABLE_API_KEY'], // This is the default and can be omitted }); const file = await client.files.delete('file_01kfxgjd94fn9stqm414vjb0s8'); console.log(file.id); ``` #### Response ```json { "id": "file_01kfxgjd94fn9stqm414vjb0s8", "deleted": true, "object": "file" } ``` ## Get file metadata `client.files.retrieve(stringfileID, RequestOptionsoptions?): File` **get** `/v1/files/{file_id}` Get metadata for a specific file. ### Parameters - `fileID: string` The unique identifier of the file. ### Returns - `File` Response representing an uploaded file. This is returned from POST (upload), GET (retrieve), and list endpoints. - `id: string` The unique identifier for this file. - `content_type: string` The MIME type of the file. - `created_at: string` The timestamp when the file was uploaded. - `file_name: string` The original filename of the uploaded file. - `object: "file"` The object type, which is always 'file'. - `"file"` - `size: number` The size of the file in bytes. ### Example ```typescript import DeepTable from '@deeptable/deeptable'; const client = new DeepTable({ apiKey: process.env['DEEPTABLE_API_KEY'], // This is the default and can be omitted }); const file = await client.files.retrieve('file_01kfxgjd94fn9stqm414vjb0s8'); console.log(file.id); ``` #### Response ```json { "id": "file_01kfxgjd94fn9stqm414vjb0s8", "content_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "created_at": "2024-01-15T10:30:00Z", "file_name": "financial_report.xlsx", "object": "file", "size": 1048576 } ``` ## Download file `client.files.download(stringfileID, RequestOptionsoptions?): Response` **get** `/v1/files/{file_id}/content` Download the original uploaded file content. ### Parameters - `fileID: string` The unique identifier of the file. ### Returns - `unnamed_schema_3 = Response` ### Example ```typescript import DeepTable from '@deeptable/deeptable'; const client = new DeepTable({ apiKey: process.env['DEEPTABLE_API_KEY'], // This is the default and can be omitted }); const response = await client.files.download('file_01kfxgjd94fn9stqm414vjb0s8'); console.log(response); const content = await response.blob(); console.log(content); ``` ## Domain Types ### File - `File` Response representing an uploaded file. This is returned from POST (upload), GET (retrieve), and list endpoints. - `id: string` The unique identifier for this file. - `content_type: string` The MIME type of the file. - `created_at: string` The timestamp when the file was uploaded. - `file_name: string` The original filename of the uploaded file. - `object: "file"` The object type, which is always 'file'. - `"file"` - `size: number` The size of the file in bytes.