---
title: "WT AmoCRM library (Joomla) — Core API - WebTolk websites development, Joomla Extensions"
description: "Core reference for WT AmoCRM (Webtolk\\Amocrm): the Amocrm facade, the AmocrmRequest HTTP client, exceptions, traits, and the EntityInterface contract; explains how to safely work with AmoCRM entities inside Joomla."
url: "https://web-tolk.ru/en/dev/biblioteki/wt-amo-crm-library/documentation/wt-amocrm-library-joomla-core-api"
date: "2026-06-19T04:38:38+00:00"
language: "en-GB"
---

# WT AmoCRM library (Joomla) — Core API

WT Amo CRM library - Documentation

**Category:** [Libraries](https://web-tolk.ru/en/dev/biblioteki)

[Project](https://web-tolk.ru/en/dev/biblioteki/wt-amo-crm-library)[Versions](https://web-tolk.ru/en/dev/biblioteki/wt-amo-crm-library/versions)[Documentation](https://web-tolk.ru/en/dev/biblioteki/wt-amo-crm-library/documentation)[GitHub](https://github.com/WebTolk/WT-Amo-CRM-library-for-Joomla-4)

Core reference for WT AmoCRM (Webtolk\Amocrm): the Amocrm facade, the AmocrmRequest HTTP client, exceptions, traits, and the EntityInterface contract; explains how to safely work with AmoCRM entities inside Joomla.

Documentation for the core classes of the `Webtolk\Amocrm` library located in `lib_webtolk_amocrm/src`.

## Quick start (recommended path)

```
use Webtolk\Amocrm\Amocrm;

$amocrm = new Amocrm();

// Retrieve a list of leads
$leads = $amocrm->leads()->getLeads(['limit' => 50]);

// Load a contact by ID
$contact = $amocrm->contacts()->getContactById(123456);
```

Requirements:

- The **System - WT AmoCRM** system plugin is enabled.
- Plugin parameters include `amocrm_domain`, `amocrm_client_id`, `amocrm_client_secret`, and (for OAuth) `amocrm_code`.
- `com_ajax` is used for the webhook/AJAX entry point.

## Class `Amocrm`

The library facade. In 1.3.0+ the primary workflow is to reach entities through the magic `__call()` helpers: `$amocrm->leads()`, `$amocrm->contacts()`, `$amocrm->users()`, etc.

Most methods on this class are **marked as deprecated** as of 1.3.0 and remain only for backward compatibility. Prefer the entity classes exposed via `__call()` and `AmocrmRequest`.

### Key methods

- `__construct()` — loads the library language files and instantiates `AmocrmRequest`.
- `getRequest(): AmocrmRequest` — returns the request object (useful for low-level calls).
- `__call(string $name, array $_): EntityInterface` — creates an entity instance from `Webtolk\Amocrm\Entities`.

### Deprecated methods (1.3.0, slated for removal in 2.0)

Use the entity equivalents:

- `getAccountInfo()` > `account()->getAccountInfo()`
- `getLeadById()` > `leads()->getLeadById()`
- `createLeads()` > `leads()->createLeads()`
- `createLeadsComplex()` > `leads()->createLeadsComplex()`
- `getTags()` > `tags()->getTags()`
- `getLeadsPiplines()` > `leads()->getLeadsPiplines()`
- `getCustomFields()` > `customfields()->getCustomFields()`
- `getContactsCustomFields()` > `customfields()->getContactsCustomFields()`
- `getCompaniesCustomFields()` > `customfields()->getCompaniesCustomFields()`
- `getCustomersCustomFields()` > `customfields()->getCustomersCustomFields()`
- `getContacts()` > `contacts()->getContacts()`
- `addContacts()` > `contacts()->addContacts()`
- `getUserById()` > `users()->getUserById()`
- `getNotes()` > `notes()->getNotes()`
- `addNotes()` > `notes()->addNotes()`

Token management helpers (`authorize`, `setToken`, `storeTokenData`, etc.) are deprecated as well.

## Class `AmocrmRequest`

Low-level HTTP client with authorization, token cache, and error handling.

### Core methods

- `getResponse(string $endpoint, ?array $data, string $request_method = 'POST', string $content_type = 'application/x-www-form-urlencoded', bool $custom_endpoint = false): object` - Executes a REST call against AmoCRM. - If `$custom_endpoint = true`, the path is used “as is” (without the `/api/v4` prefix). - Returns the response object or an error object `{ error_code, error_message }`.
- `canDoRequest(): bool` - Confirms that credentials and token are present.
- `getPluginParams(): Registry` - Reads `system/wt_amocrm` plugin parameters.
- `getAmoCRMHost(): Uri` - Builds a `Uri` for the AmoCRM domain with enforced `https`.
- Token helpers: - `setToken()`, `setTokenType()`, `setTokenExpiresIn()` - `storeTokenData()` — caches the token in Joomla. - `storeRefreshToken()` — saves the refresh token back to the library parameters.

### Facts

- Supports `token_type = long_term` (reads `long_term_token`).
- Optionally throttles calls when `avoid_rest_api_limits_exceeding = 1` (150 ms sleep).
- Logs errors to `lib_webtolk_amo_crm.log.php`.

### Sample low-level request

```
use Webtolk\Amocrm\Amocrm;

$amocrm = new Amocrm();
$request = $amocrm->getRequest();

// Retrieve account information
$account = $request->getResponse('/account', null, 'GET', 'application/json');
```

## Exceptions

- `AmocrmException` — the library’s general exception.
- `AmocrmClientException` — deprecated (1.3.0).

## Traits

- `LogTrait` - `saveToLog(string $data, string $priority = 'NOTICE', string $log_name = 'lib_webtolk_amo_crm')` - Writes to `logs/{log_name}.log.php` and pushes a Joomla message.
- `DataErrorTrait` - `receivedEmptyData()` — builds a standard error object. - `wrongEntityType()` — builds an error when the entity type is invalid.

## Interface `EntityInterface`

Minimum contract: the constructor accepts an `AmocrmRequest`.

```
public function __construct(AmocrmRequest $request);
```

## JSON-LD Schema

```json
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "@id": "https://web-tolk.ru/#/schema/BreadcrumbList/17",
    "itemListElement": [
        {
            "@type": "ListItem",
            "position": 1,
            "item": {
                "@id": "https://web-tolk.ru/en",
                "name": "Home"
            }
        },
        {
            "@type": "ListItem",
            "position": 2,
            "item": {
                "@id": "https://web-tolk.ru/en/dev",
                "name": "Joomla extensions"
            }
        },
        {
            "@type": "ListItem",
            "position": 3,
            "item": {
                "@id": "/en/dev/biblioteki",
                "name": "Libraries"
            }
        },
        {
            "@type": "ListItem",
            "position": 4,
            "item": {
                "@id": "/en/dev/biblioteki/wt-amo-crm-library",
                "name": "WT Amo CRM library"
            }
        },
        {
            "@type": "ListItem",
            "position": 5,
            "item": {
                "@id": "/en/dev/biblioteki/wt-amo-crm-library/documentation",
                "name": "Documentation"
            }
        },
        {
            "@type": "ListItem",
            "position": 6,
            "item": {
                "name": "WT AmoCRM library (Joomla) — Core API"
            }
        }
    ]
}
```

```json
{
    "@context": "https://schema.org",
    "@graph": [
        {
            "@type": "Organization",
            "@id": "https://web-tolk.ru/#/schema/Organization/base",
            "name": "WebTolk",
            "url": "https://web-tolk.ru/",
            "logo": {
                "@type": "ImageObject",
                "@id": "https://web-tolk.ru/#/schema/ImageObject/logo",
                "url": "images/webtolk-1080p.jpg",
                "contentUrl": "images/webtolk-1080p.jpg",
                "width": 1920,
                "height": 1080
            },
            "image": {
                "@id": "https://web-tolk.ru/#/schema/ImageObject/logo"
            },
            "sameAs": [
                "https://github.com/WebTolk",
                "https://github.com/sergeytolkachyov",
                "https://vk.com/web_tolk",
                "https://vk.com/webtolkru",
                "https://tenchat.ru/sergeytolkachyov",
                "https://t.me/sergeytolkachyov",
                "https://t.me/webtolkru"
            ]
        },
        {
            "@type": "WebSite",
            "@id": "https://web-tolk.ru/#/schema/WebSite/base",
            "url": "https://web-tolk.ru/",
            "name": "WebTolk websites development, Joomla Extensions",
            "publisher": {
                "@id": "https://web-tolk.ru/#/schema/Organization/base"
            }
        },
        {
            "@type": "WebPage",
            "@id": "https://web-tolk.ru/#/schema/WebPage/base",
            "url": "https://web-tolk.ru/en/dev/biblioteki/wt-amo-crm-library/documentation/wt-amocrm-library-joomla-core-api",
            "name": "WT AmoCRM library (Joomla) — Core API - WebTolk websites development, Joomla Extensions",
            "description": "Core reference for WT AmoCRM (Webtolk\\Amocrm): the Amocrm facade, the AmocrmRequest HTTP client, exceptions, traits, and the EntityInterface contract; explains how to safely work with AmoCRM entities inside Joomla.",
            "isPartOf": {
                "@id": "https://web-tolk.ru/#/schema/WebSite/base"
            },
            "about": {
                "@id": "https://web-tolk.ru/#/schema/TechArticle/base"
            },
            "inLanguage": "en-GB",
            "breadcrumb": {
                "@id": "https://web-tolk.ru/#/schema/BreadcrumbList/17"
            }
        },
        {
            "@type": "TechArticle",
            "headline": "WT AmoCRM library (Joomla) — Core API",
            "url": "https://web-tolk.ru/en/dev/biblioteki/wt-amo-crm-library/documentation/wt-amocrm-library-joomla-core-api",
            "description": "Core reference for WT AmoCRM (Webtolk\\Amocrm): the Amocrm facade, the AmocrmRequest HTTP client, exceptions, traits, and the EntityInterface contract; explains how to safely work with AmoCRM entities inside Joomla.",
            "mainEntityOfPage": {
                "@type": "WebPage",
                "url": "https://web-tolk.ru/en/dev/biblioteki/wt-amo-crm-library/documentation/wt-amocrm-library-joomla-core-api"
            },
            "keywords": [
                "joomla",
                " amocrm",
                " php",
                " documentation"
            ]
        }
    ]
}
```
