# QR Code Harbor API — Examples

Runnable examples for the QR Code Harbor API (Business plan). Full reference: [`../api-docs.html`](../api-docs.html).

## 1. Get an API key

1. Create/upgrade to a **Business** account at [qrcodeharbor.com](https://qrcodeharbor.com).
2. Go to **Dashboard → Account → API Keys**.
3. Click **Create API key**, give it a name, and copy the key that's shown — it is only shown **once**.

## 2. Configure your environment

Copy the example env file and fill in your key:

```bash
cp .env.example .env
```

Edit `.env` and set:

```
QRCODEHARBOR_API_KEY=your_key_here
```

Then load it into your shell before running any example:

```bash
source .env
export QRCODEHARBOR_API_KEY
```

(or simply `export QRCODEHARBOR_API_KEY=qch_live_xxxxxxxxxxxxxxxx` directly.)

**Do not commit your `.env` file or your API key.**

## 3. Run the examples

### cURL

```bash
bash curl/create-static-url.sh
```

### Node.js (requires Node 18+ for built-in `fetch`)

```bash
node node/create-static-url.js
node node/bulk-generate.js
```

### Python (requires Python 3.8+ and `pip install requests`)

```bash
pip install requests
python3 python/create-static-url.py
python3 python/bulk_generate.py
```

## What each example does

| File | Description |
|---|---|
| `curl/create-static-url.sh` | Creates a single static `url` type QR code via cURL. |
| `node/create-static-url.js` | Same request in Node.js using the built-in `fetch`. |
| `python/create-static-url.py` | Same request in Python using `requests`. |
| `node/bulk-generate.js` | Creates several QR codes (mixed types) in one call to the bulk endpoint. |
| `python/bulk_generate.py` | Same bulk request in Python. |

## Notes

- Base URL: `https://qrcodeharbor.com/api/v1`
- Auth header: `Authorization: Bearer $QRCODEHARBOR_API_KEY` (or the equivalent `X-API-Key` header — see the docs).
- `format` supports `svg`, `png`, and `pdf`. Bulk **CSV file upload → ZIP download** is not available — the bulk examples here use the JSON-array approach.
- Styling fields (`fg`, `bg`, `size`, `margin`, `errorCorrectionLevel`, `format`) are flat top-level fields on the request body, not nested under a `style` object.
- For the full endpoint list, request/response schemas, rate limits, and error codes, see [`../api-docs.html`](../api-docs.html) or the machine-readable [`../openapi.json`](../openapi.json).
