Crates.io | qr-api |
lib.rs | qr-api |
version | 0.1.0 |
source | src |
created_at | 2021-05-07 19:22:27.997235 |
updated_at | 2021-05-07 19:22:27.997235 |
description | A simple and fast QRcode encoder/decoder API written in rust. |
homepage | https://github.com/zolagonano/qr-api.git |
repository | https://github.com/zolagonano/qr-api.git |
max_upload_size | |
id | 394367 |
size | 47,509 |
A simple and fast QRcode encoder/decoder API written in rust.
Notes:
https://qr-ende.herokuapp.com
.To encode our text, we need to send a request to the /encode/<your_text>
path, for example:
curl 'https://qr-ende.herokuapp.com/encode/hello'
That command above will give us a 128px in 128px PNG picture of QRCode, encoded with base64:
"iVBORw0KGgoAAAANSUhEUgAAAHQAAAB0CAAAAABx8Un7AAACOElEQVR4nO3NW4obQRBEUc/+F237NAQE1VWSNbjnKy+IeFS24uv3r59nRh9lRh9lRh9lRh9lRh/lNvr193cit7lJRrodfYcZ3ZLb3CQj3Y6+w3Z07dA9j2ToOoddP6M3uueRDF3nsOuPozQkU+x8a0imzYxeGpIpdr41JNPmW6OQkU7maUimzYxeGpJpkJFO5mlIps23RnnI/KohmTYzemlIpuAh86uGZNocR1fSR8FD5unKrp/RG+mj4CHzdGXXb0dPuPV+0hPemxnd4tb7SU94b26jn5ChT/9jRv+J/zbqj9LFU6w+6OToO2b0Ip5i9UEnR99xGw35Awq+0Xe3Zuhw69ci+MAbBd/ou1szdLj1axF84I2Cb/TdrRk63Pq1CD7wRsE3+u7WDB1u/Vo0/VF80CF9MrrjaTOjFz6Am/igQ/pkdMfT5jbqKHhL5iHvfJOegm9m9MJbMg9555v0FHxzG0Uf81HwkPmTvmJGL7zxUfCQ+ZO+Yjv6Cn8K3/E0yNDxrc2MHvEn8B1Pgwwd39rcRh2d6Ft3yfGtQV6Z0S196y45vjXIK9vRtUP61qY7/hUzeiN9a9Md/4rjKA3JtOmOD+mg74wZvTQk06Y7PqSDvjM+HqWIpyGZNrpmRi8NyVHE05BMG13z8Sh4yDwNyas2M3ppSKbgIfM0JK/aHEdXuudxyu+Y0Rvd8zjld2xHT7jdvevhjV91ZUa3uN296+GNX3XlNvoTzOijzOijzOijzOijzOij/AFHTEgf6TUWfAAAAABJRU5ErkJggg=="
Also, we can encode our QRCode with custom width and height using query strings:
curl 'https://qr-ende.herokuapp.com/encode/hello?width=64&height=64'
Now that command above will give us a 64px in 64px PNG picture of QRCode, encoded with base64:
"iVBORw0KGgoAAAANSUhEUgAAADoAAAA6CAAAAADE0BX0AAABJUlEQVR4nO3O0WoDMQxE0eb/P7r1YSrLW1JIi0JeckHSeKRZ9vb58V/e0Yd4cfS2quFyzKgm3nK3WNVwOWZUE2+5W2yrtIBJZaL1VNSxczpOegomF8+J8rxMHkwOnhP1ik7BtMNUtKAVdT3nlJ6JnuS862QntljVOD/rZCdK3Efot4uJqB9Lz3k64kWfTEThoCN5oyZ1bEvAyWX5rWpSx7ZEyEqHHW2WOj5TItQ62NFmqTtRi6x07+6Bri0mokuuslQUh+66MhO9kngF+qXCRNSyiZszPQVOmImWik6FqN6HqagDJ3SIKh9x8IworWdvchBneVssK0tTlYLJQZzlbbGsLE2uV2mvaBWmokV0oj1/MhM98WOFCx+rKiaif+cdfYjXRL8A+QUkELIXPo0AAAAASUVORK5CYII="
The decoding process is the opposite of the encoding process, which means we have to pass the base64 of our QRCode to the API, to decode a QRCode we need to send a request to the /decode/<your_qrcode_base64>
:
For this example, we can use our base64 encoded QRCode that we get in encode section:
"iVBORw0KGgoAAAANSUhEUgAAADoAAAA6CAAAAADE0BX0AAABJUlEQVR4nO3O0WoDMQxE0eb/P7r1YSrLW1JIi0JeckHSeKRZ9vb58V/e0Yd4cfS2quFyzKgm3nK3WNVwOWZUE2+5W2yrtIBJZaL1VNSxczpOegomF8+J8rxMHkwOnhP1ik7BtMNUtKAVdT3nlJ6JnuS862QntljVOD/rZCdK3Efot4uJqB9Lz3k64kWfTEThoCN5oyZ1bEvAyWX5rWpSx7ZEyEqHHW2WOj5TItQ62NFmqTtRi6x07+6Bri0mokuuslQUh+66MhO9kngF+qXCRNSyiZszPQVOmImWik6FqN6HqagDJ3SIKh9x8IworWdvchBneVssK0tTlYLJQZzlbbGsLE2uV2mvaBWmokV0oj1/MhM98WOFCx+rKiaif+cdfYjXRL8A+QUkELIXPo0AAAAASUVORK5CYII="
But we have to encode that in URLencode first:
iVBORw0KGgoAAAANSUhEUgAAADoAAAA6CAAAAADE0BX0AAABJUlEQVR4nO3O0WoDMQxE0eb%2FP7r1YSrLW1JIi0JeckHSeKRZ9vb58V%2Fe0Yd4cfS2quFyzKgm3nK3WNVwOWZUE2%2B5W2yrtIBJZaL1VNSxczpOegomF8%2BJ8rxMHkwOnhP1ik7BtMNUtKAVdT3nlJ6JnuS862QntljVOD%2FrZCdK3Efot4uJqB9Lz3k64kWfTEThoCN5oyZ1bEvAyWX5rWpSx7ZEyEqHHW2WOj5TItQ62NFmqTtRi6x07%2B6Bri0mokuuslQUh%2B66MhO9kngF%2BqXCRNSyiZszPQVOmImWik6FqN6HqagDJ3SIKh9x8IworWdvchBneVssK0tTlYLJQZzlbbGsLE2uV2mvaBWmokV0oj1%2FMhM98WOFCx%2BrKiaif%2BcdfYjXRL8A%2BQUkELIXPo0AAAAASUVORK5CYII%3D
Now we can decode our QRCode:
curl 'https://qr-ende.herokuapp.com/decode/iVBORw0KGgoAAAANSUhEUgAAADoAAAA6CAAAAADE0BX0AAABJUlEQVR4nO3O0WoDMQxE0eb%2FP7r1YSrLW1JIi0JeckHSeKRZ9vb58V%2Fe0Yd4cfS2quFyzKgm3nK3WNVwOWZUE2%2B5W2yrtIBJZaL1VNSxczpOegomF8%2BJ8rxMHkwOnhP1ik7BtMNUtKAVdT3nlJ6JnuS862QntljVOD%2FrZCdK3Efot4uJqB9Lz3k64kWfTEThoCN5oyZ1bEvAyWX5rWpSx7ZEyEqHHW2WOj5TItQ62NFmqTtRi6x07%2B6Bri0mokuuslQUh%2B66MhO9kngF%2BqXCRNSyiZszPQVOmImWik6FqN6HqagDJ3SIKh9x8IworWdvchBneVssK0tTlYLJQZzlbbGsLE2uV2mvaBWmokV0oj1%2FMhM98WOFCx%2BrKiaif%2BcdfYjXRL8A%2BQUkELIXPo0AAAAASUVORK5CYII%3D'
The output of the command above will be hello
.
If you want to run this API by yourself, you have two options(maybe more than two):
Deploying to Heroku is the simplest way to run this API, you only need an account in heroko.com
:
heroku-cli
:heroku login
git clone https://github.com/zolagonano/qr-api.git
heroku-cli
:heroku git:remote -a <your-app-name>
git push heroku master
git clone https://github.com/zolagonano/qr-api.git
cd qr-api
cargo run --release
cargo install qr-api
qr-api
All contributions are welcome but if you don't know what you can do look at this list:
Licensed under MIT license.