Is it possible for me to get products that are discounted via Amazon's API? - api

I want to search Amazon's product API for discounted products (30% off or more). Is there a simple way to do this via the API?

For certain search indexes, you can ask for minimum percentage off:
http://docs.amazonwebservices.com/AWSECommerceService/2011-08-01/DG/USSearchIndexParamForItemsearch.html
For instance, if I'm searching for Toys, I can get the minimum percentage off with the following parameters:
{"SearchIndex": "Toys", "Service": "AWSECommerceService", "AWSAccessKeyId": "xxx", "Timestamp": "2011-12-26T05:41:20Z", "Version": "2009-11-02", "Keywords": "Halo", "AssociateTag": "xxx", "MinPercentageOff": 30, "Operation": "ItemSearch", "ResponseGroup": "Large"}
However, if I'm searching for video games, the "MinPercentageOff" parameter is ignored. The documentation page I included above shows which of the search indices accept this parameter - note that if the index doesn't support it it's simply ignored (the search doesn't fail, it just doesn't honor that parameter).

Yes you can quite easily, I ran the API and put a break point and looked down into the attributes and found what your looking for...
For the percentage discount you can find it here:
item->Offers->offersField->offerListingField->percentageSaved
For the price of the item its talking about you can find it here:
item->Offers->offersField->offerListingField->Price->formattedPriceField

Related

How to listen to Tweets that only contains geo-info from Twitter stream

I'm trying to use version 2 of the Twitter API to achieve the goal described in the title. Here's what I have tried so far:
Listening to sample stream (1% of Twitter's stream): Almost all the returned Tweets don't have geo-info when following this approach. And it makes sense, since only 0.85% of all Tweets have geo-info.
Listening to a filtered stream with only one rule setup, namely the has:geo rule. But it's returning the following 2 errors:
"Reference to invalid operator 'has:geo'. Operator is not available in current product or product packaging. Please refer to complete available operator list at https://developer.twitter.com/en/docs/twitter-api/enterprise/rules-and-filtering/operators-by-product. (at position 5)".
"has/is/lang/sample cannot be used as a standalone operator (at position 1)".
Here's the rule I'm adding to the stream:
[
{
"value": "has:geo",
"tag": "contains geo-info",
},
]
I need help in solving both shown errors, or a suggestion describing a third different approach.
I see this question has been discussed on the Twitter Community forum: https://twittercommunity.com/t/how-to-listen-to-tweets-that-only-contains-geo-info-from-twitter-stream/162905/2
Short answer:
The has:geois one of several query operators that can not be used in a standalone fashion, and must be paired with keywords and other non-boolean operators.
The has:geo operator is only available in academic and paid packages.

Struggling to import analyst share price to GoogleSheets

I am trying to create a column that imports the analyst price target from TipRanks website.
I uploaded two images:
Image 1: you can see the cell that I want to import.
Image 2: you can see my function that doesn't work.
What should I change in order to get this live info?
Thanks.
The site you are checking is actually "javascript" generated thus import functions won't properly work on them.
To check, just try to import the whole site data. If it returns a javascript function, then it is javascript generated.
Sample (tipranks.com)
What you can do is actually try to find other sites that provide the same data.
I did find one with the same data you are looking for, 50.38 for csiq. Link is "https://www.marketwatch.com/investing/stock/csiq/analystestimates". And since data is shown as table, it would be easier to import using importhtml.
Cell formula is:
=INDEX(IMPORTHTML("https://www.marketwatch.com/investing/stock/csiq/analystestimates", "table", 5), 2, 2)
Sample output:
The table is the fifth one in the DOM, and INDEX(table, 2, 2) means getting the 2nd row 2nd column of the table.
If the site is no good for you, you can try finding other sites that would suit your needs. And then use either importhtml or importxml depending on the site structure.
When you inspect the network when the website is loading you will see that the prices come when calling the forecast endpoint https://www.tipranks.com/stocks/tsla/forecast. This in turn returns an html response which is probably generated with Javascript on the client because they use React on the frontend, but you can still see the preview in the Network tab of the browser dev tools.
You can then copy the preview in VSCode and prettify it, to try and pin point the span holding the price. Of course it won't be exact science, because the html tags are generated with some media queries, but you will get close enough to some extent.
After you get the xml path but you get an empty error, you can delete some tags until you get some text. Use search in google sheets to search for highest price label, and than continue adding tags until you get the desired value.
Here is what I managed to get:
Lowest price target:
=importxml("https://www.tipranks.com/stocks/snow/forecast", "/html/body/div[1]/div[1]/div[4]/div[1]/div[2]/div[1]/div[4]/div[2]/div[2]/div[4]/div[1]/div[1]/div[5]/span[2]")
Average price target:
=importxml("https://www.tipranks.com/stocks/snow/forecast", "/html/body/div[1]/div[1]/div[4]/div[1]/div[2]/div[1]/div[4]/div[2]/div[2]/div[4]/div[1]/div[1]/div[3]/span[2]")
Highest price target:
=importxml("https://www.tipranks.com/stocks/snow/forecast", "/html/body/div[1]/div[1]/div[4]/div[1]/div[2]/div[1]/div[4]/div[2]/div[2]/div[4]/div[1]/div[1]/div[1]/span[2]")
In time these methods might change depending on their development process, but you could use the above steps to update the script.
P.S. I wasn't satisfied with the marketwatch analyst price targets. I think the wisdom of the crowd is better on tipranks.
Try this one. Works perfectly fine on my personal Stock Portfolio on Google Sheets:
Lowest Price Target:
=importxml(CONCATENATE("https://www.tipranks.com/stocks/", A1,"/forecast"), "//*[#class='colorpurple-dark ml3 mobile_fontSize7 laptop_ml0']")
Average Price Target:
=importxml(CONCATENATE("https://www.tipranks.com/stocks/", A4,"/forecast"), "//*[#class='colorgray-1 ml3 mobile_fontSize7 laptop_ml0']")
Highest Price Target:
=importxml(CONCATENATE("https://www.tipranks.com/stocks/", A4,"/forecast"), "//*[#class='colorpale ml3 mobile_fontSize7 laptop_ml0']")

ImportXML google sheet for shipment package tracking

I want to track each FEDEX, DHL and UPS shipment status directly from google sheets. I am using importxml function:
=IMPORTXML("https://www.fedex.com/apps/fedextrack/?action=track&tracknumbers="&C2&"&locale=en_US&cntry_code=us","//h1/div[#class="redesignSnapshotTVC snapshotController_addr_label dest"]/title")
However it shows error.
Attaching my sheet link for this: https://docs.google.com/spreadsheets/d/1E1L0rn9-H4MCutI1On2uHDkkPo1pdjRpv014YREGIdU/edit?usp=sharing
Please tell what is best way to do it. I am from non tech background.
Thanks so much for help!
Common issue. You're trying to import html that is generated after loading. That means we have to look for how the data you want is generated.
Data source
Upon inspection of the site, I found that it was making an XHR to the URL https://www.fedex.com/trackingCal/track, and that it was doing so via POST with a long payload. The response was in JSON format. Of note, there is the scanEventList entry.
"scanEventList": [{
"date": "2020-07-15",
"time": "13:15:00",
"gmtOffset": "-07:00",
"status": "Delivery exception",
"statusCD": "DE",
"scanLocation": "SAN BERNARDINO, CA",
"scanDetails": "Future delivery requested",
"scanDetailsHtml": "",
"rtrnShprTrkNbr": "",
"statusExceptionCode": "17",
"isClearanceDelay": false,
"isDelivered": false,
"isDelException": true,
"isException": true
},
...
]
Solution
First, get the ImportJSON script from GitHub, and add it into your sheet's scripts (Tools > Script Editor). It's not the most amazing thing, but it will at least give us ImportJSONViaPost() to get the data we want:
=INDEX(ImportJSONViaPost("https://www.fedex.com/trackingCal/track","data=%7B%22TrackPackagesRequest%22%3A%7B%22appType%22%3A%22WTRK%22%2C%22appDeviceType%22%3A%22DESKTOP%22%2C%22supportHTML%22%3Atrue%2C%22supportCurrentLocation%22%3Atrue%2C%22uniqueKey%22%3A%22%22%2C%22processingParameters%22%3A%7B%7D%2C%22trackingInfoList%22%3A%5B%7B%22trackNumberInfo%22%3A%7B%22trackingNumber%22%3A%22"&A2&"%22%2C%22trackingQualifier%22%3A%22%22%2C%22trackingCarrier%22%3A%22%22%7D%7D%5D%7D%7D&action=trackpackages&locale=en_US&version=1&format=json",,"/TrackPackagesResponse/packageList/scanEventList,/TrackPackagesResponse/packageList/trackingCarrierDesc","noHeaders"),1)
Arguments:
URL for the tracker
The POST payload. Cell A2 Holds your tracking number.
Leave empty
Query - Lets us select the data that we want. In this example, I chose to select the carrier description and the entire scanEventList entry, but you can specify particular elements of that as well.
"noHeaders" means just the data.
Just using the JSON import gives us an entry for each element of scanEventList, but the first is the most recent, so, we use INDEX to retrieve the first entry, which should contain what you need.
For additional help on the ImportJSON package, see here.

BigCommerce storefront apis for order

Where is the documentation for /api/storefront/orders/*?
I was expecting to find it on this page.
https://developer.bigcommerce.com/api-docs/cart-and-checkout/working-sf-apis
Specifically, the documentation that would cover /api/storefront/orders/:order-id
and cover the valid inputs to the querystring. I know you can pass include, with one or more of the values as a comma separated string
payments
lineItems.physicalItems.socialMedia
lineItems.physicalItems.options
lineItems.digitalItems.socialMedia
lineItems.digitalItems.options
Edit
The checkout stencil context object used on theme\templates\pages\order-confirmation.html has this schema
{
"order_confirmation_content": "goes in the body",
"checkout_head": "goes in the head",
"order": {
"id": 206
},
"header_image": "for an img src attribute"
}
The documentation for the storefront orders API can be found here:
https://developer.bigcommerce.com/api-reference/orders/storefront-orders-api/order/ordersbyorderidget
However, as you mentioned, there are a few query parameters that are undocumented. Those are not officially supported, and they might be subject to change in the future. This is a case where our position is to hold off on documenting the API parameters until we've determined long-term support. Hope that helps to provide some context!

Which fields are required to create an event through Social Tables API

I have the following questions that I was not clear on from the API documentation:
Which fields are required to create an event?
What does "Invalid field: 0" mean? (this was an error message received when trying to create an event)
The sample body includes "spaces" as string -- is this the space name or ID?
Is this required? If yes, to create a space I need an event ID but to create an event do I need a space?
Hey thanks for using our API. It looks like the developer docs on our portal got kind of mangled. We'll be working on fixing that soon.
In the meantime, let me try to help.
So, the actual required fields for that endpoint are very minimal, here is a small sample post I made for a room here at Social Tables:
{
"name": "Dan's Office Party",
"category": "Other",
"spaces": [
{
"name": "st test"
}
]
}
The key thing here is that spaces is an array, with at least a name property attached.
The error message you referred to is a failing validation check on the type of one of the fields you submitted.
You do need a space to create an event, but as you can see, only the name is absolutely required. However, if you want to do any diagramming with that event, you'll probably want to attach a venue_id with one of our floorplan IDs in addition to the name property.
I have created an issue to update the mangled doc located at https://developer.socialtables.com/api-console#!/Events/post_4_0_legacyvm3_teams_team_events and will comment here when it is updated.