Barcode API

  • 0

Barcode API

Tags : 

Barcodes offer an efficient and versatile way to store data, and are especially useful in inventory management systems. Luckily, creating one in FileMaker has been made easier by using Feedzon’s fast and free API.

Feedzon’s free Barcode API service supports 25+ formats, giving you plenty of options to choose from. We’ll keep things simple in this tutorial.

Create the Necessary Fields in your FileMaker app
To get started, make sure you have a container field ready to insert a barcode into before you create your script. The container field in this example will be called ‘Barcode’. We’ll also be creating a number field called ‘BarcodeNumber’ that will store the data used to create the barcode.

Get an API Service Key from Feedzon

1. Create a free account here.
2. Once you’ve logged in, go to ‘My Services’ and click ‘New Service’.
3. Choose ‘Barcode’ for the Service Type and give it a name.
4. Click ‘Add Service’
5. You should now see your unique Service Key needed for the Barcode API calls.

Choose a Barcode Format
There are two main categories of barcode formats, 1D and 2D, and both have several to choose from. The amount of data that you can store in each barcode varies with the different format types, so make sure you choose an appropriate format for your use case. Check out Feedzon’s documentation for detailed explanations on each format, and the parameters that each one accepts to customize your barcode. Once you’ve chosen one, you’ll need its TypeCode value for the API call (see below). For this tutorial we’ll be using the Code 128 format which offers high density encoding to produce a condensed barcode.

Create the Script
1. Create a new script. We’ll call ours BarcodeDemo in this example.

2. Inside your script, create some variables to contain the data needed for the API call:
    $key = {your Service Key here} //Find this in your Feedzon account in ‘My services’
    $type = {your chosen CodeType here} //We’ll use “code128” for our example
    $data = {your barcode data here} //We’ll be referencing our BarcodeNumber field
    $url = “https://api.feedzon.com/barcode/1.1/CreateBarcode.fz?” & “ServiceKey=”        & $key & “&TypeCode=” & $type & “&Data=” & $data

3. Use the ‘Insert from URL’ script step to send your first API call to Feedzon. Set the ‘Target’ option to save the response into a variable called $result,  or to a global field of your choice. Use the $url variable you created earlier for the ‘Specify URL’ option. Note: We’ll be making two separate API calls to generate our barcode. First we’ll send a request to get a ‘Task ID’, then we’ll use that in our second request to retrieve our barcode.

4. After your ‘Insert from URL’ script step, check the $result variable for errors. A successful response will contain two values. The first value will be “0” meaning no errors occurred, and the second value will be the Task ID.

5. Use an ‘If’ script step to make sure no errors occurred and the $result variable contains a Task ID as it’s second value. If so, proceed with your script – otherwise return an error message and exit the script.

6. Create two additional variables for your second API call:
    $task_id = GetValue ( $result ; 2 )
    $url2 = “https://api.feedzon.com/barcode/1.1/DownloadFile.fz?ServiceKey=” &          $key & “&TaskID=” & $task_id

7. Use another ‘Insert from URL’ script step to retrieve your barcode image. Set the ‘Target’ option to save the response into your container field. Use the new $url2 variable for the ‘Specify URL’ option. Note: For this to work, you’ll need to be on a layout that has the container field on it when you run this portion of the script. Use a Go To Layout script step to navigate to the appropriate layout first if needed.

8. Run your script. If all goes well, a new barcode will be inserted into your Barcode container field.

 

Now you can create fully customized and robust barcodes with only a few additional parameters using this API. You can find Feedzon’s free Barcode API demo file and full documentation here. How have the use of barcodes have helped or improved your business?

Want barcodes added to your database? Contact Eleanor at eleanor@app.works.


Leave a Reply

20 − 8 =