Download the PHP package airalo/sdk without Composer
On this page you can find all versions of the php package airalo/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sdk
Airalo PHP SDK
Airalo's PHP SDK provides extremely simple integration with the RESTful API and adds extra layer of security on top.
The SDK supports:
- auto authentication and encryption
- auto caching and rate limit handling
- packages fetching of local, global, country and all combined
- packages auto pagination on endpoints
- package ordering
- package bulk order allowing different packages and quantities to be bought at once
- package topup ordering
- unified response format of type
EasyAccess
which allows key access as associative array and/or object at the same time without json_decode usage - compatible with Unix, macOS, Windows operating systems
Requisites
- PHP version >=
7.4
cURL
extension enabled in php.ini (enabled by default)sodium
extension enabled in php.ini (enabled by default)
Autoloading
We highly encourage to always use composer
as a dependency managed and simply require Airalo's SDK by simply running this CLI command:
Then in your codebase you will have access to the Airalo
class by having required autoload.php
file already.
For legacy projects or projects which still do not use composer, please make sure to require alo.php
custom autoloader from the SDK:
Initialization
-
Object usage:
- Static usage:
EasyAccess responses
The SDK provides simple and yet powerful way to interact with the response objects.
By default you will be able to access them as an associative array or object without the need to modify them.
Example:
Methods Interface
Packages
NOTE:
Passingtrue
to$flat
parameter makes the response significantly more compact and easy to handle. However it differes than the main one returned from the endpoints. Be mindful in which occassions you will need the original and in which the compact version. Happy coding!
public function getAllPackages(bool $flat = false, $limit = null, $page = null): ?EasyAccess
Fetching all of Airalo's packages. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object, example:
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
public function getLocalPackages(bool $flat = false, $limit = null, $page = null): ?EasyAccess
Fetching local Airalo packages. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object.
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
public function getGlobalPackages(bool $flat = false, $limit = null, $page = null): ?EasyAccess
Fetching global Airalo packages. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object.
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
public function getCountryPackages(string $countryCode, bool $flat = false, $limit = null): ?EasyAccess
Fetching country specific Airalo packages. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object.
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
public function getSimPackages(bool $flat = false, $limit = null, $page = null): ?EasyAccess
Fetching Sim only Airalo packages without top ups. By default the response will be the same as the one from packages REST endpoint (more here: https://partners-doc.airalo.com/#d775be27-4c08-45d1-9faa-8ec2c4f97bf5). Passing $flat
as true will return package objects data in a single data object.
By default no limit number of packages will be applied if $limit
is empty
By default it will paginate all pages (multiple calls) or if $page
is provided it will be the starting pagination index.
Orders
public function order(string $packageId, int $quantity, ?string $description = null): ?EasyAccess
Places an order for a given package id (fetched from any of the packages calls) and calls order
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#768fbbc7-b649-4fb5-9755-be579333a2d9
public function orderAsync(string $packageId, int $quantity, ?string $webhookUrl = null, ?string $description = null): ?EasyAccess
Places an async order for a given package id (fetched from any of the packages calls) and calls order-async
endpoint of the REST API.
Full information can be found here: https://partners-doc.airalo.com/#c8471dfc-83d6-4d36-ac8e-6dce2d55a49e
public function orderWithEmailSimShare(string $packageId, int $quantity, array $esimCloud, ?string $description = null): ?EasyAccess
Places an order for a given package id (fetched from any of the packages calls) and calls order
endpoint of the REST API.
Accepts additional array $esimCloud with mandatory key to_email
(a valid email address) belonging to an end user and sharing_option
one of or both: ['link', 'pdf'] with optional list of copy_address
.
The end user will receive an email with a link button (and pdf attachment if selected) with redirect to a fully managed eSIM page with installation instructions, usage checks.
This method is recommended if you do not intend to handle eSIM management for your users in your applications.
Full response example can be found here: https://partners-doc.airalo.com/#768fbbc7-b649-4fb5-9755-be579333a2d9
public function orderBulk(array $packages, ?string $description = null): ?EasyAccess
Parameters: array $packages
where the key is the package name and the value represents the desired quantity.
Parallel ordering for multiple packages (up to 50 different package ids) within the same function call. Example usage:
Example response:
NOTE:
Each package id is a key in the returned response. The quantity ofsims
object represents the ordered quantity from the initial call.
If an error occurs in one of the parallel orders, the error REST response will be assigned to the package id key, so you must make sure to validate each response
Example:
public function orderAsyncBulk(array $packages, ?string $webhookUrl = null, ?string $description = null): ?EasyAccess
Parameters: array $packages
where the key is the package name and the value represents the desired quantity.
Parallel async ordering for multiple packages (up to 50 different package ids) within the same function call. Example usage:
Example response:
NOTE:
Each package id is a key in the returned response. The quantity ofsims
object represents the ordered quantity from the initial call.
If an error occurs in one of the parallel async orders, the error REST response will be assigned to the package id key, so you must make sure to validate each response
public function orderBulkWithEmailSimShare(array $packages, array $esimCloud, ?string $description = null): ?EasyAccess
Parallel ordering for multiple packages (up to 50 different package ids) within the same function call. Example usage:
Accepts additional array $esimCloud with mandatory key to_email
(a valid email address) belonging to an end user and sharing_option
one of or both: ['link', 'pdf'] with optional list of copy_address
.
The end user will receive an email with a link button (and pdf attachment if selected) with redirect to a fully managed eSIM page with installation instructions, usage checks.
This method is recommended if you do not intend to handle eSIM management for your users in your applications.
Full response example can be found here: https://partners-doc.airalo.com/#768fbbc7-b649-4fb5-9755-be579333a2d9
Vouchers
public function voucher(int $usageLimit, int $amount, int $quantity, ?bool $isPaid = false, string $voucherCode = null): ?EasyAccess
calls voucher
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#768fbbc7-b649-4fb5-9755-be579333a2d9
Example response:
Esim Vouchers
public function esimVouchers(array $vouchers): ?EasyAccess
calls voucher/esim
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#5a48bb8d-70d1-4030-ad92-4a82eb979281
Example response:
Topups
public function topup(string $packageId, string $iccid, ?string $description = null): ?EasyAccess
Places a topup for a given package id and iccid of an eSIM and calls topups
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#e411d932-2993-463f-a548-754c47ac7c00
Sim Usage
public function simUsage(string $iccid): ?EasyAccess
Places an $iccid with user iccid and calls simUsage
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#e411d932-2993-463f-a548-754c47ac7c00
Example response can be found in the API documentation (link above).
public function simUsageBulk(array $iccids): ?EasyAccess
Places an array of $iccids and calls simUsage
endpoint of the REST API in parallel for each of the iccids.
Full response example can be found here: https://partners-doc.airalo.com/#e411d932-2993-463f-a548-754c47ac7c00
Example response can be found in the API documentation (link above).
NOTE:
Each iccid is a key in the returned response.
If an error occurs in one of the parallel usage calls, the error REST response will be assigned to the iccid key, so you must make sure to validate each responseSim Topups
public function getSimTopups(string $iccid): ?EasyAccess
Fetches all available topups for the provided iccid
belonging to an ordered eSIM.
Full response example can be found here: https://partners-doc.airalo.com/#13535dd3-c337-4122-8e97-2fdb93263e86
Example response can be found in the API documentation (link above).
Sim Package History
public function getSimPackageHistory(string $iccid): ?EasyAccess
Fetches package history for the provided iccid
belonging to an ordered eSIM.
Full response example can be found here: https://partners-doc.airalo.com/#5e9bdbcb-dce5-42f7-8e41-d7c1d2dba7a5
Exchange Rates
public function getExchangeRates(?string $date=null, ?string $source=null, ?string $from=null, ?string $to=null): ?EasyAccess
Fetches exchange rates for the provided parameters.
$date
- date in the format YYYY-MM-DD
. If not provided it takes the current date
$source
- always null
$from
- Always USD
$to
- comma separated list of currency codes to convert to. Example 'AUD,GBP,EUR'
Example response for the call:
Example response can be found in the API documentation (link above).
Sim Instructions
public function getSimInstructions(string $iccid, string $language = "en"): ?EasyAccess
Places an $iccid with user iccid & $language with language like en,de. by default its en and calls getSimInstructions
endpoint of the REST API.
Full response example can be found here: https://partners-doc.airalo.com/#768fbbc7-b649-4fb5-9755-be579333a2d9
Example response:
Techincal notes
- Encrypted auth tokens are automatically cached in filesystem for 24h.
- Caching is automatically stored in filesystem for 1h.
- Utilize the
mock()
methods in Airalo and AiraloStatic for seamless stubbing with your own unit tests. - All exceptions thrown by the SDK are instance of
AiraloException
. - To clear all cache (not recommended to clear cache on production often) you can just do the following: