PHPackages                             trevweb/cin7-core-api-v2-client - 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. trevweb/cin7-core-api-v2-client

ActiveLibrary[API Development](/categories/api)

trevweb/cin7-core-api-v2-client
===============================

A Cin7 Core API V2 Client for PHP

v1.0.1(4mo ago)18↓85.7%MITPHPPHP &gt;=8.2

Since Feb 21Pushed 4mo agoCompare

[ Source](https://github.com/TrevStoke/Cin7CoreClient)[ Packagist](https://packagist.org/packages/trevweb/cin7-core-api-v2-client)[ RSS](/packages/trevweb-cin7-core-api-v2-client/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Cin7 Core API V2 Client for PHP
===============================

[](#cin7-core-api-v2-client-for-php)

A PHP client for interacting with the Cin7 Core (formerly DEAR Inventory) API V2.

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

[](#installation)

```
composer require trevweb/cin7-core-api-v2-client:^1.0
```

Usage
-----

[](#usage)

### Initialise the client

[](#initialise-the-client)

```
$accountId = 'your_account_id';
$applicationKey = 'your_application_key';
$client = new Cin7CoreApiV2Client($accountId, $applicationKey);
```

### Get a specific product

[](#get-a-specific-product)

```
try {
    $product = $client->get(Cin7CoreEndpoints::PRODUCT, ['Name' => 'Big Tyre']);
    print_r($product);
} catch (Exception $e) {
    // Handle exception
    echo "Error fetching product: " . $e->getMessage();
}
```

### Create a sale

[](#create-a-sale)

```
try {
    $saleData = [
            "CustomerID" => "guid-of-customer",
            "TaxRule" => "Tax on Sales",
            "Location" => "Main Warehouse",
            // ... other required fields
        ];

    $response = $client->post('sale', $saleData);
    echo "Created Sale ID: " . $response['ID'];
} catch (Exception $e) {
    echo "Error creating sale: " . $e->getMessage();
}
```

### Fetch all products (pagination)

[](#fetch-all-products-pagination)

```
try {
    $products = $client->fetchAll(Cin7CoreEndpoints::PRODUCT, 'Products');
    foreach ($products as $product) {
        print_r($product);
    }
} catch (Exception $e) {
    echo "Error fetching products: " . $e->getMessage();
}
```

Examples
--------

[](#examples)

See the [examples](examples) directory for more usage examples. Place a file in the examples directory named 'cin7-example-api-credentials.php' with the following contents:

```
