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

# Examples

> Code examples for generating QR codes with the BananaSplit API.

## URL QR code

### cURL

```bash theme={null}
# SVG output
curl "https://bananasplit.net/api/qr-code?type=url&url=https://example.com&format=svg" \
  -o qr.svg

# JSON with both formats
curl "https://bananasplit.net/api/qr-code?type=url&url=https://example.com&format=json"

# Custom colors
curl "https://bananasplit.net/api/qr-code?type=url&url=https://example.com&color=7b260f&background=ffe66f&format=svg"
```

### JavaScript

```javascript theme={null}
const response = await fetch(
  'https://bananasplit.net/api/qr-code?' + new URLSearchParams({
    type: 'url',
    url: 'https://example.com',
    format: 'json'
  })
);

const { svg, png } = await response.json();
```

### Python

```python theme={null}
import requests

response = requests.get('https://bananasplit.net/api/qr-code', params={
    'type': 'url',
    'url': 'https://example.com',
    'format': 'svg'
})

svg_content = response.text
```

## Wi-Fi QR code

```bash theme={null}
curl -X POST "https://bananasplit.net/api/qr-code" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "wifi",
    "ssid": "MyNetwork",
    "password": "secret123",
    "encryption": "WPA",
    "format": "svg"
  }'
```

## Contact card

```bash theme={null}
curl -X POST "https://bananasplit.net/api/qr-code" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "vcard",
    "firstName": "Ana",
    "lastName": "Silva",
    "phone": "+351912345678",
    "email": "ana@example.com",
    "organization": "Acme Inc",
    "format": "svg"
  }'
```

## Email QR code

```bash theme={null}
curl -X POST "https://bananasplit.net/api/qr-code" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "email",
    "email": "hello@example.com",
    "subject": "Hello",
    "body": "I found you via QR code",
    "format": "svg"
  }'
```

## SMS QR code

```bash theme={null}
curl -X POST "https://bananasplit.net/api/qr-code" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "sms",
    "phone": "+351912345678",
    "message": "Hello from QR",
    "format": "svg"
  }'
```

## Custom styling

### BananaSplit brand colors

```bash theme={null}
curl "https://bananasplit.net/api/qr-code?type=url&url=https://bananasplit.net&color=7b260f&background=ffe66f&corners=rounded&format=svg"
```

### With banana logo

```bash theme={null}
curl "https://bananasplit.net/api/qr-code?type=url&url=https://bananasplit.net&logo=banana&format=svg"
```

### Large print-ready

```bash theme={null}
curl "https://bananasplit.net/api/qr-code?type=url&url=https://example.com&size=2048&format=png" \
  -o qr-print.png
```

## Using with agents

AI agents can generate QR codes inline:

```
Generate a QR code for https://bananasplit.net using the QR Code API
```

The agent will use the API to create the code and can embed it in responses or save to files.

## Error handling

```javascript theme={null}
const response = await fetch('https://bananasplit.net/api/qr-code?type=url&url=invalid');

if (!response.ok) {
  const error = await response.json();
  console.error(error.code, error.hint);
  // INVALID_URL, "URL must start with http:// or https://"
}
```

## Rate limit handling

```javascript theme={null}
const response = await fetch('https://bananasplit.net/api/qr-code?...');

if (response.status === 429) {
  const retryAfter = response.headers.get('Retry-After');
  await new Promise(r => setTimeout(r, retryAfter * 1000));
  // retry
}
```


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