Download the PHP package slimad/colnect-api without Composer

On this page you can find all versions of the php package slimad/colnect-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package colnect-api

Colnect API – PHP SDK

A lightweight, fully typed PHP SDK for the Colnect REST API, built on top of Saloon v3. It ships with first-class support for HMAC request signing, request mocking, PHPStan level 9 static analysis and mutation testing via Infection.

Tests PHP Version


Table of contents


Features

Requirements

Component Version
PHP ^8.2 (tested on 8.2, 8.3 and 8.4)
saloonphp/saloon ^3.0
ext-pcov dev only (for Infection coverage)

CAPI is served exclusively over HTTP/2, so the cURL build used by Guzzle has to support it (curl --version must list HTTP2).

Installation

Install the package via Composer:

The package is distributed under the slimad/colnect-api name. The autoload root is Slimad\ColnectApi\ and maps to src/.

Quick start

Authentication

Colnect uses an appId + appSecret pair that must be requested from Colnect. Every request is signed with an HMAC-SHA256 hash:

The signing logic lives in ColnectConnector::boot() and is applied automatically to every request - you never have to touch it yourself.

Never commit your appSecret to version control. Load it from environment variables, a secrets manager, or your framework's configuration layer. If a secret leaks, revoke it and generate a new one - Colnect accepts both secrets for a short grace period while you rotate.

Available requests

General actions

Class Endpoint Notes
General\GetCategoriesRequest GET /categories Category names currently available on Colnect.
General\GetLanguagesRequest GET /languages short_iso => language_name.
General\GetCountryFlagsRequest GET /country_flag/ids/{ids} country_id => flag_picture_id, see PictureUrl::flag().
General\GetRequestCountRequest GET /request_count[/days/{days}] Your own daily CAPI usage, up to 200 days.
General\TranslatePhrasesRequest POST /translate_phrases Phrases are sent as a JSON array in the body.

Collector actions

Class Endpoint
Collector\GetRatingsCountRequest GET /ratings_count/collector/{collector}
Collector\GetRatingsReceivedRequest GET /ratings_received/collector/{collector}
Collector\GetRatingsGivenRequest GET /ratings_given/collector/{collector}

Privacy settings may make Colnect answer private instead of the data.

Category actions

Class Endpoint Mandatory arguments
Category\GetCountriesRequest GET /countries/cat/{category} -
Category\GetProducersRequest GET /producers/cat/{category}/country/{country} country
Category\GetSeriesRequest GET /series/cat/{category}/producer/{producer} producer
Category\GetYearsRequest GET /years/cat/{category}/producer/{producer} producer
Category\GetThemesRequest GET /themes/cat/{category} -
Category\GetCatalogsRequest GET /catalogs/cat/{category} -
Category\GetCurrenciesRequest GET /currencies/cat/{category} -
Category\GetFaceValuesRequest GET /face_values/cat/{category} -
Category\GetSystemsRequest GET /systems/cat/{category} -
Category\GetItemsListRequest GET /list/cat/{category}/{filters} at least one filter
Category\GetItemIdsRequest GET /list_id/cat/{category}/{filters} at least one filter
Category\GetItemRequest GET /item/cat/{category}/id/{ids} 1 to 50 item IDs
Category\GetFieldTitlesRequest GET /field_titles/cat/{category} -
Category\GetProducerIsCountryRequest GET /producer_is_country/cat/{category} -
Category\GetCategoryActionsRequest GET /category_actions/cat/{category} -
Category\GetCategorySortOptionsRequest GET /category_sort_options/cat/{category} -

Not every action exists in every category - ask GetCategoryActionsRequest when in doubt.

Search

Class Endpoint
Search\GlobalSearchRequest GET /search[/collectibles/{type}]/q/{query}[/page/{page}]
Search\ImageSearchRequest POST /image_search[/cat/{category}]/{filters}

Marketplace

Class Endpoint
Marketplace\GetMarketPricesRequest GET /market_prices/cat/{category}/ids/{ids}[/days/{days}]
Marketplace\GetItemSalesRequest GET /item_sales/cat/{category}/item_id/{ids}[/...]

All request classes follow the same pattern:

Working with categories

The CategoryType enum provides a typed list of the collectable categories supported by Colnect, using the very module names Colnect expects in the cat filter:

Each category-aware request accepts either the enum or a raw string, so you can interoperate with values coming from forms, configs, or HTTP input:

Colnect names the producer differently per category ("company" for phonecards, "brand" for teabags, the country itself for stamps). The enum knows the mapping:

Categories are edited continuously on Colnect, so treat the enum as a convenience and GetCategoriesRequest as the source of truth.

Filtering lists

Filters is an immutable collection rendering the documented common list filters as path segments, in the order you add them:

Named helpers exist for country, producer, series, year, theme, catalog, currency, face_value, system, sort and page. Colnect exposes more filters while you navigate the site; reach them with with():

Filter IDs are Colnect-internal and change over time - the API documentation asks you not to cache them for more than 24 hours.

Items and pictures

GetItemRequest returns the fields listed by GetFieldTitlesRequest, in the same order. The fields differ per category and may change, so read them at runtime instead of hard-coding offsets:

Picture IDs become URLs through PictureUrl:

The item name is slugged with Str::urlize(), the port of the function published in the API specification.

Marketplace

Image search

Image search is disabled by default and billed per call, so it has to be enabled for your application first. Because image recognition is imperfect, narrowing the search down with a category and filters is recommended.

A target can also be built from base64 data (ImageSearchTarget::fromBase64()) or from a local file (ImageSearchTarget::fromFile()), each with a withBack*() counterpart. The response carries distances and best_matches, where c_id is the item ID and p_id the picture ID.

Error handling

Every malformed argument throws Slimad\ColnectApi\Exceptions\InvalidArgumentException, which extends the SPL \InvalidArgumentException:

HTTP errors are handled by Saloon as usual - use $response->failed(), $response->status() or $connector->send() with ->throw().

Mocking & testing your integration

Because the SDK is built on Saloon, you can mock every response without hitting the network - ideal for fast, deterministic unit tests:

See tests/ColnectConnectorTest.php for end-to-end examples of asserting headers, payloads and the HMAC signature.

Development

Clone the repository and install dev dependencies:

Running the test suite

The test suite runs against:

Static analysis

PHPStan is configured at level 9 for both src/ and tests/:

Mutation testing

Infection is configured with the @default mutator set and source-only coverage:

The pcov extension is required for coverage; it is already declared as a dev dependency in composer.json.

Documentation

Versioning

This project follows Semantic Versioning 2.0.0:

Pin a major version in your composer.json to avoid unexpected breaking changes:

Contributing

Contributions are welcome and appreciated! To contribute:

  1. Fork the repository and create a feature branch off main.
  2. Add code and tests – PRs without tests will not be merged.
  3. Make sure the full quality gate passes locally:

  4. Follow the existing coding style – declare(strict_types=1), typed properties, PSR-12 formatting.
  5. Open a pull request describing what changed and why.

Bug reports and feature requests can be filed via GitHub Issues. Please include a minimal reproducible example whenever possible.

Security

Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.

If you discover a security vulnerability in this package, report it privately so it can be addressed before public disclosure:

When reporting, please include:

  1. A description of the vulnerability and the impact you believe it may have.
  2. Step-by-step instructions to reproduce the issue (proof of concept code is ideal).
  3. The affected version(s) of the package.
  4. Any suggested remediation, if known.

You can expect:

Please act in good faith and avoid:

License

This package is open-sourced software licensed under the MIT License.

See the LICENSE file for the full text. In short, you are free to use, copy, modify, merge, publish, distribute, sublicense and/or sell copies of the software, provided the original copyright notice and the license text are included in all copies or substantial portions of the software. The software is provided "as is", without warranty of any kind.

Credits

If this package is useful to you, please consider starring the repository on GitHub ⭐.


All versions of colnect-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
saloonphp/saloon Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package slimad/colnect-api contains the following files

Loading the files please wait ...