> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dashlink.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Downloading QR codes

> Which format to use where.

```bash cURL theme={null}
curl -X GET "https://api.dashlink.ai/api/v1/qrcode/download_qr_code_image?name=QR-0001&format=svg" \
  -H "X-API-Key: $DASHLINK_API_KEY"
```

```javascript Node.js theme={null}
const response = await fetch("https://api.dashlink.ai/api/v1/qrcode/download_qr_code_image?name=QR-0001&format=svg", {
  headers: { "X-API-Key": process.env.DASHLINK_API_KEY },
});
const payload = await response.json();
```

```python Python theme={null}
import os
import requests

response = requests.get(
    'https://api.dashlink.ai/api/v1/qrcode/download_qr_code_image?name=QR-0001&format=svg',
    headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
)
payload = response.json()
```

```go Go theme={null}
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

func main() {
	endpoint0 := "https://api.dashlink.ai/api/v1/qrcode/download_qr_code_image?name=QR-0001&format=svg"
	req0, err0 := http.NewRequest("GET", endpoint0, nil)
	if err0 != nil {
		panic(err0)
	}
	req0.Header.Set("X-API-Key", os.Getenv("DASHLINK_API_KEY"))
	resp0, err0b := http.DefaultClient.Do(req0)
	if err0b != nil {
		panic(err0b)
	}
	defer resp0.Body.Close()
	body0, _ := io.ReadAll(resp0.Body)
	fmt.Println(string(body0))
}

```

```ruby Ruby theme={null}
require "net/http"
require "json"
require "uri"

uri0 = URI("https://api.dashlink.ai/api/v1/qrcode/download_qr_code_image?name=QR-0001&format=svg")
request0 = Net::HTTP::Get.new(uri0)
request0["X-API-Key"] = ENV.fetch("DASHLINK_API_KEY")
response0 = Net::HTTP.start(uri0.hostname, uri0.port, use_ssl: true) do |http|
  http.request(request0)
end
payload0 = JSON.parse(response0.body)
```

```php PHP theme={null}
<?php
$ch0 = curl_init('https://api.dashlink.ai/api/v1/qrcode/download_qr_code_image?name=QR-0001&format=svg');
curl_setopt($ch0, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch0, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch0, CURLOPT_HTTPHEADER, [
    "X-API-Key: " . getenv("DASHLINK_API_KEY"),
]);
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

## Choosing a format

| Format | Use for | Why |
| - | - | - |
| `svg` | Print, large displays | Vector — scales to any size without softening |
| `png` | Web, email, slides | Raster with transparency support |
| `jpeg` | Only when something demands it | No transparency, and compression artefacts blur edges |

> [!WARNING]
>
> Use SVG for anything going to print. A PNG scaled up to poster size gets soft edges, and soft edges are exactly what makes a scanner hesitate.

> [!NOTE]
>
> Avoid JPEG for QR codes. Its compression is tuned for photographs and introduces artefacts around the hard black-and-white boundaries a QR code is made of.

The first request for a format that does not exist yet generates it, so that one call may be slower.

## Saving a set

```python theme={null}
def download_qr(name, fmt="svg", directory="."):
    response = requests.get(
        f"{BASE}/qrcode/download_qr_code_image",
        headers=HEADERS,
        params={"name": name, "format": fmt},
    )

    # The endpoint returns the image itself on success and a JSON error
    # envelope on failure, so check before writing bytes to disk.
    if response.headers.get("Content-Type", "").startswith("application/json"):
        raise RuntimeError(response.json()["error"]["message"])

    path = Path(directory) / f"{name}.{fmt}"
    path.write_bytes(response.content)
    return path


for qr in all_qrcodes(tags=["print-campaign"]):
    download_qr(qr["name"], fmt="svg", directory="exports")
```

## Sizing for print

Rule of thumb: a QR code should be at least **2cm x 2cm** and roughly a tenth of the scanning distance.

| Scanned from | Minimum size |
| - | - |
| 30cm — a table card | 2cm |
| 1m — a shelf label | 10cm |
| 5m — a poster | 50cm |

Leave a clear margin around the code — about four modules' worth of empty space. Text or artwork crowding the edge stops scanners locating it.

## Refreshing after a restyle

Changing styling regenerates the image, so anything you exported earlier is stale. Re-download after an `edit_qr_code` call if you keep local copies.

The encoded URL is unchanged, so codes already printed keep working.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.