ZPK » APIS » SDK » PHP

SDK PHP

A composer-installable SDK that will allow you to access all ZPK APIs

Installation via composer (recommended)


We recommend using the composer version so that your project can always update to the latest version of the SDK.

Example composer require
composer require zpksystems/phpzpk

Setting up the app


All API calls must specify an application.

The zpkApplication class determines a specific application by its application_id and an authentication api_key.

These applications can be created and managed in the dashboard of your panel.


Example apkApplication
<?php

use zpksystems\phpzpk\zpkApplication;

require 'vendor/autoload.php';

$app = new zpkApplication('app_id','key');

ZPK Translate

Using the SDK to translate text and detect languages using the ZPK Translate API

Translation


Call the translation API by initializing a translator, in this example you can see a request to translate 2 sentences. In the first case the source language will be autodetected. In the second we indicate the source language.

Ejemplo traducir dos textos
<?php
require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkTranslator;

$app = new zpkApplication('app_id','key');


$t = new zpkTranslator( $app );

// Add a text to be translated to italian, english and french.
// Source language is autodetected
$t->addTranslation(
    'Esto es una frase en español',
    ['it','en','fr']
);

// Add another translation
// but sending a source language
$t->addTranslation(
    'Esto es una frase en español',
    ['it','en','fr'],
    'es'
);

echo json_encode($t->translate(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Getting all llanguages


You can get the entire list of available languages in our translation API.

Keep in mind that this request also has a cost, we recommend caching this data and not performing this query more than once every 48 hours.

Example Languages list
<?php
require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkTranslator;

$app = new zpkApplication('app_id','key');
$t = new zpkTranslator( $app );

echo json_encode($t->getLanguages(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Vin Analyzer

Extract and parse Vehicle Identification Numbers (VIN) data, or auto-correct incorrect VIN numbers.

Analyzing VIN numbers


Call the parsing API by initializing a VINS parser

Example analize 2 VINs
<?php
require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkTranslate;

$app = new zpkApplication('app_id','key');

$vinA = new zpkVinAnalyzer( $app );

// Add a valid vin
$vinA->addVin('L6TCX2E70ME005154');

// Add an invalid vin (missing character)
$vinA->addVin('6TCX2E70ME005154');

echo json_encode($vinA->analyze(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Filtering VINs by zone, country, manufacturer, or brand.


Our API allows you to establish filters that will alter the score of the detected VINs. These filters can be used to exclude VIns that meet one or more criteria, or to give priority to other VINs in case an incorrect number can be corrected to different valid VINs.

In the following example, it will send a VIN with the first three digits VS5 that belongs to the manufacturer 'renault' without establishing any filter. The ZPK API will return the data of a vehicle from the manufacturer renault.

In a second element, we establish a filter that penalizes the renault brand. The API will determine that the VIN sent contains a writing error because we have penalized renault, and will return a Seat brand vehicle because its manufacturer code is VSS, and VSS is optically very similar to VS5

Example excludeBrand
<?php
require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkVinAnalyzer;

$app = new zpkApplication('app_id','key');


// Add a valid VIN from a renault vehicle
// don't use filters

$vinA = new zpkVinAnalyzer( $app );
$vinA->addVin('VS5ZZZ5F1P6510989');

echo "VIN VS5ZZZ5F1P6510989 analysis without filter:\n";

echo json_encode($vinA->analyze(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE)."\n\n";


// Add the same VIN and add a penalizer for
// all vehicles from 'renault'

$vinA = new zpkVinAnalyzer( $app );
$vinA->addVin('VS5ZZZ5F1P6510989');
$vinA->excludeBrand('renault');

echo "VIN VS5ZZZ5F1P6510989 excluding renault:\n";

echo json_encode($vinA->analyze(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);


Obtaining countries, manufacturers, and brands.


To get all this data in an updated way you can make the following calls in the SDK.

Keep in mind that these requests also have a cost, we recommend caching this data since it is added and modified only occasionally.

Example manufacturers,brands,countries
<?php
require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkTranslate;

$app = new zpkApplication('app_id','key');


// Add a valid VIN from a renault vehicle
// don't use filters

$vinA = new zpkVinAnalyzer( $app );

// Make 3 requests
$data = [
    'manufacturers'=>$vinA->getManufacturers(),
    'countries'=>$vinA->getCountries(),
    'brands'=>$vinA->getBrands(),
];

echo json_encode($data,
  JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

VIN OCR

Extract and parse Vehicle Identification Numbers(VIN) data or auto-correct incorrect VIN numbers from scanned documents and images.

Analyzing an image to extract the VIN


Call the OCR detection API initializing a VIN OCR

Example Image extraction
<?php
require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkVinOcr;

$app = new zpkApplication('app_id','key');

ocr = new zpkVinOcr( $app );

// Add an image
$ocr->setImageFile('image.png');

echo json_encode($ocr->scan(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Using scoring filters for optimal recognition.


Like the VINAnalyzer API, VINOCR can use filters that will alter the internal scoring of possible VIN numbers considered during optical recognition.

This example will send an image that could match multiple manufacturers:

In this example we will send a VIN number that is missing the first character, and therefore could belong to different manufacturers. For this example we will assume that we work with a fleet of European vehicles.

We will use a filter to give VINs of European vehicles a higher score, forcing the API to give a higher preference score to these vehicles

Example Using filters
<?php
require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkVinOcr;

$app = new zpkApplication('app_id','key');

ocr = new zpkVinOcr( $app );

// Add an image
$ocr->setImageFile('image.png');

// Add a positive filter for european
// vehicles.
$ocr->addFilter([
    'zone'=>'Europe',
    'score'=>3
]);

echo json_encode($ocr->scan(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Getting all considered VINs


You can request the API to return, together with the results, all the VINs that have been taken into account when determining a correct VIN. That can help you create filters specific to your use case.

To do this we will simply call the includeConsideredVins() method

Example includeConsideredVins
<?php

$ocr->includeConsideredVins();

Obtaining manufacturers, brands, and countries.


Your application can query the manufacturers, brands, models and countries that this API can return with a call to different methods.

Keep in mind that consulting this information also has a cost, we recommend caching this data to minimize API calls.

Example manufacturers,brands,...
<?php
require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkVinOcr;

$app = new zpkApplication('app_id','key');

ocr = new zpkVinOcr( $app );

// Add an image
$ocr->setImageFile('image.png');

// Add a positive filter for european
// vehicles.
$data = [
    'manufacturers'=>$ocr->getManufacturers(),
    'countries'=>$ocr->getCountries(),
    'brands'=>$ocr->getBrands(),
];

echo json_encode($data,
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Plate Scanner OCR

Extract vehicle license plates from images and documents

Extracting the license plate from an image


Call the OCR detection API by initializing a License Plate Scanner.

Example Extract from image
<?php

require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkPlateScanner;

$app = new zpkApplication('app_id','key');

$scanner = new zpkPlateScanner( $app );

// Add an image
$scanner->setImageFile('plate.png');

echo json_encode($scanner->scan(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Specifying zones


You can send one or more geographic zones to be used as an API hint at detection time with the setZoneHints method.

Example Zones
<?php

require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkPlateScanner;

$app = new zpkApplication('app_id','key');

$scanner = new zpkPlateScanner( $app );

// Add an image
$scanner->setImageFile('plate.png');

// Set region hints
$scanner->setRegionHints(['es','it']);

echo json_encode($scanner->scan(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Regions in strict mode


With a call to enableStrictRegions() we can force the API to consider only and exclusively license plates from the zones specified above, discarding all license plates that do not comply with the pattern of the specified zones.

Example stric mode regions
<?php

require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkPlateScanner;

$app = new zpkApplication('app_id','key');

$scanner = new zpkPlateScanner( $app );

// Add an image
$scanner->setImageFile('plate.png');

// Set region hints
$scanner->setRegionHints(['es','it']);

// Enable strict mode
$scanner->enableStrictRegions();

echo json_encode($scanner->scan(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Getting all zones


A call to getAllRegions() will return a list of all regions supported by the API. Remember that this request has a cost, we recommend saving this data in cache.

Example getting regiones
<?php

require 'vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkPlateScanner;

$app = new zpkApplication('app_id','key');
$scanner = new zpkPlateScanner( $app );

echo json_encode($scanner->getAllRegions(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);


ZPK SMS

Send SMS text messages to mobile phones, supports 216 countries.

Sending a SMS message

Intialize an SmsRequest to send one or more messages.

Example sending SMS
<?php

$application = new zpkApplication($application_id,$api_key);

$sendRequest = new zpkSmsSendingRequest($application);

$sms = new zpkSMS("+34634568046");
$sms->setFrom("First");
$sms->setMessage("SMS test message, the first one :)");

$sendRequest->add($sms);

$response = $r->send();

var_dump($response);

Checking price rates

Up-to date prices can be requested, initialize a PriceRequest.

Example Get pricing
<?php
// Initialize zpk application
$application = new zpkApplication($application_id,$api_key);

// Price request
$pRequest = new zpkSmsPriceRequest( $application );

$data = $pRequqest->getPrices();

echo json_encode($data,JSON_PRETTY_PRINT);

ZPK Moderation API

Text message moderation, and source behavior analysis

Analyze messages


Example Analyze messages
<?php
require __DIR__.'/../../vendor/autoload.php';

use zpksystems\phpzpk\zpkApplication;
use zpksystems\phpzpk\zpkModerator;


$application = new zpkApplication('app_id','api_key');
$moderator = new zpkModerator($application);

$moderator->addText( ['text'=>'I want to k**l myself.'] );


echo json_encode($moderator->scan(),
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

Get statistics from a specific source


Example Get source stats
<?php

$application = new zpkApplication('app_id','api_key');
$moderator = new zpkModerator($application);

$stats = $moderator->getSourceStats('User-A');

echo json_encode($stats,
 JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);

echo "END\n";

Pricing

All ZPK System APIs have on-demand pricing, you pay only for the use of the APIs. No monthly fees.

API Price
Vin OCR
VinOcr
EUR 0,003 for each scanned image
Vin Analyzer
VinAnalyzer
EUR 0,004 for each request
EUR 0,003 for each extra VIN on the request
IA Images
IA Images
Starting at 0,038 €
ZPK Translate
ZPK Translate
First 600.000 characters per month / Free
1 EUR foreach 62.500 additional characters
HTML To Image
HTML To Image
0,0020 for reach capture request.
Moderation API
Moderation API
EUR 0,0010 for moderation (up to 500 characters)
EUR 0,0050 per query to statistics from a message source.
Plate Scanner
PlateScanner
EUR 0,001 foreach scanned image
EUR 0,010 for each regions list request
ZPK SMS
ZPK SMS
Spain : 0.0495 €
France : 0.0724 €
United States : 0.0220 €

Getting credit


By creating an account at ZPK Systems and validating your data, 2,00 euros will be added free of charge to your account so that you can carry out tests.

Cree una cuenta ahora, y obtenga crédito gratuito para realizar la implementación. Si ya está registrado, acceda a su panel para gestionar su crédito disponible o añadir fondos.

Does your project not use PHP?

Our API can be implemented in a multitude of languages.

If your project does not use PHP you can use the HTTP API. Our APIS work with HTTP communication based on JSON requests and responses. Facilitating implementation in virtually any programming language.

See the http API, endpoints, and parameters in the specific documentation for each API.