API Calling Syntax
The syntax for calling the QRC Web Server is as follows:
Create a new QRC
http://{server}:{port}/{format}/Create?text={text}[&{options}]
View a QRC image
http://{server}:{port}/Image/{id}
List available QRCs
http://{server}:{port}/{format}/Cache
Information about the QRC Server
http://{server}:{port}/{format}/Info
whereby:
{server} is the name or IP address of the computer where the QRC Web Server is running
{port} is the network port that the server is runing on (default 9010)
{format} is either XML, JSON or Image, and determines how the response is returned
{text} is the text to encode as a QRC (e.g., a URL, a person, an e-mail, etc.)
{options} are additional QRC formatting options
{id} is a unique identifer assigned to each generated QRC
Data Elements
Data elements included in XML and JSON responses include:
QRCodeText |
Text encoded into the QRC |
QRCodeID |
Unique ID assigned to the QRC |
QRCodeFile |
File created on the computer (only if the FILESYSTEM_SAVE property is set to TRUE) |
QRCodeAppearance |
Appearnce parameters used to create the QRC |
QRCExpires |
Date and time when the QRC expires and is no longer accessible via /Image |
Example
For example, to create a QRC for the URL http://www.google.com using default formatting:
http://{server}:{port}/{format}/Create?text=http://www.google.com
which returns the following XML (/XML/Create):
<?xml version='1.0'?>
<QRCServerResponse>
<QRCResponse>
<QRCodeAppearance>OutputSize=150;PixelRoundness=1.0;PixelColorStart=#555555</QRCodeAppearance>
<QRCodeExpires>2022-10-11 13:42:10</QRCodeExpires>
<QRCodeFile>/tmp/QRCServer/03e8ca1b-e9a1-440e-b4ee-2e5416d44a33.png</QRCodeFile>
<QRCodeID>03e8ca1b-e9a1-440e-b4ee-2e5416d44a33</QRCodeID>
<QRCodeText>http://www.google.com</QRCodeText>
</QRCResponse>
</QRCServerResponse>
or the following JSON (/JSON/Create):
{
"QRCServerResponse": {
"QRCResponse": {
"QRCodeAppearance": "OutputSize=150;PixelRoundness=1.0;PixelColorStart=#555555",
"QRCodeExpires": "2022-10-11 13:42:10",
"QRCodeFile": "/tmp/QRCServer/03e8ca1b-e9a1-440e-b4ee-2e5416d44a33.png",
"QRCodeID": "03e8ca1b-e9a1-440e-b4ee-2e5416d44a33",
"QRCodeText": "http://www.google.com"
}
}
}
To download this QRC using the QRCodeID data element:
http://{server}:{port}/Image/03e8ca1b-e9a1-440e-b4ee-2e5416d44a33
Automatic Image Redirect
To be automatically redirected (HTTP 302) to the QRC image, rather than receiving an XML or JSON response, append the parameter:
&redirect=true
to the /Create URL. The QRC image will still be cached, and can stil be retrieved (with /Image) until it has expired. This provides a short-cut method for creating and retrieving the QRC image with one request. However, any errors will still be returned as XML or JSON.
Quotes & Spaces
Note that if the data include spaces, you must include quotes (%22) around the data, and the URLs must be properly escaped if using a browser or if making a GET request. For example, to encode the following person data as a QRC:
FirstName=John;LastName=Doe;Company=Acme Inc;JobDepartment=Engineering;PhoneMobile=555-123-4567
since the data must be quoted (%22) because the company name contains a space (%20), the browser or GET request would be:
http://{server}:{port}/XML/Create?text=%22FirstName=John;LastName=Doe;Company=Acme%20Inc;JobDepartment=Engineering;PhoneMobile=555-123-4567%22
The QRC Server will also accept POST requests as well as GET requests, which still requires quoting text with spaces, but does not require URL encoding. For example, using curl POST from the command line:
$ curl -d
'text="FirstName=John;LastName=Doe;Company=Acme Inc;JobDepartment=Engineering;PhoneMobile=555-123-4567;URL=https://www.acme.com"'
http://minerva.colornet.com:9010/XML/Create
Supported Appearance Parameters
Although the default QRC appearance parameters are configured within the QRC Server properties file, the following parameters may be overridden when creating a QRC:
o OutputSize
o ColorSpace
o RotationAngle
o PixelRoundness
o PixelColorType
o BackgroundColorType
o PixelColorStart
o PixelColorEnd
o GradientAngle
o BottomText
o BottomTextSize
o BottomTextColor
For example:
http://{server}:{port}/{format}/Create?text=http://www.google.com&OutputSize=200&PixelColorStart=%230000FF
This will create a 200x200 (OutputSize=200) pixel QRC that is Blue (PixelColorStart=#0000FF). Note that the hash character ('#') has been escaped as %23.
Please see the QR Factory 3 Appearance web page for details on these parameters.