Introduction
Welcome to the PDF417.PRO API! You can use our API to automate the process of creating barcodes.
We have language bindings in Shell, Python and JavaScript! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
You must use the API key to allow access to the API. You can get the key in the settings on your profile page. To do this, you need to register on the pdf417.pro.
We expects for the API key to be included in all API requests to the server in a header that looks like the following:
AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e
Authentication
Get account info
To get account informaion, use this code:
import requests
headers = {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
}
response = requests.get('https://pdf417.pro/api/get_account_info/', headers=headers)
curl -X GET "https://pdf417.pro/api/get_account_info/" \
-H "AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e"
fetch('https://pdf417.pro/api/get_account_info/', {
method: 'GET',
headers: {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e'
}
});
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://pdf417.pro/api/get_account_info/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
]);
$response = curl_exec($ch);
curl_close($ch);
require 'net/http'
uri = URI('https://pdf417.pro/api/get_account_info/')
req = Net::HTTP::Post.new(uri)
req['AUTH-TOKEN'] = '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e'
req_options = {
use_ssl: uri.scheme == 'https'
}
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(req)
end
The above command returns JSON structured like this:
{
"username": "api@demo",
"available_barcodes": 0,
"barcodes_limit": 0,
"barcodes_created": 0,
"api_token": "6c1a0f0f-ce4e-4c73-8f97-31484ce8551e"
}
This endpoint return detailed account information.
HTTP Request
GET https://pdf417.pro/api/get_account_info/
Barcodes
Get available states
import requests
headers = {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
}
response = requests.get('https://pdf417.pro/api/get_available_states', headers=headers)
print(response.json())
curl "https://pdf417.pro/api/get_available_states" \
-H "AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e"
fetch('https://pdf417.pro/api/get_available_states', {
headers: {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e'
}
});
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://pdf417.pro/api/get_available_states');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
]);
$response = curl_exec($ch);
curl_close($ch);
require 'net/http'
uri = URI('https://pdf417.pro/api/get_available_states')
req = Net::HTTP::Get.new(uri)
req['AUTH-TOKEN'] = '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e'
req_options = {
use_ssl: uri.scheme == 'https'
}
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(req)
end
The above command returns JSON structured like this:
{
"available_states": [
{
"state": "California",
"code": "CA",
"revision": "08/29/2017",
},
{
"state": "Colorado",
"code": "CO",
"revision": "10/30/2015",
},
...
]
}
This endpoint retrieves available states. This endpoint retrieves the available states. The endpoint also retrieves a two-letter state code (which is needed to use the next endpoint) as well as a document revision.
HTTP Request
GET https://pdf417.pro/api/get_available_states/
Get brief barcode fields information
import requests
headers = {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
}
params = {
'state': 'CA',
}
response = requests.get('https://pdf417.pro/api/get_barcode_fields_brief_info/', params=params, headers=headers)
print(response.json())
curl "https://pdf417.pro/api/get_barcode_fields_brief_info/?state=CA" \
-H "AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e"
fetch('https://pdf417.pro/api/get_barcode_fields_brief_info/?state=CA', {
headers: {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e'
}
});
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://pdf417.pro/api/get_barcode_fields_brief_info/?state=CA');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
]);
$response = curl_exec($ch);
curl_close($ch);
require 'net/http'
uri = URI('https://pdf417.pro/api/get_barcode_fields_brief_info/')
params = {
:state => 'CA',
}
uri.query = URI.encode_www_form(params)
req = Net::HTTP::Get.new(uri)
req['AUTH-TOKEN'] = '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e'
req_options = {
use_ssl: uri.scheme == 'https'
}
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(req)
end
The above command returns JSON structured like this:
{
"NUMBER": "D1234567",
"FIRSTNAME": "John",
"LASTNAME": "Doe",
"MIDDLENAME": "",
"ADDRESS": "516",
"CITY": "Ronhert",
"ZIP": "875420000",
"CLASS": "C",
"SEX": "",
"DONOR": "",
"DOB": "01151970",
"DOI": "08262021",
"DOE": "01152026",
"DD": "08/25/202165508/AAFD/26",
"ICN": "21237D12345670401",
"RESTRICTIONS": "NONE",
"ENDORSEMENT": "NONE",
"HEIGHT": "69",
"WEIGHT": "160",
"EYE2": "BLK",
"EYE": "BLK",
"HAIR2": "BLK",
"HAIR": "BLK"
}
This endpoint retrieves required field from from the specified barcode and and their default values.
HTTP Request
GET https://pdf417.pro/api/get_barcode_fields_brief_info/
Query Parameters
Parameter | Description |
---|---|
state | Two-letter state code |
Get full barcode fields information
import requests
headers = {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
}
params = {
'state': 'CA',
}
response = requests.get('https://pdf417.pro/api/get_barcode_fields_full_info/', params=params, headers=headers)
print(response.json())
curl "https://pdf417.pro/api/get_barcode_fields_full_info/?state=CA" \
-H "AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e"
fetch('https://pdf417.pro/api/get_barcode_fields_full_info/?state=CA', {
headers: {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e'
}
});
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://pdf417.pro/api/get_barcode_fields_full_info/?state=CA');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
]);
$response = curl_exec($ch);
curl_close($ch);
require 'net/http'
uri = URI('https://pdf417.pro/api/get_barcode_fields_full_info/')
params = {
:state => 'CA',
}
uri.query = URI.encode_www_form(params)
req = Net::HTTP::Get.new(uri)
req['AUTH-TOKEN'] = '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e'
req_options = {
use_ssl: uri.scheme == 'https'
}
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(req)
end
The above command returns JSON structured like this:
{
"fields": [
{
"name": "DL Number",
"input_id": "inputDocumentNumber",
"code": "NUMBER",
"placeholder": "D1234567",
"type": "text",
"pattern": "[a-zA-Z][0-9]{7}",
"required": false
},
{
"name": "First name",
"input_id": "inputFirstName",
"code": "FIRSTNAME",
"placeholder": "John",
"type": "text",
"pattern": "[a-zA-Z\\s]+",
"required": false
},
...
]
}
This endpoint retrieves required field from from the specified barcode.
HTTP Request
GET https://pdf417.pro/api/get_barcode_fields_full_info/
Query Parameters
Parameter | Description |
---|---|
state | Two-letter state code |
Create barcode
This endpoint allows you to create a barcode
Below is a standard set of fields that will work for most states. You can use it for testing.
However, some states require specific fields. Therefore, the correct use case is to get the required set using this endpoint.
import requests
headers = {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
'Content-Type': 'application/x-www-form-urlencoded',
}
data = {
"STATE": "CA",
"NUMBER": "D1234567",
"FIRSTNAME": "John",
"LASTNAME": "Doe",
"MIDDLENAME": "",
"ADDRESS": "516",
"CITY": "Ronhert",
"ZIP": "875420000",
"CLASS": "C",
"SEX": "M",
"DONOR": "NO",
"DOB": "01151970",
"DOI": "08262021",
"DOE": "01152026",
"DD": "08/25/202165508/AAFD/26",
"ICN": "21237D12345670401",
"RESTRICTIONS": "NONE",
"ENDORSEMENT": "NONE",
"HEIGHT": "69",
"WEIGHT": "160",
"EYE": "BRO",
"EYE2": "BRN",
"HAIR": "BRO",
"HAIR2": "BRN",
}
response = requests.post('https://pdf417.pro/api/generate_barcode/', headers=headers, json=data)
print(response.json())
curl -X POST "https://pdf417.pro/api/generate_barcode/" \
-H "AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e" \
-d '{
"STATE": "CA",
"NUMBER": "D1234567",
"FIRSTNAME": "John",
"LASTNAME": "Doe",
"MIDDLENAME": "",
"ADDRESS": "516",
"CITY": "Ronhert",
"ZIP": "875420000",
"CLASS": "C",
"SEX": "",
"DONOR": "",
"DOB": "01151970",
"DOI": "08262021",
"DOE": "01152026",
"DD": "08/25/202165508/AAFD/26",
"ICN": "21237D12345670401",
"RESTRICTIONS": "NONE",
"ENDORSEMENT": "NONE",
"HEIGHT": "69",
"WEIGHT": "160",
"EYE2": "",
"EYE": "",
"HAIR2": "",
"HAIR": ""
}'
fetch('https://pdf417.pro/api/generate_barcode/', {
method: 'POST',
headers: {
'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: '{"STATE": "CA", "NUMBER": "D1234567", "FIRSTNAME": "John", "LASTNAME": "Doe", "MIDDLENAME": "", "ADDRESS": "516", "CITY": "Ronhert", "ZIP": "875420000", "CLASS": "C", "SEX": "M", "DONOR": "NO", "DOB": "01151970", "DOI": "08262021", "DOE": "01152026", "DD": "08/25/202165508/AAFD/26", "ICN": "21237D12345670401", "RESTRICTIONS": "NONE", "ENDORSEMENT": "NONE", "HEIGHT": "69", "WEIGHT": "160", "EYE": "BLU", "HAIR": "BLK"}'
});
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://pdf417.pro/api/generate_barcode/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
'Content-Type: application/x-www-form-urlencoded',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"STATE": "CA", "NUMBER": "D1234567", "FIRSTNAME": "John", "LASTNAME": "Doe", "MIDDLENAME": "", "ADDRESS": "516", "CITY": "Ronhert", "ZIP": "875420000", "CLASS": "C", "SEX": "M", "DONOR": "NO", "DOB": "01151970", "DOI": "08262021", "DOE": "01152026", "DD": "08/25/202165508/AAFD/26", "ICN": "21237D12345670401", "RESTRICTIONS": "NONE", "ENDORSEMENT": "NONE", "HEIGHT": "69", "WEIGHT": "160", "EYE": "BLU", "HAIR": "BLK"}');
$response = curl_exec($ch);
curl_close($ch);
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://pdf417.pro/api/generate_barcode/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'AUTH-TOKEN: 6c1a0f0f-ce4e-4c73-8f97-31484ce8551e',
'Content-Type: application/x-www-form-urlencoded',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"STATE": "CA", "NUMBER": "D1234567", "FIRSTNAME": "John", "LASTNAME": "Doe", "MIDDLENAME": "", "ADDRESS": "516", "CITY": "Ronhert", "ZIP": "875420000", "CLASS": "C", "SEX": "M", "DONOR": "NO", "DOB": "01151970", "DOI": "08262021", "DOE": "01152026", "DD": "08/25/202165508/AAFD/26", "ICN": "21237D12345670401", "RESTRICTIONS": "NONE", "ENDORSEMENT": "NONE", "HEIGHT": "69", "WEIGHT": "160", "EYE": "BLU", "HAIR": "BLK"}');
$response = curl_exec($ch);
curl_close($ch);
The above command returns JSON structured like this:
{
"status": "SUCCESS",
"message": "DONE",
"file_png": "/media/barcodes/2023/03/11/barcode_86672ad3-6dbe-4848-b1f9-eab2b9d02deb.png",
"file_svg": "/media/barcodes/2023/03/11/barcode_86672ad3-6dbe-4848-b1f9-eab2b9d02deb.svg"
}
HTTP Request
GET https://pdf417.pro/api/generate_barcode/
JSON Data
Parameter | Description |
---|---|
STATE | CA |
NUMBER | D1234567 |
FIRSTNAME | John |
LASTNAME | Doe |
MIDDLENAME | |
ADDRESS | 516 |
CITY | Ronhert |
ZIP | 875420000 |
CLASS | C |
SEX | M |
DONOR | NO |
DOB | 01151970 |
DOI | 08262021 |
DOE | 01152026 |
DD | 08/25/202165508/AAFD/26 |
ICN | 21237D12345670401 |
RESTRICTIONS | NONE |
ENDORSEMENT | NONE |
HEIGHT | 69 |
WEIGHT | 160 |
EYE | BLU |
HAIR | BLK |
Errors
The PDF417 API uses the following error codes:
Error Code | Meaning |
---|---|
WRONG_REQUEST_TYPE | Your request type is incorrect. We use only GET and POST request. |
AUTHTOKEN_NOT_FOUND | There is no AUTH-TOKEN header in your request |
WRONG_AUTHTOKEN_FORMAT | Your API key have ivalid format. |
WRONG_AUTHTOKEN | Your API key is wrong. |
STATE_PARAMETER_NOT_FOUND | You didn't specify the state code in the request. |
INVALID_STATE_CODE | Non-existent state code. |
BARCODE_LIMIT | There are not enough available barcodes to generate. |
CONFIG_ERROR | Internal error. Please contact with our support. |
Examples
Here is a example of using our API with Python. Click to show code.
Note you should install requests
package to use your API.
import requests
# Your data
my_data = {
'NUMBER': 'D0000000',
'FIRSTNAME': 'Satoshi',
'LASTNAME': 'Nakamoto',
'DOB': '01011970',
}
# Set header for authentication
headers = { 'AUTH-TOKEN': '6c1a0f0f-ce4e-4c73-8f97-31484ce8551e' }
# Get inforamation info
response = requests.get('https://pdf417.pro/api/get_account_info/', headers=headers)
print('Account info:')
print(response.json())
# Get Califonia fields info
params = { 'state': 'CA'}
response = requests.get('https://pdf417.pro/api/get_barcode_fields_brief_info/', params=params, headers=headers)
print('\nCalifonia fields:')
print(response.json())
# Generate Califonia barcode
data = response.json() # JSON with data received in the previous request
for key, value in my_data.items():
data[key] = value # chage recieved data
print('\nNew data:')
print(data)
response = requests.post('https://pdf417.pro/api/generate_barcode/', headers=headers, json=data)
print('\nResults:')
print(response.json())
# Save barcode file
url = 'https://pdf417.pro' + response.json()['file_png']
r = requests.get(url, allow_redirects=True)
open('barcode.png', 'wb').write(r.content)
print('\nBarcode saved: barcode.png')