Spreadsheets

2 endpoints for converting between CSV, XLSX, XLS, ODS, XLSM, and JSON.

Method Endpoint Purpose
POST /v1/convert/spreadsheet Convert between spreadsheet formats
GET /v1/convert/spreadsheet Stream a converted spreadsheet from a URL source

Python SDK Examples

CSV to XLSX

Pass CSV as an inline string via data.

from toolkitapi import Convert

cv = Convert(api_key="tk_...")

csv_text = "Product,Q1,Q2,Q3\nWidgets,1200,1450,1380\nGadgets,890,920,1010"

result = cv.spreadsheet(
    from_format="csv",
    to_format="xlsx",
    data=csv_text,
    sheet_name="Sales",
)

import base64
from pathlib import Path
xlsx_bytes = base64.b64decode(result["result"])
Path("sales.xlsx").write_bytes(xlsx_bytes)

XLSX to CSV

import base64
from pathlib import Path
from toolkitapi import Convert

cv = Convert(api_key="tk_...")

xlsx_bytes = Path("report.xlsx").read_bytes()

result = cv.spreadsheet(
    from_format="xlsx",
    to_format="csv",
    file=base64.b64encode(xlsx_bytes).decode(),
)

print(result["result"])
# Product,Q1,Q2,Q3
# Widgets,1200,1450,1380
# Gadgets,890,920,1010

JSON to XLSX

Convert a JSON array of objects directly to a spreadsheet.

from toolkitapi import Convert

cv = Convert(api_key="tk_...")

records = [
    {"name": "Alice", "department": "Engineering", "salary": 95000},
    {"name": "Bob",   "department": "Design",      "salary": 82000},
    {"name": "Carol", "department": "Marketing",   "salary": 78000},
]

result = cv.spreadsheet(
    from_format="json",
    to_format="xlsx",
    data=records,
    sheet_name="Employees",
)

import base64
from pathlib import Path
Path("employees.xlsx").write_bytes(base64.b64decode(result["result"]))

XLSX to JSON

import base64
from pathlib import Path
import json
from toolkitapi import Convert

cv = Convert(api_key="tk_...")

xlsx_bytes = Path("employees.xlsx").read_bytes()

result = cv.spreadsheet(
    from_format="xlsx",
    to_format="json",
    file=base64.b64encode(xlsx_bytes).decode(),
)

rows = json.loads(result["result"])
for row in rows:
    print(row)

Convert from a URL and download directly

Use spreadsheet_file() to stream the converted file to disk without base64 overhead.

from toolkitapi import Convert

cv = Convert(api_key="tk_...")

path = cv.spreadsheet_file(
    url="https://toolkitapi.io/data/quarterly-report.csv",
    from_format="csv",
    to_format="xlsx",
    sheet_name="Q Report",
    output_path="quarterly-report.xlsx",
)
print(f"Saved to {path}")

Convert a tab-separated file

Specify delimiter explicitly when the CSV uses a non-standard separator.

from toolkitapi import Convert

cv = Convert(api_key="tk_...")

tsv_text = "name\tscore\nAlice\t95\nBob\t87"

result = cv.spreadsheet(
    from_format="csv",
    to_format="xlsx",
    data=tsv_text,
    delimiter="\t",
)

Request Parameters

Parameter Type Description
from_format string Source format: csv, xlsx, xls, ods, xlsm, json
to_format string Target format: same set
data any Inline data — CSV string or JSON array of objects
file string Base64-encoded source file (alternative to data or url)
url string Public URL to fetch source file from
delimiter string CSV column delimiter (auto-detected if omitted)
sheet_name string Worksheet name for XLSX output (default Sheet1)

Response Fields

Field Type Description
result string Converted content — base64 for binary formats, plain text for CSV/JSON
from_format string Source format used
to_format string Target format used
file_url string Presigned download URL (when MinIO storage is enabled)
metadata object Stats: rows, columns, sheet_name

Tip

For JSON→XLSX conversions, pass a list of objects as data — column headers are derived automatically from the object keys. Use sheet_name to give the worksheet a meaningful name.