I’ve been using Distill for a few years but recently wanted to explore the best way to track value changes in APIs. I am trying to monitor flights via JetBlue APIs
Sample API Link: https://jbrest.jetblue.com/bff/bff-service/bestFares/?apiKey=dummy&origin=EWR&destination=SJU&fareType=LOWEST&month=FEBRUARY%202024&tripType=ONE_WAY&adult=2&child=0&infant=0
The idea is to notify when prices for any date drop below 100 or a specific price (e.g., 175). I used regex101 to build the regex expression and the below expression was provided:
/"amount":\b(0*(?:[1-9][0-9]?|175))\b/gim
Per the sample API Link provided above, I should get “3” matches in the text.
Below is how I configured the expression in Distill:
The matches regular expression condition tests whether the text matches the expression. It will not update the monitor’s data. You can check the result of the condition in the Monitor’s data view:
So the issue I have now is that sometimes values for different dates “change” but those dates are not under $100 but I still get the alert because the dates that did not change are still under $100. So I get a notification because the overall text change but not for a new date that is under $100. This is because I was using the “Text” aspect.
I now changed it to “Added text” and now have the issue that sometimes only 2 number in the price change. For example, it changes from $175 to $165. The text that changed is only the first two numbers “17” to “16”, therefore the alert is triggered because the added text of “16” is less than 100 but in reality the price is still not less than 100.
What is the best way to successfully resolve this?
If there’s a new change after the previous one in which the price for a different fare entry changes from 250 to 254 then it won’t be saved because the regex output will remain the same.
I’ve added currencyCode in regex so that it matches currencyCode text every time, even if outboundFare is blank. This way we won’t get SELECTION_EMPTY error. You can remove it if that’s not required.