QRCode Generator is a REST API designed to generate QRCode.
This API is able to deviler the QRCode as an Base64 encoded PNG or directly as an image url.
Use Docker
docker pull justinbriard/qrcode
Use git clone and run the binary as a service
git clone https://github.com/jbriard/qrcode.git
- Python 3.x
- Pip
- bottle
- paste
- requests
- urllib3
- boto3
- pyqrcode
- pypng
You need to setup some Environment Variable to run QRCode Generator in order to use bucket management. /!\ QRCOde Generator didn't manage the S3 storage, if you don't clean the bucket, the generated image will stay forever. I personaly use a Life Cycle rule to delete all the image older than 2 days.
export S3BUCKET_URL="https://s3.fr-par.scw.cloud"
export ACCESS_KEY="SCW4KFF46W"
export SECRET_KEY="1ff11952-fed1-4a94-95e7-83fdb9a66367"
export S3BUCKET_NAME="otbm-qrcode"
export S3BUCKET_REGION="fr-par"
export URL="https://api.qrcode.otbm.fr"
python run.py
Body Json
You need to send this body, if you omit any of the elements you will get an error.
{
"text":"hello World",
"size":"10",
"result_format":"base64"
}
You need to set this 3 elements :
- text
- size
- result_format
text This is literraly the text you want to encode in the QRCode.
size It's the size of the generated image 1 is the smallest and 40 is the largest.
result_format Is the format is the format in which the image will be made available.
- If set to base64, you will get the image encoded in base64
- If set to link, you will get an URL to the generated image.
Endpoint v1/qrcode
Base64
curl --request POST \
--url http://[server]:[port]/v1/elements \
--header 'content-type: application/json' \
--data '{
"text":"hello World",
"size":"10",
"result_format":"base64"
}'
result:
{
"status": "ok",
"result": "iVBORw0KGgoAAAANSUhEUgAAAEIAAABCAQAAAADLLz1FAAAAoklEQVR4nK3SMQrEMAxEUYFbQ64imNYwVzekDfgqBrUCbcgmZJVto+pVHyEkcU6XlyRl8SlMogEWWQpZUZ7q81/D7CFaGVfvkhRAJSuCled+lyYw+mRSYzO3SBr7BqMySbkYPKsYZ5es6u7tqNzCdPSjcksrTZkFXVcpkRQBI7Kk2AZlEm2/d40kRWvfyq/qagsfgs6RRYttY9ZeGM2z3v2hD7edgzQjGFQ7AAAAAElFTkSuQmCC"
}
Link
curl --request POST \
--url http://[server]:[port]/v1/elements \
--header 'content-type: application/json' \
--data '{
"text":"hello World",
"size":"10",
"result_format":"link"
}'
result:
{
"status": "ok",
"result": "https://s3.fr-par.scw.cloud/otbm-qrcode/9KGB3KRG2MSCY6TY4L.png"
}
Endpoint /checkhealth
curl --request GET \
--url http://[server]:[port]/checkhealth
result:
{
"status": "ok"
}
Endpoint /version
curl --request GET \
--url http://[server]:[port]/version
result:
1.4
You can see more info on https://qrcode.otbm.fr/ or test the API https://api.qrcode.otbm.fr
Under development