# QR Code Generator

## /generate-qrcode

This endpoint accepts a GET request with query parameters including the `url`, `color`, and `pattern`. It generates a QR code based on the provided URL or text, with the specified color and pattern options if provided. If the `color` parameter is provided, it returns the QR code as a PNG image with the specified color. Otherwise, it returns the QR code as a base64-encoded string. If there is an error during the generation process, it returns a 500 error with a corresponding message.

### Query Parameters

| Parameter | Type   | Description                                                                |
| --------- | ------ | -------------------------------------------------------------------------- |
| url       | string | The URL or text to encode into the QR code.                                |
| color     | string | The color of the dark modules in the QR code (optional, default is black). |
| pattern   | number | The QR code pattern (optional).                                            |

### Response

* If `color` parameter is provided, the endpoint returns a PNG image of the generated QR code with the specified color.
* If `color` parameter is not provided, the endpoint returns a base64-encoded string representation of the generated QR code.

### Example

#### Request

GET /generate-qrcode?url=<https://example.com\\&color=%235DE2E7\\&pattern=3>

#### Response

If successful, the response will be a PNG image of the generated QR code with the specified color and pattern.

<figure><img src="https://861527455-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCU13r0Y1S0oj9F6D3IVs%2Fuploads%2FTRyFN4nI7xI7g65zP6a4%2FScreenshot%202024-04-18%20131317.png?alt=media&#x26;token=e23f16a0-e006-4688-9ec0-0590938eec6c" alt=""><figcaption></figcaption></figure>

### Error Handling

* If an error occurs during QR code generation, the endpoint will return a 500 Internal Server Error response with an error message.

{% hint style="info" %}
Please note that the `url` parameter is required, while `color` and `pattern` are optional. If `color` is not specified, default color values will be used. The `pattern` parameter allows you to choose the mask pattern used in the QR code generation process.
{% endhint %}
