Detect change in REST API response - python-3.x

Say I query some API to get the prices of some items on Amazon. I was thinking I could create some Pub/Sub system where, when there is a change in any of these prices, the new price is published and some subscriber handles the change.
One option is to make some process that spins, querying the same API over and over until there is some new price in the API response, which then gets published. Is this my only option? If so, what python libraries exist to run this spinning publisher in the background?
Thanks in advance for any help!

Related

Automatically updating Shopify inventory item quantity

I have a Shopify store with rental products. Since Shopify doesn't handle return flows, the shop is connected to an external service, were the order is sent via an API to that service, which handles finalizing the rental and tracking it.
Now here is the problem, since the procedure is finalized outside of Shopify, the products are removed when rented, but not added when returned. this makes updating the shop manual. I am currently using Pipedream to handle my Web-hooks and requests, and it provides a service to change Inventory Level, but no direct way to update Shopify inventory. I know that the only way to update quantity in by getting InventoryItemID, and the only way to get that is by using ProductVarientID. I was able to acheive that using GraphQL, but I'd have to manually quary the InventoryItemID by using the ProductVarientIDs of my return orders from an API, and then use a mutation that does bulk inventory update to get the job done, but you can see, this is hardly automated.
Any thoughts and ideas are much appreciated.
If there is a way to do it using Pipedream, that's super.

How to subscribe the API updates from Amazon MWS

Is there a mail list or RSS feed we can subscribe to get notified when API changes?
I've never seen one. I periodically look at the documentation to see if any dates have changed, but that's as good as it gets I think. https://developer.amazonservices.com/gp/mws/docs.html.

Track multiple context for the same Bot

We have a bot that will be used by different customers and depending on their database, sector of activity we're gonna have different answers from the bot and inputs from users. Intents etc will be the same for now we don't plan to make a custom bot for each customer.
What would be the best way to separate data per customer within Chatbase?
I'm not sure if we should use
A new API key for each customer (Do we have a limitation then?)
Differentiate them by the platform filter (seems to not be appropriated)
Differentiate them by the version filter (same it would feel a bit weird to me)
Using Custom Event, not sure how though
Example, in Dialogflow we pass the customer name/id as a context parameter.
Thank you for your question. You listed the two workarounds I would suggest, I will detail the pros/cons:
New API Key for each customer: Could become unwieldy to have to change bots everytime you want to look at a different users' metrics. You should also create a general api (bot) where you send all messages in order to get the aggregate metrics. This would mean making two api calls per message.
Differentiate by version filter: This would be the preferred method, however it could lengthen load times for your reports as your number of users grows. The advantage would be that all of your metrics are in one place, and they will be aggregated while only having to send one api call per message.

How to avoid circular Updates in 2-Way-Sync / Determine that list event is caused by skill itself?

The Alexa List API FAQ says as follows:
How can a developer determine that an event has been triggered due to their skill?
Consider this scenario:
The customer creates a to-do in the app.
The skill service uses the Skill Messaging API to send a message to the skill to create a list item in Alexa.
The skill receives the Skill Messaging API message and POSTs to householdlist and list items.
In response to the POST, the skill service records the alexa_item_id locally. An ItemsCreate event also occurs as a list item was just created. Alexa triggers an event even if a list item is created by calling List API. Skill developers can use the item_id value returned by CreateListItem to uniquely identify an item.
Now my question:
Is there any more precise information / sample on that? (I am still new to node.js and alexa development)
In my current skill implementation (AWS Lambda endpoint) list elements are added via ask list API which results in return in receiving the ItemsCreated event a few seconds later in the same lambda.
Currently I cannot filter out events like that which results in en endless circular update loop. The same is true for delete events while it stops after the first try here.
How can I determine that I can skip this event?
Where/how shall I store/cache this (e.g. the item_id mentioned above) information?
How do I get to this information seconds later (while other users may have called into the lambda meanwhile)?
Note:
Both happens out of session.
Seems there is no built-in way to achieve that.
From the FAQ I conclude that I need my own persistency (e.g. dynamoDB) and store item_id / user_id there in order to check the events.
https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs#persisting-skill-attributes-through-dynamodb
If any concerns or any easier way applicable - please let me know.
Ok You must use the Api with webhook
so, for any webhook event comes from system A , you must do a request api to the system B to get the data about this Item e.g
then you must compare the data which come by webhook and the data that return from api , if no difference then stop
else continue in effecting in the System B

How to access more than 10 products in Amazon mws via ListMatchingProducts API using node.js

I am using node.js(Meteor) for calling Amazon MWS ListMatchingProducts API for getting all products of my seller account . Its running sucessfully and i am getting the response , but as the documentation said that only ten(10) products are returned at one time. So i just want to know how we get products more than 10 . In the doc Amazon also said that you can submit NextToken with a "ByNextToken" operation to request additional pages.But i am not getting any nextToken or related to that nextToken field on my response.So how do i get the nextToken from there side or how can i get more than 10 products from that API. As i also check on one post they said that we need to use Reports for that but i want to use ListMatchingProducts API for that and want result more than 10.
Please provide me any suggestion or guidance how can i achieve that.
Any help would be appriciated
Thanks
You want to call the Reports API using the Inventory Report report type or one of the other Listing Report types. That is the way to go. The ListMatchingProductsoperation of the Products API is meant to be a search, based on a query. Yes, it only lists ten products but it does not give you a NextToken like some of the other operations. Knowing your Report Type and Marketplace ID, you can submit those to the Reports API with your credentials and get back all of your products all at once and there is no searching involved.
What I would also suggest is to use the Amazon Scratchpad to play around with your operations to make sure you get what you expect, then plug it into your node.js project.

Resources