Skip to content

API in .NET 5.0 to fetch data from the Lidl Plus API

Notifications You must be signed in to change notification settings

KoenZomers/LidlApi

Repository files navigation

Lidl Plus API in .NET 5

licence badge issues badge prwelcome badge .NET 5 CI

API in .NET 5 using C# which can be used to read data from the Lidl Plus API used by the Lidl Plus app. Includes Unit Tests and a sample ConsoleApp to test the API. All assemblies are signed and compiled against .NET 5 which makes it usable cross platform and across all .NET supporting languages.

Notice

Note that in no way this code is supported by Lidl itself. Lidl has now implemented a system which prevents logging in to their APIs by third parties. This code therefore no longer works and there is no (easy) way to get it to work again. Use it for inspiration, but don't expect it to work anymore as-is. I personally have no intent to fix it again.

Usage

If you want to build the code locally, copy the App.sample.config file under ConsoleApp and UnitTest to App.config and fill it with your Lidl Plus e-mail address and password.

You can create a new session to connect to the Lidl Plus services using:

// Create a new Session instance to connect with the Lidl APi
var session = new KoenZomers.Lidl.Api.Session();

This will connect it to the Lidl Plus services of The Netherlands and return content in Dutch. If you wish to connect to Lidl Plus for another county and/or language, you can pass this in through one of the optional arguments in the constructor, i.e. for Germany use:

// Create a new Session instance to connect with the Lidl APi
var session = new KoenZomers.Lidl.Api.Session(language: "DE-DE", country: "DE");

The other optional parameters in the constructor you typically should not change from their defaults.

Once you have the session initiated, you need to authenticate it first using:

// Authenticate to the Lidl Plus API using an e-mail address and password
await session.Authenticate("johndoe@hotmail.com", "myLidlPlusPassword");

Instead of using the e-mail address and password to authenticate, you can also use a refresh token to do so, which is a faster way to authenticate as it requires fewer steps behind the scenes:

// Authenticate to the Lidl Plus API using a refresh token
await session.Authenticate("refreshToken");

Once authenticated, you can call one of the methods to retrieve data from the Lidl Plus services, such as:

// Retrieve all your receipts
await session.GetReceipts();

// Retrieve all your coupons
await session.GetCoupons();

// Retrieve all the scratch coupons you receive after a purchase for discounts on items
await session.GetScratchCoupons();

// Scratch open the coupon with the provided id
await session.RedeemScratchCoupon("couponid");

// Mark a specific receipt as favorite
await session.MakeReceiptFavorite("receiptid");

Have a look at the Unit Tests and/or Console Application for seeing additional samples about the available data you can pull from the API.

NuGet

Also available as NuGet Package: KoenZomers.Lidl.Api

Version History

Version 1.0.0.1 - June 7, 2021

  • Minor cosmetical fixes

Version 1.0 - June 4, 2021

  • Initial version

Feedback

Comments\suggestions\bug reports are welcome!

Koen Zomers koen@zomers.eu

About

API in .NET 5.0 to fetch data from the Lidl Plus API

Topics

Resources

Stars

Watchers

Forks

Languages