quickchart-io
raw JSON → 2.0.0 verified Fri May 01 auth: no python
A Python client for quickchart.io, a web service that generates static chart images from Chart.js definitions. Current version 2.0.0 requires Python >=3.7. The library sends JSON chart specifications to the QuickChart API and returns PNG/JPEG/SVG images. Major update v2.0.0 dropped Python 2 and Python <3.7 support. Released as needed.
pip install quickchart-io Common errors
error TypeError: __init__() got an unexpected keyword argument 'api_key' ↓
cause Old version v1.x (or very early v2 alpha) did not accept api_key as a constructor argument. The stable v2.0.0 api_key parameter was added.
fix
Upgrade to latest version:
pip install --upgrade quickchart-io error AttributeError: 'QuickChart' object has no attribute 'get_url' ↓
cause The method might be named differently in older versions or the import is incorrect.
fix
Ensure you have version >=1.0.1 and use the correct import:
from quickchart import QuickChart error requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) ↓
cause Usually an invalid API key or hitting the rate limit without an API key. The server returns a non-JSON error.
fix
Set a valid API key via environment variable or check usage limits. Also verify the chart config is valid JSON.
Warnings
breaking Upgrading from v1.x to v2.0.0 drops Python 2 and Python < 3.7 support. Existing code using Python 2 will break. ↓
fix Upgrade to Python 3.7+ and install quickchart-io>=2.0.0.
gotcha When using chart configurations with JavaScript functions (e.g., tooltips, custom axes callbacks), the v2 library may not correctly serialize JavaScript functions. Use `qc.set_config` or pass a raw string for the config if functions are required. ↓
fix Wrap JavaScript functions as strings using `'function() { ... }'` or use `qc.set_config` with a properly escaped config dictionary.
deprecated The `QuickChart` parameter `host` is deprecated in v2.0.0 in favor of `scheme` and `host` as separate parameters or using the constructor's `host` parameter. ↓
fix Use `QuickChart(host='https://quickchart.io')` (string with protocol) or separate `scheme` and `host` kwargs.
Imports
- QuickChart wrong
import quickchartcorrectfrom quickchart import QuickChart
Quickstart
from quickchart import QuickChart
import os
api_key = os.environ.get('QUICKCHART_API_KEY', '')
qc = QuickChart(api_key=api_key)
qc.width = 600
qc.height = 400
qc.device_pixel_ratio = 2.0
qc.config = {
"type": "bar",
"data": {
"labels": ["Q1", "Q2", "Q3", "Q4"],
"datasets": [{
"label": "Sales",
"data": [50, 60, 70, 80]
}]
}
}
url = qc.get_url()
print(f"Chart URL: {url}")
# To get binary image data: img_bytes = qc.get_bytes()