PHPackages                             mtrdesign/cottoncart-api-php-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. mtrdesign/cottoncart-api-php-client

ActiveLibrary[API Development](/categories/api)

mtrdesign/cottoncart-api-php-client
===================================

The Cotton Cart API Client Library enables you to work with Cotton Cart APIs on your server. This library supports JSON an API output format.

1175PHP

Since Jun 25Pushed 6y ago6 watchersCompare

[ Source](https://github.com/mtrdesign/cottoncart-api-php-client)[ Packagist](https://packagist.org/packages/mtrdesign/cottoncart-api-php-client)[ RSS](/packages/mtrdesign-cottoncart-api-php-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

Cotton Cart APIs Client Library for PHP
=======================================

[](#cotton-cart-apis-client-library-for-php)

About
-----

[](#about)

The Cotton Cart API Client Library enables you to work with Cotton Cart APIs on your server. This library supports JSON and XML API output format.

Feedback and bug reports are appreciated.

Requirements
------------

[](#requirements)

To use this client, you will need:

- [PHP 5.3.2 or higher](http://www.php.net/)
- [PHP cURL extension](http://php.net/manual/en/book.curl.php)
- Composer dependency manager  (Optional, but recommended)

Getting started
---------------

[](#getting-started)

If you encounter any problems, or if you have any questions please email .

#### General

[](#general)

Cotton Cart uses a RESTFul API based at . Each API call has a corresponding URL. Each API URL follows the pattern:

```
$versionID/$method_group/$method.$format
```

where:

- $versionID is a short string identifying the API version (e.g. 'v1')
- $method\_group is a word identifying the function group (e.g. 'catalogue)
- $method is the API call name within the funciton group (e.g. 'stores')
- $format is the desired response format either "xml" or "json"

Sample URLs:

#### Authenticated calls

[](#authenticated-calls)

Certain API calls require authentication, while others are anonymous. Authenticated API calls must include auth\_id, auth\_ts and auth\_sig parameters, discussed below. API calls without auth\_id are anonymous, and even if they contain auth\_ts and auth\_sig, these parameters are not processed or verified.

Each Cotton Cart user can create and delete multiple API Keys through the web interface. Each key has is a lowercase alphanumeric ID, appended with '@' to the store ID (e.g. 'user123@mystore'), and a shared secret value (16char, mixedcase alphanum). Authentication is performed based on the API Key and the corresponding shared secret.

To be authenticated, each call must include 3 parameters:

- The authentication id (auth\_id, e.g.'user123@mystore')
- The timestamp (auth\_ts) of the time the request was generated. This is an integer value representing an accurate Unix Time
- The computed authentication signature (auth\_sig)

To generate a valid request, the client needs to do the following:

- Create the signature base string, consisting of the API version identifier, followed by a slash character, followed by the API method group, followed by a slash character, followed by the API method, followed by a question mark character, followed by all parameters of the request except the "auth\_sig" parameter, sorted by key in lexical order and formatted as a query string, but without any percentescaping performed on the parameters and without file attachment names/values .
    - Note: The requested format is NOT included in the signature.
    - Example signature base string: v1/catalogue/store\_info?auth\_id=user123@mystore&amp;auth\_ts=1329130234&amp;store\_id=some\_store
- Generate a hexadecimal SHA256 HMAC of the base string hashed together with the API\_KEY (see PHP docs on HMAC). Sha256 must be used as a hashing function.
- Append that hex value to the list of arguments as auth\_sig. The final request would look like:

```
    catalogue/store_info?store_id=some_store&auth_id=user123mystore&auth_ts=1329130234
```

The above scheme allows secure, stateless communication between the server and the client.

#### General response format

[](#general-response-format)

###### HTTP Codes

[](#http-codes)

The Cotton Cart API always returns a response with 200 OK HTTP code. Any errors are included as a part of the response body, without affecting the HTTP headers.

###### Success state and errors

[](#success-state-and-errors)

Every response contains a success key which can be either "true" or "false" (as string values). If success is false, the response will contain information about the error:

```
{
	"success": false,
	"errorCode": 400,
	"error": "Required parameter missing",
	"errorDetails": {
		"param": "store_id"
	}
}
```

The errorDetails key is optional and its contents vary on a pererror basis; it is intended for human debugging, not for automatic processing.

###### Pagination

[](#pagination)

Some requests support paginated response, using the count and start request parameters. By default, all available records are listed. count can be used without start (in which case the first count records are listed); however, if start is provided, count is required.

If a request asks for paginated response, the response will contain a pagination structure:

```
{
	"success": true,
	"pagination": {
		"start": 0,
		"count": 10,
		"total": 150
		"pages": 15,
		"prev_page": null,
		"next_page": 10
	}
}
```

- start - Marks the starting point of the pagination.
- count - The number of items per page.
- total - The total number of records available for listing.
- pages - The number of available pages.
- prev\_page - The starting index of the previous page.
- next\_page - The starting index of the next page.

The start and count keys mirror the values from the request. total holds the total number of records available for listing, pages holds the number of available pages of count items per page, while prev\_page and next\_page hold the starting index of the previous and the next page respectively (a value to be used for the start request parameter, in order to display previous/next page). prev\_page and next\_page would be null if further navigation in the respective direction is not available.

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

[](#installation)

#### 1. Using Composer

[](#1-using-composer)

The recommended installation method is through [Composer](http://getcomposer.org/), a dependency manager for PHP. Just add `mtrdesign/cottoncart-api-php-client` to your project's `composer.json` file:

```
"require": {
  "mtrdesign/cottoncart-api-php-client": "dev-master"
}
```

and then run `composer install`. For further details you can find the package at [Packagist](https://packagist.org/packages/mtrdesign/cottoncart-api-php-client).

#### 2. Cloning from GitHub

[](#2-cloning-from-github)

The library is available on GitHub. You can clone it into a local repository with the git clone command.

```
git clone https://github.com/mtrdesign/cottoncart-api-php-client.git
```

#### 3. Manual way

[](#3-manual-way)

Or you can install the package manually by:

- Copy and rename `src` folder to your codebase, perhaps to the vendor directory.
- Add the new folder to your autoloader or require the files directly.

Basic Examples
--------------

[](#basic-examples)

#### 1. Manage calls

[](#1-manage-calls)

- [manage/create\_product](examples/manage/create_product.php)
- [manage/create\_store](examples/manage/create_store.php)
- [manage/create\_user](examples/manage/create_user.php)
- [manage/delete\_design](examples/manage/delete_design.php)
- [manage/delete\_product](examples/manage/delete_product.php)
- [manage/delete\_store](examples/manage/delete_store.php)
- [manage/edit\_product](examples/manage/edit_product.php)
- [manage/edit\_store](examples/manage/edit_store.php)
- manage/edit\_store\_prices
- manage/store\_prices\_options
- [manage/my\_stores](examples/manage/my_stores.php)
- [manage/my\_users](examples/manage/my_users.php)
- [manage/product\_options](examples/manage/product_options.php)
- [manage/store\_options](examples/manage/store_options.php)
- [manage/upload\_design](examples/manage/upload_design.php)

#### 2. Catalogue calls

[](#2-catalogue-calls)

- [catalogue/product\_info](examples/catalogue/product_info.php)
- [catalogue/store\_info](examples/catalogue/store_info.php)
- [catalogue/stores](examples/catalogue/stores.php)

#### 3. Order calls

[](#3-order-calls)

- [order/calculate](examples/order/calculate.php)
- [order/checkout](examples/order/checkout.php)
- [order/test\_checkout](examples/order/test_checkout.php)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 93.1% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f10688f990a6aa07ad0dee6cf27264d79b4227508d89dd0bcd2d44ceff46ae5f?d=identicon)[akolevutd](/maintainers/akolevutd)

![](https://www.gravatar.com/avatar/753a5486ac630699e27d9b2d196fb651db8940aab0899078edfba4b22ca5839c?d=identicon)[mtrdesign](/maintainers/mtrdesign)

---

Top Contributors

[![akolevutd](https://avatars.githubusercontent.com/u/7977543?v=4)](https://github.com/akolevutd "akolevutd (27 commits)")[![atanas-mavrov](https://avatars.githubusercontent.com/u/18038157?v=4)](https://github.com/atanas-mavrov "atanas-mavrov (1 commits)")[![vborisov](https://avatars.githubusercontent.com/u/3350797?v=4)](https://github.com/vborisov "vborisov (1 commits)")

### Embed Badge

![Health badge](/badges/mtrdesign-cottoncart-api-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/mtrdesign-cottoncart-api-php-client/health.svg)](https://phpackages.com/packages/mtrdesign-cottoncart-api-php-client)
```

###  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)[facebook/php-business-sdk

PHP SDK for Facebook Business

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

PHP wrapper for the Meilisearch API

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

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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