dub icon indicating copy to clipboard operation
dub copied to clipboard

Generate QR code programmatically with API

Open steven-tey opened this issue 1 year ago • 5 comments

Would love the ability to generate & download QR codes programmatically via the API.

steven-tey avatar Nov 07 '23 17:11 steven-tey

Hello @steven-tey can you suggest any articles or something so that I can start working on this?

VishalMCF avatar Nov 07 '23 22:11 VishalMCF

Currently the only way to download the QR code in SVG, PNG or jpeg is via the dashboard and this is a manual task that has to be done for each link that you want the QR code from.

This can be cumbersome for projects that want to automate this process in their workflow or to deliver the QR code in desired format for 3rd party use.

Example project on how I want to use this via an API endpoint: I have got an event website that hosts sport events that organizers can post them selfs. Currently developing a feature that will create a flyer for this event on inserts. What I want is a shortlink to be created on example.com/code to example2.com/events/233839 I also want a QR code to be created for each event inserted in the database. This QR code then should be provided to the organizers so that they can use it for custom designs. I also want to use this QR code for the flyer that I will create for them.

The api endpoint to create a QR code should be the same as in the GUI.

  • Color code can be added as an option
  • Path to Logo file?
  • File type: SVG, PNG, JPG

Not sure how the download would work since the PNG and JPEG or SVG are probably created on on demand and not stored anywhere.

NLDylan avatar Nov 08 '23 16:11 NLDylan

Is it possible that we store the QR code in any object storage. And then remove it after some amount of time. We can have a purge process to remove QR codes after some point of time. It will increase the cost ofcourse because I am new and I am not sure whether we have S3 bucket or not in Dub

On Wed, Nov 8, 2023, 21:44 NLDylan @.***> wrote:

Currently the only way to download the QR code in SVG, PNG or jpeg is via the dashboard and this is a manual task that has to be done for each link that you want the QR code from.

This can be cumbersome for projects that want to automate this process in their workflow or to deliver the QR code in desired format for 3rd party use.

Example project on how I want to use this via an API endpoint: I have got an event website that hosts sport events that organizers can post them selfs. Currently developing a feature that will create a flyer for this event on inserts. What I want is a shortlink to be created on example.com/code to example2.com/events/233839 I also want a QR code to be created for each event inserted in the database. This QR code then should be provided to the organizers so that they can use it for custom designs. I also want to use this QR code for the flyer that I will create for them.

The api endpoint to create a QR code should be the same as in the GUI.

  • Color code can be added as an option
  • Path to Logo file?
  • File type: SVG, PNG, JPG

Not sure how the download would work since the PNG and JPEG or SVG are probably created on on demand and not stored anywhere.

— Reply to this email directly, view it on GitHub https://github.com/steven-tey/dub/issues/452#issuecomment-1802215207, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQYCBCUWEWS7VDPRS52WERTYDOVWJAVCNFSM6AAAAAA7BQ2YIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBSGIYTKMRQG4 . You are receiving this because you commented.Message ID: @.***>

VishalMCF avatar Nov 08 '23 17:11 VishalMCF

Maybe @steven-tey if there is any storage at the moment. And if the PNG and JPG only get created and not stored anywhere currently.

NLDylan avatar Nov 09 '23 07:11 NLDylan

@NLDylan @steven-tey maybe the client should use the API to generate QR code and store it in its own infrastructure. We can reduce the latency using redis-like caching with some preconfigured cache key time out policy. Does it sound good?

VishalMCF avatar Nov 09 '23 09:11 VishalMCF

Good news everyone – you can now generate QR codes via our REST API! Here are the docs for the QR code endpoint.

Whenever you create/retrieve a short link on Dub, you’ll also get a qrCode attribute that gives you the full URL of the QR code for the short link (e.g. https://api.dub.co/qr?url=https://dub.sh/try)

Feel free to try this out and let me know if you have any questions!

steven-tey avatar Jan 29 '24 23:01 steven-tey