API that delivers Dynamic One Time Use QR Codes
- Serves Dynamic QR codes that self destruct after 60minutes
- Customizable apperance (color, size, margin and quality)
- Runs MongoDB with TTL expiration
- QR codes can only be used once, ideal for limited URLs such as authorization links or one-time offers
- QRx1 on rapidAPI
To generate a QR code, simply make a GET request to the /qr
endpoint and add a query parameter called data
containing the URL
/qr?data=https://wikipedia.org
The /qr
endpoint accepts a set of options if you want to change the appearance of the QR code
"options": {
"width": 500, // sets the width of the image in pixels
"dark": "987fee", // hex color for the dark parts (the dots/squares)
"light": "fefefe", // hex color for the light parts (the background)
"quality": 1, // sets quality - range from 0-1
"margin": 3 // margin from the code to the edge
}
/qr?data=https://wikipedia.org&width=500&dark=000fff&light=fff&quality=1&margin=3
Set custom expiration of unclaimed QR code
Range from 0 - 600 seconds (maximum lifetime is 60minutes, defaults to 3minutes)
{
"timeout": 10 // Set custom timeout in seconds
}
/qr?data=https://wikipedia.org&timeout=10
If you wish to contribute to this project feel free to open a PR
-
Download and install MongoDB Community Server
-
install nodemon
npm install -g nodemon # or using yarn: yarn global add nodemon
-
In the root folder of the repo, create a
.env
file with the following configuration:MONGO_DB_URI = "mongodb://localhost:27017/URL-shortener"
This is the connection string to your local MongoDB, it may look different depending on your settings.
-
run
npm install
and you are done, the project should now be working on your local machine! -
run
npm start
to start the server and serve the API onhttp://localhost:3000
Since the redirect is done on the same server(localhost) you cannot scan the QR codes with your phone. I would recommentd using a browser plugin or similar software to scan the QR codes.
I'm using this chrome extension
The word "QR Code" is registered trademark of:
DENSO WAVE INCORPORATED