Best Practices for Using Third Party eCommerce API Data

What would be best for the next situation. I have an e-commerce store that is reducing the distributor's inventory level. If the site, every time a user loads a product detail page, use a third party API for the most up to date? Or, should the site use third party APIs and then store this data for a certain amount of time on its own system and update it periodically?

It seems obvious to me that it should update every time the product detail page is loaded, but what are high traffic stores? Are there completely different solutions used for this case?

+2


source to share


3 answers


In this case, I will definitely cache the results from the distributor's site for a period of time rather than hitting them every time you receive a request. However, I would simply not use an empty 5 minutes or 30 minutes timeout for all cache entries. I would use some heuristics instead. If possible, for example if your application is written in Python, you can attach a simple script to each product that implements a timeout.

That way, if it's an item that is infrequently requested, or one that has a large quantity in stock, you can cache for a longer time.

if product.popularityrating > 8 or product.lastqtyinstock < 20:
   cache.expire(productnum)
distributor.checkstock(productnum)

      



This gives you flexibility that you can call if you need it. First, you can set the following for all rules:

 cache.expireover("3m",productnum)
 distributor.checkstock(productnum)

      

Actually the script probably won't include a call to the checkstock function because it will be in the main application, but it's included here for context. If python seems too heavy to include just this small amount of flexibilty, then take a look at TCL, which was specifically designed for this type of work. Both can be easily implemented in C, C ++, C # and Java applications.

+1


source


Actually, there is another solution. Your distributor maintains a product catalog on their servers and makes it available to you through the Open Catalog interface . When a user wants to place an order, they are redirected to a location in the distributor's directory, select items, and then pass the selection back to your store.



It is widely used in the SRM (Supplier Relationship Management) division.

0


source


It depends on many factors: traffic on your site, how often inventory levels change, business impact on obsolete data, how often vendors allow you to call their API, their API SLA in terms of availability and performance, and so on. ...

Once you have these answers, there are of course many possibilities here. For example, for a low traffic site where proper inventory is important, you can call a third-party API on every call, but fall back to alternative behavior (such as using cached data) if the API does not respond within a certain timeout.

Sometimes well thought out APIs will include hints about the data validity period. For example, some REST-over-HTTP APIs support various HTTP cache control headers that can be used to specify a validity period or to retrieve data only if it has changed since the last request.

0


source







All Articles