Metadata-Version: 2.4
Name: shapesoda
Version: 1.1.0
Summary: Shapesoda API client: convert raster images into SVG, PDF, EPS, DXF or PNG vectors.
Author-email: Shapesoda <support@shapesoda.com>
License-Expression: LicenseRef-Proprietary
Project-URL: Homepage, https://shapesoda.com/api
Project-URL: Documentation, https://shapesoda.com/api
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: urllib3<3.0.0,>=2.1.0
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: pydantic>=2
Requires-Dist: typing-extensions>=4.7.1

# shapesoda

Python client for the [Shapesoda API](https://shapesoda.com/api): raster images (PNG, JPEG, WebP, BMP, GIF, TIFF) to SVG, PDF, EPS, DXF or PNG vectors. Python 3.9+.

```sh
pip install shapesoda
```

```python
from shapesoda import Shapesoda, ShapesodaError

client = Shapesoda()  # API key from SHAPESODA_API_KEY, or Shapesoda(api_key="ssk_...")

try:
    # One call, one credit for all formats; files are saved as out/logo.svg and out/logo.pdf.
    r = client.vectorize_file("logo.png", formats=["svg", "pdf"], preset="print", out_dir="out")
    print(r.paths, r.response.credits_remaining)
except ShapesodaError as e:
    if e.code == "no_credits":
        print("Top up at https://shapesoda.com")
    else:
        raise
```

- `vectorize(bytes, **options)` and `vectorize_file(path, **options)` send the image, then download every requested format into `result.files` (and `out_dir`). Options: `formats`, `preset`, `image_type`, `quality`, `colors`, `detail`, `draw`, `layers`, `palette`, `width`, `height`, `unit`, `mode` (`"test"` is free and watermarked), `out_dir`, `name`, plus the fine-tuning options: `max_colors`, `palette_tolerance`, `min_area`, `max_pixels`, `curve_tolerance`, `smoothness`, `corners`, `denoise`, `group_by`, `curves`, `stroke_width`, `stroke_color`, `stroke_scaling`, `gap_filler`, `gap_filler_width`, `aspect`, `align_x`, `align_y`, `scale`, `dpi`, `svg_version`, `svg_fixed_size`, `adobe_compat`, `dxf_curves`, `png_antialias` and `retention_days` (1–30 days instead of 24 hours, free). A preset only sets defaults; every option you pass wins. Ranges and combination rules: https://shapesoda.com/api#parameters.
- `preview(bytes, **options)` / `preview_file(path, **options)`: a free PNG up to 1 MP (`result.files["png"]`), 200 per account per day. When the user is happy, `upgrade(result, formats=["svg"])` builds the vectors from the stored image for 1 credit (`credits_charged`), with no new upload; other formats are free afterwards.
- Errors are `ShapesodaError` with `code` (`unauthorized`, `no_credits`, `rate_limited`, `invalid_image`, …, or `network`), `status`, `request_id` and `retry_after`.
- After `429` or `503` with `Retry-After` the call is retried up to 5 times (`max_retries`); a wait longer than `max_retry_wait` (60 s) and the daily limits are not retried.
- `download(result_id, result_token, format)`, `delete_result(...)` and `account()` are there too; the generated low-level client is `shapesoda.core` (package `shapesoda_core`).

The SDK always sends `Accept: application/json`, so the API answers with links to the stored result (kept for 24 hours, encrypted with the `result_token` only you get) and the files are downloaded with that token. Reference: https://shapesoda.com/api.

`shapesoda_core/` is generated by openapi-generator from the public OpenAPI spec; do not edit it by hand (see `clients/sdk/README.md`).
