almalio / api-php
Almalio.com API Wrapper
Installs: 5 263
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
pkg:composer/almalio/api-php
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpstan/phpstan: ^1.10
This package is auto-updated.
Last update: 2025-12-15 13:16:35 UTC
README
Instalation
composer require almalio/api-php
Usage
$api = new Almalio('API_KEY'); $result = $api->addContact('SITE_KEY', [ 'order_number' => '12345', 'order_total' => 123.45, 'order_currency' => 'EUR', 'order_delivery_type' => 1, 'firstname' => 'John', 'lastname' => 'Doe', 'email' => 'mail@example.org', 'phone' => '+421905000000', 'street' => 'Main Street 123', 'city' => 'New York', 'postcode' => '12345', 'country_code' => 'SK', ]); // Check if the request was successful, otherwise check the error message, validate data (see rules lower) and try again
Available methods
__construct(string $apiKey, string $apiUrl = 'https://almalio.com/api/v1')
Create new instance of Almalio API wrapper.
Parameters
string $apiKey- API keystring $apiUrl- API URL
addContact(string $siteKey, array $data)
Add contact to the Almalio system.
Parameters
string $siteKey- Site keyarray $data- Contact dataorder_number- Order number (required|string|between:1,255)order_total- Order total (required|numeric|min:0)order_currency- Order currency code (required|string|size:3) - ISO 4217, e.g. EURorder_delivery_type- Order delivery type (required|integer|in:1,2) - ENUM, see belowfirstname- First name (required|string|between:1,255|regex:/^[\p{L} ]+$/u)lastname- Last name (required|string|between:1,255|regex:/^[\p{L} ]+$/u)email- Email (required|email|between:1,255)phone- Phone (required|string|between:1,255)street- Street (required|string|between:1,255|regex:/^(?=.*\d)(?=.*[a-zA-Z].*[a-zA-Z]).+$/)city- City (required|string|between:1,255|regex:/^[\p{L} ]+$/u)postcode- Postcode (required|string|between:1,255)country_code- Country code (required|string|size:2) - ISO 3166-1 alpha-2, e.g. SKtesting- Testing mode (optional|boolean) - do not send on production, it is only used to validate the request
Order delivery type ENUM
1- Delivery to the address2- Personal pickup
Responses
Validation error
Status code: 400
{
"message": "Validation failed",
"error": [
"The street field format is invalid.",
"The postcode field is required."
]
}
Imported
Status code: 200
{
"message": "Contact added to queue successfully",
"success": true
}
Duplicate
Status code: 200
{
"message": "Contact already imported",
"success": false
}
Test successful
Status code: 200
{
"message": "Test successful",
"success": true,
"data": {
"order_number": "12345",
"order_total": 123.45,
"order_currency": "EUR",
"order_delivery_type": 1,
"firstname": "John",
"lastname": "Doe",
"email": "mail@example.org",
"phone": "+421905000000",
"street": "Main Street 123",
"city": "New York",
"postcode": "12345",
"country_code": "SK"
}
}