PHPackages                             imclarky/tesco-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. imclarky/tesco-api

ActiveLibrary[API Development](/categories/api)

imclarky/tesco-api
==================

A PHP Client for the Tesco Supermarket API

v0.1.0-beta(7y ago)34MITPHPPHP ^7.1

Since Sep 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ImClarky/tesco-api-php)[ Packagist](https://packagist.org/packages/imclarky/tesco-api)[ RSS](/packages/imclarky-tesco-api/feed)WikiDiscussions master Synced 2d ago

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

Tesco API - PHP
===============

[](#tesco-api---php)

A PHP Client for the Tesco Supermarket API

[![Packagist](https://camo.githubusercontent.com/eb1950c9139c2a5441cd6722ef89d6ead5673511601139691b8892cb8e4ff25b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f496d636c61726b792f746573636f2d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/imclarky/tesco-api)[![Travis (.org)](https://camo.githubusercontent.com/e1f0e681215f93203743d224af18d9f8b371cc3de85e2d19501efbbd48489ab8/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f496d436c61726b792f746573636f2d6170692d7068702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ImClarky/tesco-api-php)[![StyleCI](https://camo.githubusercontent.com/1fd9b4c578510ed5c2d276c8b684a50c47902f8f2c5434d6732ad2c0d568a0c6/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3133323936303533302f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/132960530)[![Coveralls github](https://camo.githubusercontent.com/6716d9a898347ecb9c7fd83bfbb6a47f5ae07fe26c24b61bdc3cdb8e17ef2d8f/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f496d436c61726b792f746573636f2d6170692d7068702e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/ImClarky/tesco-api-php)[![Packagist](https://camo.githubusercontent.com/3e18c86043e6d7e704d32a6783636062b8312c82466b9871b564da8599978eb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696d636c61726b792f746573636f2d6170692e7376673f7374796c653d666c61742d737175617265)](https://github.com/ImClarky/tesco-api-php/blob/master/LICENSE)

Contents
--------

[](#contents)

- [Getting Started](#getting-started)
    - [Installation](#installation)
    - [Requirements](#requirements)
    - [API Key](#api-key)
    - [Simple Example](#simple-example)
- [Usage](#usage)
    - [Requests](#requests)
        - [Grocery Request](#grocery-request)
        - [Product Request](#product-request)
        - [Store Location Request](#store-location-request)
    - [Responses](#responses)
    - [Models](#models)

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

To install, simply require the package using composer:

```
composer require imclarky/tesco-api
```

### Requirements

[](#requirements)

- PHP &gt;7.1
- Tesco API Key (see below)

### API Key

[](#api-key)

You will first need to register for an API Key from [Tesco's Developer Portal](https://devportal.tescolabs.com/), by signing up for an account and subscribing the General APIs.

### Simple Example

[](#simple-example)

Here is a simple example of a request to the Tesco API to find grocerys related to the word *chocolate*:

```
$tesco = new \ImClarky\TescoApi\TescoApi('apikey');

$results = $tesco->newGroceryRequest()->addSearchTerm('chocolate')->send();

foreach ($results->getModels() as $grocery) {
    echo $grocery->getName();
}
```

Usage
-----

[](#usage)

### Requests

[](#requests)

There are two ways of creating requests to the API. The first, as shown above, is to use the base TescoApi class.

The base class is initialized with your API Key:

```
$tescoApi = new \ImClarky\TescoApi\TescoApi('apikey');
```

This base class has 3 main functions, each of which will return a new instance of the related request class.

```
public function newGroceryRequest(): GroceryRequest
{
    return new GroceryRequest($this->_apiKey);
}

public function newProductRequest(): ProductRequest
{
    return new ProductRequest($this->_apiKey);
}

public function newStoreLocationRequest(): StoreLocationRequest
{
    return new StoreLocationRequest($this->_apiKey);
}
```

Alternatively you can create new instances of the Request classes directly, again passing the API key asa a parameter.

```
$groceryRequest = new \ImClarky\TescoApi\Requests\GroceryRequest('apikey');

$productRequest = new \ImClarky\TescoApi\Requests\ProductRequest('apikey');

$storeLocationRequest = new \ImClarky\TescoApi\Requests\StoreLocationRequest('apikey');
```

Each request object has different methods to add query paramters to the API request.

---

#### Grocery Request

[](#grocery-request)

**`addSearchTerm(string $searchTerm)`**
Add a search term to search for. Providing a search term is required; if no term is added when the request is sent, the Request class will throw a `RequestException`.

```
$request = new GroceryRequest('apikey');

$response = $request->addSearchTerm('biscuits')->send();
```

---

#### Product Request

[](#product-request)

**`addGtin(string $gtin)`**
Add a product's GTIN/EAN-13 number to the search list.

**`addTpnb(string $tpnb)`**
Add a product's Tesco Product Number Base (TPNB) number to the search list.

**`addTpnc(string $tpnc)`**
Add a product's Tesco Product Number Consumer (TPNC) number to the search list.

**`addCatId(string $catId)`**
Add a product's Catalogue ID to the search list.

Each of these functions returns the request object instance to allow chaining the above methods.

```
$request = new ProductRequest('apikey');

$response = $request->addGtin('0332322384993')
                    ->addGtin('0368604930293')
                    ->addTpnc('34029384')
                    ->send();
```

---

#### Store Location Request

[](#store-location-request)

**`addSort(string $type, string $value)`**
Add a Sort query parameter. Currently the only sort type is *Near*; Which sorts the results by distance from the given location.

TypeDescriptionExample ValuesSORT\_NEARSort the results by the distance from the given location - ascendingLondon, UK
SE11 5AP**`addFilter(string $type, $value)`**
Add a Filter query parameter to filter the results.

TypeDescriptionExample ValuesFILTER\_NAMEThe name of the storeLakeside Extra
Charing Cross ExpressFILTER\_BRANCHNUMBERThe branch number of the store3482
2593FILTER\_ISOCOUNTRYCODEThe ISO Country Code the store is located ingb
x-uk
imFILTER\_FACILITYA facility at the storeFacility::FACILITY\_ATM
Facility::FACILITY\_CAR\_WASHFILTER\_CATEGORYA store categoryStore::CATEGORY\_STORE
Store::CATEGORY\_CFCFILTER\_TYPEA store typeStore::TYPE\_EXTRA
Store::TYPE\_EXPRESSFILTER\_STATUSThe status of the storeTradingNormally a string will be passed in the `$value` parameter - this will add the term and will be used in a `AND` expression in the where clause. However, if an array is passed, the values of the array will be treated as an `OR` expression. For example:

```
$response = $storeRequest->addFilter(Filter::FILTER_FACILITY, Facility::FACILITY_ATM)
                         ->addFilter(Filter::FILTER_FACILITY, Facility::FACILITY_DBT)
                         ->addFilter(Filter::FILTER_FACILITY, [
                             Facility::FACILITY_CAR_WASH,
                             Facility::FACILITY_JET_WASH,
                             Facility::FACILITY_HAND_CAR_WASH
                         ]);

// In an SQL-like querying language
// WHERE Facility = 'ATM' AND Facility = 'DBT' AND (Facility = 'Car Wash' OR Facility = 'Jet Wash' OR Facility = 'Hand Car Wash')
```

**`addLike(string $type, $value, bool $start = false)`**
Add a Like query paramter to filter the results. This is exactly the same as Filters, except the API will do a full text search for the the value. If `$start` is set to true, the search will only return results where the term is at the start.

---

#### Pagination

[](#pagination)

Both the Store Location and Grocery request results are returned in pages. You can set the offset and limit on these request, as well as navigate the pages.

**`setLimit(int $limit)`**
Set the limit of the request - ie, how many results to return. If this function is never called, then the default value of *10* is used.

**`setOffset(int $offset)`**
Set the offset of the request - ie, how many results to offset. If this function is never called, then the default value of 0 is used.

**`getNextPage()`**
Get the next page of results

**`getPrevPage()`**
Get the previous page of results.

**`goToPage(int $page)`**
Go to a specific page of results.

### Responses

[](#responses)

Each successful request will return a related response object. Eg a `StoreLocationRequest` returns a `StoreLocationResponse`. Each response object will contain information like response headers, response status, etc. as well as the models generated from the response data (see below).

### Models

[](#models)

Models are generated from the responsed data retrieved from a request.

#### Grocery

[](#grocery)

---

#### Product

[](#product)

---

#### Store

[](#store)

---

#### Opening Times and Exceptions

[](#opening-times-and-exceptions)

---

#### Facility

[](#facility)

---

#### Guideline Daily Amounts (GDAs)

[](#guideline-daily-amounts-gdas)

---

#### Nutrition

[](#nutrition)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

2805d ago

### Community

Maintainers

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

---

Top Contributors

[![ImClarky](https://avatars.githubusercontent.com/u/16253833?v=4)](https://github.com/ImClarky "ImClarky (80 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/imclarky-tesco-api/health.svg)

```
[![Health](https://phpackages.com/badges/imclarky-tesco-api/health.svg)](https://phpackages.com/packages/imclarky-tesco-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)
