Python SDK: Files
⚠️
Preview — this feature is being built; the design below is the spec.
Upload once, reference by id.
from syntic import Syntic
client = Syntic() # reads SYNTIC_API_KEY| Method | Endpoint | Returns |
|---|---|---|
files.upload | POST /v1/files | FileObject |
files.list | GET /v1/files | SyncPage[FileObject] |
files.retrieve | GET /v1/files/{file_id} | FileObject |
files.content | GET /v1/files/{file_id}/content | BinaryResponse |
files.delete | DELETE /v1/files/{file_id} | FileDeleted |
Methods
files.upload
Upload from a path, bytes or a file object. Multipart encoding is handled for you. Maps to POST /v1/files.
result = client.files.upload(path="contract.pdf", purpose="document")files.list
List files, newest first, filtered by purpose. Maps to GET /v1/files.
for item in client.files.list(purpose="batch"):
print(item.id if hasattr(item, 'id') else item)files.retrieve
Metadata for one file. Maps to GET /v1/files/{file_id}.
result = client.files.retrieve('file_01JC3D5F7H9K1M3P5R7T')files.content
Download bytes. .write_to_file(path) streams to disk. Maps to GET /v1/files/{file_id}/content.
result = client.files.content('file_01JC3D5F7H9K1M3P5R7T')files.delete
Delete a file. Maps to DELETE /v1/files/{file_id}.
result = client.files.delete('file_01JC3D5F7H9K1M3P5R7T')Conventions
Every method accepts extra_headers, extra_query, extra_body and timeout keyword arguments, and has an async twin on AsyncSyntic. List methods return pages that iterate across all pages automatically.
See the Python SDK overview for installation, errors and retries.
Was this page helpful?