tesco

Tesco API

July 11, 2012

I’ve just added the ability to search for products and find your nearest Tesco store using the Tesco API via APIfy and thought I’d quickly share my experiences on getting product information from Tesco.

Note: Interestingly, Tesco have also stopped sign ups via the Developers Portal – if you need a key, drop me an e-mail.

NOTE: If you want to play with this then grab yourself a key by registering at the Tech for Tesco developers portal – it’s free and your account will be instantly activated. For a quick-demo you can search via APIfy, here’s some chocolate. How about some nuts?


View Documentation
Example JS Client


The documentation will go into depth of the different commands and parameters you can use, whereas I’ll just briefly go over LOGIN and PRODUCTSEARCH in this post. There’s also a presentation if you’re interested. The endpoint is https://secure.techfortesco.com/groceryapi/restservice.aspx which is a (not-so) RESTful service returning JSON data. You can call different actions by using the command query string, e.g. to login use https://secure.techfortesco.com/groceryapi/restservice.aspx?command=LOGIN

LOGIN

Most of the methods require authentication via a session key which you can obtain from the response of the LOGIN command. To login and obtain a session key do a GET request to the URL https://secure.techfortesco.com/groceryapi/restservice.aspx?command=LOGIN&developerkey={dev-key}&applicationkey={app-key}. Make sure to include in the query string email and password. The email and password should be an active account from Tesco.com. Once you’ve logged in using your chosen method you will get a JSON response back containing your name, customer ID, etc. and most importantly your session key. We’ll need the session key for future calls, so keep it safe.

Session Keys: I’m not sure what expiration session keys have, but I’d grab a new one every hour or so just to be safe.

PRODUCT SEARCHING

Once you’ve logged in you can call methods like PRODUCTSEARCH to search for products and get further information on them. Let’s find some chocolate, nom: do a GET request to the endpoint with the command set to PRODUCTSEARCH whilst also passing in your session key: &sessionkey={mysessionkey}. We can do a keyword search with the &searchtext=chocolate parameter. By default this method will pull back everything found matching that keyword, which can be a little slow, thus pass in the &page=1 parameter to enabling paging and we’ll get back 20 products. Here’s an example product that was returned:

{
"BaseProductId": "50530385",
"EANBarcode": "5000159393966",
"CheaperAlternativeProductId": "",
"HealthierAlternativeProductId": "",
"ImagePath": "http://img.tesco.com/Groceries/pi/966/5000159393966/IDShot_90x90.jpg",
"MaximumPurchaseQuantity": 99,
"Name": "Galaxy Chocolate Bar 4 Pack 184G",
"OfferPromotion": "Any 2 for £3.00 ",
"OfferValidity": "valid from 4/7/2012 until 24/7/2012",
"OfferLabelImagePath": "http://www.tesco.com/Groceries/UIAssets/I/Sites/Retail/Superstore/Online/Product/pos/2for.png",
"Price": 1.73,
"PriceDescription": "£0.94 each",
"ProductId": "262842800",
"ProductType": "QuantityOnlyProduct",
"UnitPrice": 0.94,
"UnitType": "100g"
},

very useful indeed! But wait, there’s more. If you’re a health freak and wanted to see what ingredients the product contains, check out the RDAs or view the products nutrients pass in &ExtendedInfo=Y with your request. All the information you can shake a stick at – now go create some awesome Tesco apps! ;-) Here’s a few ideas:

  1. Using PRODUCTSEARCH loop over the users favourite products daily (LISTFAVOURITES) and check if it has an offer on, if it does then notify the user.
  2. Using the users favourite products, offer them healthier alternatives by reading the RDA information.
  3. Find other supermarket APIs and do product price comparison

Pro Tip #1: they support JSONP via &jsonp={callback}
Pro Tip #2: you can generate a EAN13 barcode image via APIfy: http://apify.ifc0nfig.com/utils/barcode/{barcode-number}, e.g: (see below) – this is the product above. You can then scan this with your mobile device.

Tags: , , , , ,

18 Comments

  1. Nick says:

    Hi PaulIt’s interesting what you have done here!Could you contact me (email in ‘email’ box of reply form) about this so we can help you with some more information?CheersNick

  2. [...] taking a look at the Tesco API, the only next logical step is uncovering the ASDA API. Unfortunately ASDA arn’t as open as [...]

  3. Hello Paul,Now tesco api is not working. your both js and rest api example is also not working it’s giving errors.Please response if you have any idea that tesco changed his API or shifted to other serveror whatever information you have.Thanks in advance.It’s urgent

  4. Hi Paul,Is the tesco API still avaiable? All of my we searches appear to suggest that it no longer is. Regards,Dan.

    • Paul says:

      HI Dan, it looks like Tesco have stopped sign ups via their developer portal. You can e-mail Nick (nick.lansley@uk.tesco.com) who runs the API.

      • Neerodha says:

        I love this Katina. Great layout and faublous papers. Look at you all organised for september, clever girl and using your snippets too.Hope your blinds ok.Lynne xxx

  5. soweb says:

    Hi, I love this exactly what i have been looking for for my client, however, a couple of questions:1. the ajax call with URL:http://apify.ifc0nfig.com/tesco/search/, is there a way of getting the raw info of this or does it have to go through this and what are the licences for this.2. I would like to get the extended info but unsure where to call the example you have posted up herethanks in advance

  6. Willie says:

    Hi,

    I was wondering if there was a Tesco API for Ireland?

  7. Hi Paul – nice work here.

    Would you be able to drop me a line back? I’d like to discuss a couple of things with you.

    Thanks.

  8. Would this work in Ireland aswell? I’m working on a college project, and I may implement this API if it can be used in Ireland

    Thanks,
    David

Leave a Comment