This is official Aymakan PHP SDK. It can be used to integrate with Aymakan APIs. The following features lists are available in this SDK.For more details about our API requests and responses click here.
- PHP 7.1 or higher
- Curl 7.18 or higher
composer require aymakan/php-sdk
Your Aymakan access token are available in your customer dashboard account
Setting configuration while instantiating the Client object
Used for composer based installation
// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader'
// Used for composer based installation
require __DIR__ . '/vendor/autoload.php';
// Instantiate the client class
$client = new \Aymakan\Client();
// set token
$client->setApikey('ENTER-YOUR-API-KEY-HERE');
// set Sandbox testing mode
$client->setSandbox(true);
Below is an example on how to fetch api status through ping API call:
$response = $client->pingApi();
echo $response . "\n";
Below is an example on how to fetch all cities through GetCities API call:
$response = $client->getCityList();
echo $response . "\n";
Creates a new shipment , to find out more details about request parameters
checkout our
Create Shipping API Documentation
$data = array(
//request parameters
);
$response = $client->createShipment($data);
echo $response . "\n";
Below is an example on how to create bulk shipments:
Parameter | Type | Mandatory |
---|---|---|
shipments |
Array of shipments | Yes |
$data = array(
"shipments" =>
array(
# data for shipment 1
),
array(
# data for shipment 2
),
...
...
)
$response = $client->createBulkShipment($data);
echo $response . "\n";
Create Bulk Shippings API Documentation
Creates a reverse pickup shipment , to find out more details about request parameters
checkout our
Create Reverse Pickup Shipping API Documentation
$data = array(
//request parameters
);
$response = $client->createReversePickupShipment($data);
echo $response . "\n";
Below is an example on how to track shipments through TrackShipment API call. Shipments can be fetched as a single shipment or multiple shipments at the same time . It is important to note that the tracking numbers should be sent in an array format.
Parameter | Type | Mandatory |
---|---|---|
Tracking Number | Array | Yes |
//Track single shipment
$response = $client->trackShipment(['AY120266']);
//Track multiple shipments
$response = $client->trackShipment(['AY669001659', '143862', '143866']);
echo $response . "\n";
Below is an example on how to track shipments by reference number. Shipments can be fetched by reference number as a single shipment or multiple shipments at the same time . It is important to note that the reference number numbers should be sent in an array format.
Parameter | Type | Mandatory |
---|---|---|
Reference Number | Array | Yes |
//Track single shipment by reference number
$response = $client->shipmentByReference(['200018179']);
//Track Multiple shipment by reference number
$response = $client->shipmentByReference(['200018179','test-200018179']);
echo $response . "\n";
Shipment By Reference API Details
Below is an example of how to Cancel Shipment :
Parameter | variable name | Type | Mandatory |
---|---|---|---|
Tracking Number | tracking |
Array | Yes |
$response = $client->cancelShipment(['tracking' => "AY120266"]);
echo $response . "\n";
Below is an example on how to cancel shipments by reference number. Shipments can be fetched by reference number as a single shipment or multiple shipments at the same time . It is important to note that the reference number numbers should be sent in an array format.
Parameter | Type | Mandatory |
---|---|---|
Reference Number | Array | Yes |
# Track single shipment by reference number
$response = $client->cancelShipmentByReference(['200018179'])
# Track Multiple shipment by reference number
$response = $client->cancelShipmentByReference(['200018179','test-200018179'])
echo $response . "\n";
Cancel shipment By Reference API Details
Below is an example on how to make the Shipping AWB label Printing API call. This API requires a single tracking number associated with the customer account , and returns a URL to download the pdf file for all AWB
Parameter | variable name | Type | Mandatory |
---|---|---|---|
Tracking Code | tracking_number |
String | Yes |
$response = $client->getShipmentLabel("AY120266");
echo $response . "\n";
Shipping AWB label Printing API Details
Below is an example on how get Bulk Shipping AWB label . This API requires an array with tracking numbers associated with the customer account. If all the tracking numbers are found for that associated account, this API returns a URL to download the pdf file for all AWB.
Parameter | Type | Mandatory |
---|---|---|
Tracking Number | Array | Yes |
//Get multiple shipment label
$client->getBulkShipmentLabel(['AY669001659', '143862', '143866', '143892']);
echo $response . "\n";
Bulk Shipping AWB label Printing API Details
Below is an example on how to make the Customer Shippings API call:
$response = $client->getCustomerShipments();
echo $response . "\n";
This API fetches all current customer pickup requests.
$response = $client->pickupRequest()
echo $response . "\n";
Get Pickup Requests API Details
Below is an example on how to create a pickup request.
Parameter | variable name | Type | Mandatory |
---|---|---|---|
Date format should be "Y-m-d" | pickup_date |
String | Yes |
Time slot | time_slot |
String | Yes |
The customer's name | contact_name |
String | Yes |
The customer's phone | contact_phone |
String | Yes |
The customer's address | address |
String | Yes |
Amount of shipments | shipments |
Integer | Yes |
$data = array(
"pickup_date" => "2022-12-02",
"time_slot" => "afternoon",
"contact_name" => "example",
"contact_phone" => "059999999",
"address" => "example address",
"shipments" => 2
);
$response = $client->createPickupRequest($data)
echo $response . "\n";
Create Pickup Request API Details
Below is an example on how to cancel a pickup request.
Parameter | variable name | Type | Mandatory |
---|---|---|---|
Pickup request id | pickup_request_id |
Integer | Yes |
$data = array(
"pickup_request_id" => 4021
}
$response = $client->cancelPickupRequest($data)
echo $response . "\n";
Cancel Pickup Request API Details
Below is an example on how to fetch all time slots available to current customer.
Parameter | variable name | Type | Mandatory |
---|---|---|---|
Date format should be "Y-m-d" | pickup_date |
String | Yes |
$response = $client->timeSlots("2022-12-02")
echo $response . "\n";
Manages address associated to customer account.
Fetches ALL addresses associated to customer account.
$response = $client->getAddress();
echo $response . "\n";
Below is an example on how to make the create address associated to customer account.
Parameter | variable name | Mandatory |
---|---|---|
Title | title |
Yes |
Name | name |
Yes |
email |
Yes | |
Address | address |
Yes |
Neighbourhood | neighbourhood |
Yes |
Postcode | postcode |
Yes |
Phone | phone |
Yes |
Description | description |
Yes |
$data = array(
"title" => "Mr",
"name" => "example",
"email" => "example@example.com",
"city" => "Riyadh",
"address" => 123,
"neighbourhood" => "Al-Sahafah",
"postcode" => "11534",
"phone" => 0599999999,
"description" => "create address example"
);
$response = $client->createAddress($data);
echo $response . "\n";
Below is an example on how to update address associated to customer account.
Parameter | variable name | Mandatory |
---|---|---|
ID | id |
Yes |
Title | title |
Yes |
Name | name |
Yes |
email |
Yes | |
Address | address |
Yes |
Neighbourhood | neighbourhood |
Yes |
Postcode | postcode |
Yes |
Phone | phone |
Yes |
Description | description |
Yes |
$data = array(
"id" => 3,
"title" => "Mr",
"name" => "example",
"email" => "example@example.com",
"city" => "Riyadh",
"address" => 123,
"neighbourhood" => "Al-Sahafah",
"postcode" => "11534",
"phone" => 0599999999,
"description" => "update address example"
);
$response = $client->updateAddress($data);
echo $response . "\n";
Below is an example on how to delete an address associated to customer account.
Parameter | variable name | Mandatory |
---|---|---|
ID | id |
Yes |
$data = array(
"id" => 544,
);
$response = $client->deleteAddress($data);
var_dump($response);
Web Hooks are a convenient way to receive real time updates for your shipments as soon as a status is updated. Web Hooks can be used to update customer internal systems with the latest shipments statuses.
Below is an example on how to get webhooks .
$response = $client->getWebHook();
echo $response . "\n";
Below is an example on how to add webhook .
Parameter | variable name | Mandatory |
---|---|---|
Web Hook URL | webhook_url |
Yes |
$data = array(
"webhook_url" => "https://testings.com"
);
$response = $client->createWebHook($data);
echo $response . "\n";
Below is an example on how to update Webhook .
Parameter | variable name | Mandatory |
---|---|---|
ID | id |
Yes |
Web Hook URL | webhook_url |
Yes |
$data = array(
"id"=> 219 ,
"webhook_url" => "https://www.testings.com"
);
$response = $client->updateWebHook($data);
echo $response . "\n";
Below is an example on how to delete webhooks .
$response = $client->deleteWebHook()
echo $response . "\n";