PHPackages                             otis22/vetmanager-rest-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. otis22/vetmanager-rest-api

ActiveLibrary[API Development](/categories/api)

otis22/vetmanager-rest-api
==========================

Vetmanager - CRM for veterinary. This is library for conveniently work with Vetmanager REST API.

0.1.11(3y ago)39814[2 issues](https://github.com/otis22/vetmanager-rest-api/issues)[1 PRs](https://github.com/otis22/vetmanager-rest-api/pulls)1MITPHPPHP &gt;=7.3 || ^8.0CI failing

Since Jan 4Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/otis22/vetmanager-rest-api)[ Packagist](https://packagist.org/packages/otis22/vetmanager-rest-api)[ RSS](/packages/otis22-vetmanager-rest-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (17)Used By (1)

vetmanager-rest-api
===================

[](#vetmanager-rest-api)

[![GitHub CI](https://github.com/otis22/vetmanager-rest-api/workflows/CI/badge.svg)](https://github.com/otis22/vetmanager-rest-api/workflows/CI/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/16d8633d3500e1d00df2848eb5f31e62a269a7e95c3c89dfe24c154fd73e1d50/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f74697332322f7665746d616e616765722d726573742d6170692f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/otis22/vetmanager-rest-api?branch=main)

[![Vetmanager Logo](https://camo.githubusercontent.com/a84f3689e4f805f404bf7804e87ae0b534ffb0e77f60f88acde9307bcf893bcb/68747470733a2f2f7665746d616e616765722e72752f77702d636f6e74656e742f7468656d65732f7665746d616e616765722f696d616765732f6865616465724c6f676f2e737667)](https://camo.githubusercontent.com/a84f3689e4f805f404bf7804e87ae0b534ffb0e77f60f88acde9307bcf893bcb/68747470733a2f2f7665746d616e616765722e72752f77702d636f6e74656e742f7468656d65732f7665746d616e616765722f696d616765732f6865616465724c6f676f2e737667)

Vetmanager - veterinary CRM with REST API. vetmanager-rest-api is a library to help working with REST API.

[vetmanager.ru](https://vetmanager.ru/)

[vetmanager REST API Docs](https://help.vetmanager.cloud/article/3029)

[vetmanager REST API in Postman](https://www.postman.com/vetmanager/workspace/vetmanager-api/collection/23836400-17133b76-0f52-4bb4-8b38-28a64781074e)

What for?
---------

[](#what-for)

1. To get full url by providing only domain name (host might change)
2. To validate model name by function uri()
3. To simplify apiKey and token authorization
4. For Sorting, Filtering, etc.
5. To get all sorted and filtered records from model

\*\* Example: Get latest invoice for client id=1 or id=2

```
use GuzzleHttp\Client;
use function Otis22\VetmanagerUrl\url;
use function Otis22\VetmanagerRestApi\uri;
use function Otis22\VetmanagerRestApi\byApiKey;
use Otis22\VetmanagerRestApi\Query\Builder;

$client = new Client([
  'base_uri' => url("myclinic")->asString()
]);

$top = (new Builder())
    ->where('client_id', 'in', [1, 2])
    ->orderBy('invoice_date', 'desc')
    ->top(1);

$response = $client->request(
    'GET',
    uri("invoice")->asString(),
    [
        'headers' => byApiKey("myapikey")->asKeyValue(),
        'query' => $top->asKeyValue()
    ]
);
```

**Warning!** function `url` requires "otis22/vetmanager-url" package.

Installation
------------

[](#installation)

```
composer require otis22/vetmanager-rest-api
```

Usage
-----

[](#usage)

- [For auth](#usage-for-auth)
    1. [Api key auth](#api-key-auth)
    2. [With custom timezone](#with-custom-timezone)
    3. [Token auth](#token-auth)
    4. [Service API key auth](#service-api-key-auth)
- [For create valid URI](#usage-for-create-valid-uri)
    1. [Only model](#only-model)
    2. [Model with particular id](#model-with-particular-id)
- [For filtering and sorting data](#usage-for-filtering-and-sorting)
    1. [Filter example](#how-to-use-filters)
    2. [Full available filter list](#full-filter-list)
    3. [Sorts example](#how-to-use-sorts)
    4. [Both example](#how-to-use-both-sorts-and-filters)
- [How to get all records](#how-to-get-all-records)
- [How to get top n records](#how-to-get-top-n-records)
- [Query Builder](#query-builder)

### Usage for auth

[](#usage-for-auth)

#### Api key auth

[](#api-key-auth)

```
use Otis22\VetmanagerRestApi\Headers;
use Otis22\VetmanagerRestApi\Headers\Auth\ApiKey;

$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);

$authHeaders = new Headers\WithAuth(
    new Headers\Auth\ByApiKey(
        new ApiKey('test-key')
    )
);

$client->request(
    'GET',
    '/rest/api/user/1',
    ['headers' => $authHeaders->asKeyValue()]
);
```

or with function

```
$authHeaders = Otis22\VetmanagerRestApi\byApiKey('test-key');
# use this after ['headers' => $authHeaders->asKeyValue()]
```

#### With custom timezone

[](#with-custom-timezone)

```
use Otis22\VetmanagerRestApi\Headers;
use Otis22\VetmanagerRestApi\Headers\Auth\ApiKey;

$myHeaders = [
    'X-REST-TIME-ZONE' => '+02:00'
];
$allHeaders = new Headers\WithAuthAndParams(
    new Headers\Auth\ByApiKey(
        new ApiKey('test-key')
    ),
    $myHeaders
);

$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);

$client->request(
    'GET',
    '/rest/api/user/1',
    ['headers' => $allHeaders->asKeyValue()]
);
```

#### Token auth

[](#token-auth)

```
use Otis22\VetmanagerRestApi\Headers;
use Otis22\VetmanagerToken;

$authHeaders = new Headers\WithAuth(
    new Headers\Auth\ByToken(
        new Credentials\AppName("myapp"),
        new Token\Concrete("mytoken")
    )
);

$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);

$client->request(
    'GET',
    '/rest/api/user/1',
    ['headers' => $authHeaders->asKeyValue()]
);
```

or with function

```
$authHeaders = Otis22\VetmanagerRestApi\byToken('myapp', 'mytoken');
# use this after ['headers' => $authHeaders->asKeyValue()]
```

### Service API key auth

[](#service-api-key-auth)

```
use Otis22\VetmanagerRestApi\Headers;
use Otis22\VetmanagerRestApi\Headers\Auth\ServiceName;
use Otis22\VetmanagerRestApi\Headers\Auth\ApiKey;

$authHeaders = new Headers\WithAuth(
    new Headers\Auth\ByServiceApiKey(
        new ServiceName('name')
        new ApiKey('key')
    )
);

$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);

$client->request(
    'GET',
    '/rest/api/user/1',
    ['headers' => $authHeaders->asKeyValue()]
);
```

or with function

```
$authHeaders = Otis22\VetmanagerRestApi\byServiceApiKey('service', 'api key');
# use this after ['headers' => $authHeaders->asKeyValue()]
```

### Usage example to create valid URI

[](#usage-example-to-create-valid-uri)

#### Only model

[](#only-model)

```
use Otis22\VetmanagerRestApi\URI;
use Otis22\VetmanagerRestApi\Model;

$uri = new URI\OnlyModel(
    new Model('invoice')
);

$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);

// request to /rest/api/invoice
$client->request('GET', $uri->asString());
```

or with function

```
$uriString = \Otis22\VetmanagerRestApi\uri('invoice')->asString();
```

#### Model with particular id

[](#model-with-particular-id)

```
use Otis22\VetmanagerRestApi\URI;
use Otis22\VetmanagerRestApi\Model;

$uri = new URI\WithId(
    new Model('invoice'),
    5
);

$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);

// request to /rest/api/invoice/5
$client->request('GET', $uri->asString());
```

or with function

```
$uriString = \Otis22\VetmanagerRestApi\uri('invoice', 5)->asString();
```

### Usage example for filtering and sorting

[](#usage-example-for-filtering-and-sorting)

#### How to use Filters

[](#how-to-use-filters)

```
use Otis22\VetmanagerRestApi\Query\Filters;
use Otis22\VetmanagerRestApi\Query\Filter\EqualTo;
use Otis22\VetmanagerRestApi\Model\Property;
use Otis22\VetmanagerRestApi\Query\Filter\Value\StringValue;

$filters = new Filters(
    new EqualTo(
        new Property('propertyName'),
        new StringValue('propertyValue')
    )
    # ... we can use mach more filters new Filters($filterOne, $filterTwo, ... );
);

$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);

$client->request(
    'GET',
    '/rest/api/user/1',
    [
        'headers' => $authHeaders->asKeyValue(),
        'query' => $filters->asKeyValue()
    ]
);
```

#### Full filter list

[](#full-filter-list)

- Otis22\\VetmanagerRestApi\\Query\\Filter\\EqualTo - where property is equal to value
- Otis22\\VetmanagerRestApi\\Query\\Filter\\InArray - where property is in list
- Otis22\\VetmanagerRestApi\\Query\\Filter\\LessOrEqualThan - where property is less or equal than value
- Otis22\\VetmanagerRestApi\\Query\\Filter\\LessThan - where property is less than value
- Otis22\\VetmanagerRestApi\\Query\\Filter\\Like - where property is like value(for using MySQL LIKE)
- Otis22\\VetmanagerRestApi\\Query\\Filter\\MoreOrEqualThan - where property is more or equal than value
- Otis22\\VetmanagerRestApi\\Query\\Filter\\MoreThan - where property more than value
- Otis22\\VetmanagerRestApi\\Query\\Filter\\NotEqualTo - where propery is not equal to value
- Otis22\\VetmanagerRestApi\\Query\\Filter\\NotInArray - where property is not in list

#### How to use Sorts

[](#how-to-use-sorts)

```
use Otis22\VetmanagerRestApi\Query\Sorts;
use Otis22\VetmanagerRestApi\Query\Sort\AscBy;
use Otis22\VetmanagerRestApi\Query\Sort\DescBy;
use Otis22\VetmanagerRestApi\Model\Property;

$sorts = new Sorts(
    new AscBy(
        new Property('propertyName')
    ),
    new DescBy(
        new Property('property2Name')
    )
);

$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);

$client->request(
    'GET',
    '/rest/api/user/1',
    [
        'headers' => $authHeaders->asKeyValue(),
        'query' => $sorts->asKeyValue()
    ]
);
```

#### How to use both Sorts and Filters

[](#how-to-use-both-sorts-and-filters)

```
use Otis22\VetmanagerRestApi\Query\Query;
...

$query = new Query(
    new Filters(...),
    new Sorts(...)
);

$client = new GuzzleHttp\Client(['base_uri' => 'http://some.vetmanager.ru']);

$client->request(
    'GET',
    '/rest/api/user/1',
    [
        'headers' => $authHeaders->asKeyValue(),
        'query' => $query->asKeyValue()
    ]
);
```

### How to get all records

[](#how-to-get-all-records)

```
$paged =  PagedQuery::forGettingAll(
    new Query(
        // Sorts Required!
    )
);
$result = [];
do {
    $response = json_decode(
        strval(
            $client->request(
                'GET',
                uri('invoice')->asString(),
                [
                    'headers' => $headers->asKeyValue(),
                    'query' => $paged->asKeyValue()
                ]
            )->getBody()
        ),
        true
    );
    $paged = $paged->next();
    $result = array_merge(
        $response['data']['invoice'],
        $result
    );
} while (count($result) < $response['data']['totalCount']);
```

### How to get top n records

[](#how-to-get-top-n-records)

```
$top1 =  PagedQuery::forGettingTop(
    new Query(
        // Sorts Required!
    ),
    1
);
$response = json_decode(
    strval(
        $client->request(
            'GET',
            uri('invoice')->asString(),
            [
                'headers' => $headers->asKeyValue(),
                'query' => $top1->asKeyValue()
            ]
        )->getBody()
    ),
    true
);
```

### Query Builder

[](#query-builder)

top(n) - return PagedQuery instance for getting top n records by user filter and sort order.

```
$top = (new Builder())
    ->where('client_id', 'in', [1, 2])
    ->orderBy('id', 'desc')
    ->top(1);
```

paginateAll(): return PagedQuery instance for getting all records by user filter and sort order

```
$paginateAll = (new Builder())
    ->where('client_id', 'in', [1, 2])
    ->orderBy('id', 'desc')
    ->paginateAll();
```

paginate(limit, offset): return PagedQuery instance for getting records with custom limit and offset by user filter and sort order

```
$paginate = (new Builder())
    ->where('client_id', 'in', [1, 2])
    ->orderBy('id', 'desc')
    ->paginate(10, 20);
```

You can use [filter class](#full-filter-list) string operator instead.

```
use Otis22\VetmanagerRestApi\Query\Filter;

(new Builder())
    ->where('client_id', Filter\InArray::class, [1, 2])
    ->where('pet_id', Filter\NotEqualTo::class, 5)
```

Contributing
------------

[](#contributing)

To run all tests

```
make all
```

To connect to terminal

```
make exec
```

*Default php version is 8.1*. Use PHP\_VERSION= to use your version. Only versions 8.0 and 8.1 are available for now.

```
make all PHP_VERSION=8.0
# run both
make all PHP_VERSION=8.0 && make all PHP_VERSION=8.1
```

*For integration tests copy .env.example to .env and fill with yours values*

all commands

```
# security check
make security
# composer install
make install
# composer install with --no-dev
make install-no-dev
# check code style
make style
# run static analyze tools
make static-analyze
# run unit tests
make unit
#  check coverage
make coverage
# check integration, .env required
make integration
```

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~71 days

Total

12

Last Release

1167d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61097a8108512dbb04c61cea2c5e2291b31dacc2404e882b2aa12688e587b088?d=identicon)[vromanichev](/maintainers/vromanichev)

---

Top Contributors

[![otis22](https://avatars.githubusercontent.com/u/378373?v=4)](https://github.com/otis22 "otis22 (62 commits)")[![danilyer228](https://avatars.githubusercontent.com/u/33658320?v=4)](https://github.com/danilyer228 "danilyer228 (8 commits)")[![cursoragent](https://avatars.githubusercontent.com/u/199161495?v=4)](https://github.com/cursoragent "cursoragent (2 commits)")[![ionov-e](https://avatars.githubusercontent.com/u/82158159?v=4)](https://github.com/ionov-e "ionov-e (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/otis22-vetmanager-rest-api/health.svg)

```
[![Health](https://phpackages.com/badges/otis22-vetmanager-rest-api/health.svg)](https://phpackages.com/packages/otis22-vetmanager-rest-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
