Download the PHP package themarketer/api-client without Composer

On this page you can find all versions of the php package themarketer/api-client. 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 api-client

The Marketer API Client (PHP)

PHP client for the The Marketer API. It sends HTTP requests via Guzzle (the internal ApiGateway class) and validates payloads with Symfony Validator (the AbstractPayload / Data DTOs from TheMarketer\ApiClient\Common).

Client documentation

For a structured, easy-to-follow version:

Docusaurus site (GitHub Pages)

The documentation is also available as a Docusaurus site in the website/ folder.

Run locally:

Deployment to GitHub Pages is configured through the workflow:

Requirements

Requirement Version / note
PHP ^8.1
Composer for installing dependencies
ext-mbstring required
Main dependencies guzzlehttp/guzzle ^7, symfony/validator ^7, symfony/expression-language ^8
Development / tests phpunit ^10, orchestra/testbench ^8 (for the test suite)

Install in your project:

Public package (example):


Architecture at a glance

The base URL for REST is Config::baseRestUrl() = {restUrl}/api/{apiVersion}/ (default apiVersion = v1). The default URLs live in Client / Config (src/Common/Config.php).


Basic usage


Credentials and utilities (directly on Client)

These methods do not go through subscribers() / orders(); they are delegated to the internal CredentialsClient.

checkCredentials(string $trackingKey): bool

Checks the credentials (tracking key in the JSON body on REST, see CredentialsClient). On Client, it returns true if the decoded response is an empty array [], otherwise false. For the raw JSON as an array, use CredentialsClient::checkCredentials() with the same context.

checkApiCredentials(): bool

On Client, it returns a bool (same criterion: JSON body → empty array = success). For the full decoded response, see CredentialsClient::checkApiCredentials().

getCosts(), getRealtimeVisitors(), getSmsCredit(): array

Decoded JSON response.

getReferralLink(?string $email = null): string

Returns the raw content of the response (not JSON).

getDeliveryLogs(array $payload): array

email required; optional: per_page, page, start, end.

getEnteredAutomation(array $payload): array

date required (Y-m-d); optional page, perPage.

config(): Config

Access to customerId, restKey, baseRestUrl(), trackingKey(), etc.


API modules (examples)

Accessor on Client Role
subscribers() Subscribers: status, add/remove, bulk, tags, etc.
orders() Orders, feed URL, retail, statistics
transactionals() Transactional email and SMS
products() Product CRUD / sync, categories, brands
campaigns() List, create campaign, email report, last campaign
loyalty() Loyalty points
coupons() Available coupons, saving
reviews() Product and merchant reviews, Merchant Pro settings
mobilePush() Mobile push (iOS/Android tokens)
events() Custom events
reports() Email/SMS/push/forms/audience reports

Details about parameters: the files in src/Api/*Api.php and src/DTO/**. The tests in tests/*ApiTest.php show examples of valid payloads.

Campaigns — important notes

Reviews

Reports


Errors and exceptions

Before the request (local validation)

After the request (ApiGateway maps the HTTP status)

Status Exception
401 UnauthorizedException
404 CustomerNotFoundException
405 MethodNotAllowedException
Other errors ApiException (uses the code and message from the response; the message is extracted from the JSON message when present)

On a successful response with invalid JSON, the methods that decode it can throw JsonException. For network errors: GuzzleHttp\Exception\GuzzleException.


Tests

The suite uses ApiGateway with a Guzzle MockHandler (no real API calls). For Client in tests with an HTTP mock, context is readonly; in practice CredentialsClient and the *Api classes are tested with the same stack — see tests/CredentialsClientTest.php and tests/TestCase.php.


Smoke script (smoke.php)

A quick check with real credentials (do not commit keys to the repo):

The example in the repo calls checkCredentials($trackingKey) — replace the values with the ones from your The Marketer account.


License

MIT (see composer.json).


All versions of api-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.0
ext-mbstring Version *
symfony/validator Version ^7.0
symfony/expression-language Version ^8.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 themarketer/api-client contains the following files

Loading the files please wait ...