How to get alternative versions of book listings in Amazon PAAPI5 (get hardcover, paperpack, mass market versions of book listing)? - amazon-product-api

Version 4 of the Amazon product advertising api let you use the AlternateVersions response group to get related products, which for books let you get all the different formats of a book listing (hardcover, paperback, mass market, etc.)
Version 5 of the API does not have AlternateVersions for some reason. Is there any way to get the different versions of a book in PAAPI5?

I'm having the same issue. In my case I need just hardcover and kindle version of a book.
GetVariations (successor of AlternateVersions) is for some reason not working for books and just returns no result back.
The only possible way that I'm aware of is to do two API request (SearchItems) including the specific search index Books for books and KindleStore for kindle files. Not specifying the search index normally returns you just the hardcopy of the Books search index.
To differentiate between books and kindle version check the ItemInfo.Classifications.ProductGroup.DisplayValue or ItemInfo.Classifications.Binding.DisplayValue
For some unknown reason (at least to me) the API is returning only a subset of results when not specifying the search index (in the below example the kindle one)
Example
In the following example I looking for the hardcopy or kindle of the book with ISBN 9780262043649 by doing a SearchItem request.
a) Hardcopy with given search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "Books",
"PartnerTag": "*******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "0262043645",
"DetailPageURL": "https://www.amazon.com/dp/0262043645?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Hardcover",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Book",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence (The MIT Press)",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=stripbooks&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
b) Kindle with given search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"SearchIndex": "KindleStore",
"PartnerTag": "******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&i=digital-text&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
c) No specific search index
Payload
{
"Keywords": "9780262043649",
"Resources": [
"ItemInfo.Classifications",
"ItemInfo.Title"
],
"PartnerTag": "*******",
"PartnerType": "Associates",
"Marketplace": "www.amazon.com",
"Operation": "SearchItems"
}
Response
{
"SearchResult": {
"Items": [
{
"ASIN": "B08BT4MM18",
"DetailPageURL": "https://www.amazon.com/dp/B08BT4MM18?tag=getabstractcom&linkCode=osi&th=1&psc=1",
"ItemInfo": {
"Classifications": {
"Binding": {
"DisplayValue": "Kindle Edition",
"Label": "Binding",
"Locale": "en_US"
},
"ProductGroup": {
"DisplayValue": "Digital Ebook Purchas",
"Label": "ProductGroup",
"Locale": "en_US"
}
},
"Title": {
"DisplayValue": "Novacene: The Coming Age of Hyperintelligence",
"Label": "Title",
"Locale": "en_US"
}
}
}
],
"SearchURL": "https://www.amazon.com/s?k=9780262043649&rh=p_n_availability%3A-1&tag=getabstractcom&linkCode=osi",
"TotalResultCount": 1
}
}
You can try those examples in the API's scratchpad.
More information about the search index of the product advertising API is available on the official documentation here

Related

Swift, JSON model

I have a question regarding building a JSON model namely, I should declare a date that will be different each day - in this case: "2020-11-19" as below.
This is a response for the current day.
{
"dates": {
"2020-11-19": {
"countries": {
"Poland": {
"date": "2020-11-19",
"id": "poland",
"links": [
{
"href": "/api/2020-11-19/country/poland",
"rel": "self",
"type": "GET"
}
],
"name": "Poland",
"name_es": "Polonia",
"name_it": "Polonia",
"regions": [],
"source": "John Hopkins University",
"today_confirmed": 796798,
"today_deaths": 12088,
"today_new_confirmed": 23975,
"today_new_deaths": 637,
"today_new_open_cases": 4335,
"today_new_recovered": 19003,
"today_open_cases": 422824,
"today_recovered": 361886,
"today_vs_yesterday_confirmed": 0.03102262743215456,
"today_vs_yesterday_deaths": 0.05562832940354556,
"today_vs_yesterday_open_cases": 0.010358695210626712,
"today_vs_yesterday_recovered": 0.055421236981710864,
"yesterday_confirmed": 772823,
"yesterday_deaths": 11451,
"yesterday_open_cases": 418489,
"yesterday_recovered": 342883
}
},
"info": {
"date": "2020-11-19 00:00CET",
"date_generation": "2020-11-19 22:34",
"yesterday": "2020-11-18 00:00CET"
}
}
},
"metadata": {
"by": "Narrativa & AppliedXL",
"url": [
"wwww.narrativa.com",
"www.appliedxl.com"
]
},
"total": {
"date": "2020-11-19",
"name": "Total",
"name_es": "Total",
"name_it": "Total",
"rid": "#total",
"source": "Narrativa",
"today_confirmed": 56684618,
"today_deaths": 1356365,
"today_new_confirmed": 525111,
"today_new_deaths": 8186,
"today_new_open_cases": 273944,
"today_new_recovered": 242981,
"today_open_cases": 19082735,
"today_recovered": 36245518,
"today_vs_yesterday_confirmed": 0.009350349175964112,
"today_vs_yesterday_deaths": 0.00607189401407382,
"today_vs_yesterday_open_cases": 0.014564678824917632,
"today_vs_yesterday_recovered": 0.00674899660543371,
"yesterday_confirmed": 56159507,
"yesterday_deaths": 1348179,
"yesterday_open_cases": 18808791,
"yesterday_recovered": 36002537
},
"updated_at": "2020-11-19 21:34UTC"
}
How I should build a model so that this property would be changed every day? (of course, this date needs to have a proper format "yyyy-MM-dd")
I would probably do:
var dates: [String: YourModel]
if it will potentially have multiple dates in that field.. otherwise, I'd probably do a custom object that overrides init(from decoder: and parses out that info

How to retrieved linked document from a BIM360 issue payload?

It's all said in the title but let me detail my problem:
I want to retrieve a document linked to a given BIM360 issue. So in that specific case I want to find "georef.dwg" (at least it's version URN storage on BIM360), knowing issue #31 or #32.
When I look at the payload from the GET issues/:id, here is what I see:
{
"data":{
"id":"0f84bfa2-43be-4761-8c84-ff5314fca382",
"type":"quality_issues",
"links":{
"self":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382"
},
"attributes":{
"created_at":"2020-09-24T13:45:02.754Z",
"synced_at":"2020-09-24T13:45:02.759Z",
"updated_at":"2020-09-24T13:45:02.756Z",
"close_version":null,
"closed_at":null,
"closed_by":null,
"created_by":"TT4KN3D3PWME",
"opened_at":"2020-09-24T13:45:02.740Z",
"opened_by":"TT4KN3D3PWME",
"updated_by":"TT4KN3D3PWME",
"starting_version":1,
"title":"Issue for testing georeferencing",
"description":"",
"location_description":null,
"markup_metadata":null,
"tags":null,
"target_urn":"urn:adsk.wipprod:dm.lineage:BAu6NmpZRyW913SLf6J6IA",
"target_urn_page":null,
"collection_urn":null,
"due_date":"2020-09-30T00:00:00.000Z",
"identifier":30,
"status":"open",
"assigned_to":"201007062239661",
"assigned_to_type":"user",
"answer":null,
"answered_at":null,
"answered_by":null,
"pushpin_attributes":{
"type":"TwoDRasterPushpin",
"location":{
"x":5.710041960416264,
"y":4.169567131777653,
"z":0
},
"object_id":null,
"viewer_state":null,
"created_at":"2020-09-24T13:45:02.766Z",
"created_by":"TT4KN3D3PWME",
"created_doc_version":1,
"external_id":null,
"attributes_version":2
},
"snapshot_urn":"urn:adsk.objects:os.object:ng-issues-prod-86fe431f-012b-4349-939e-cbb0788cfbba/25881168-6246-4c32-9cc2-f31409ce519a",
"owner":"TT4KN3D3PWME",
"issue_type_id":null,
"issue_type":null,
"issue_sub_type":null,
"root_cause_id":null,
"root_cause":null,
"quality_urns":null,
"permitted_statuses":[
"answered",
"closed",
"void"
],
"permitted_attributes":[
"answer",
"assigned_to",
"assigned_to_type",
"description",
"due_date",
"location_description",
"trades",
"owner",
"issue_type",
"issue_type_id",
"root_cause",
"root_cause_id",
"title",
"status",
"sheet_metadata",
"lbs_location",
"pushpin_attributes",
"snapshot_urn",
"close_version",
"comments_attributes",
"attachments_attributes",
"markup_metadata",
"updated_at",
"tags",
"collection_urn",
"custom_attributes",
"ng_issue_subtype_id"
],
"comment_count":0,
"attachment_count":0,
"permitted_actions":[
"add_comment",
"add_attachment"
],
"sheet_metadata":{
"is3D":false,
"sheetGuid":"6882be48-6626-5238-d3df-94e9f0a0019d",
"sheetName":"2D View"
},
"lbs_location":null,
"ng_issue_subtype_id":"1611f9cf-4ba0-43d0-af0b-0047499beb81",
"ng_issue_type_id":"5830d615-c7fa-4aa3-8f9e-aa520176fa4d",
"issue_template_id":null,
"custom_attributes":[
],
"trades":null,
"comments_attributes":null,
"attachments_attributes":null
},
"relationships":{
"container":{
"links":{
"self":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/relationships/container",
"related":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/container"
}
},
"attachments":{
"links":{
"self":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/relationships/attachments",
"related":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/attachments"
}
},
"changesets":{
"links":{
"self":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/relationships/changesets",
"related":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/changesets"
}
},
"comments":{
"links":{
"self":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/relationships/comments",
"related":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/comments"
}
},
"activity_batches":{
"links":{
"self":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/relationships/activity-batches",
"related":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/activity-batches"
}
},
"root_cause_obj":{
"links":{
"self":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/relationships/root-cause-obj",
"related":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/root-cause-obj"
}
},
"issue_type_obj":{
"links":{
"self":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/relationships/issue-type-obj",
"related":"https://developer.api.autodesk.com/issues/v1/containers/86fe431f-012b-4349-939e-cbb0788cfbba/quality-issues/0f84bfa2-43be-4761-8c84-ff5314fca382/issue-type-obj"
}
}
}
}
}
I don't see any information there that allow me to retrieve "georef.dwg", but BIM360 obviously does... I see targetUrn but this isn't the URN of a BIM360 item version.
When I create an issue on a Revit file, then I get something in issue.attributes.pushpin_attributes.viewer_state.seedURN which seems to point to the correct version URN, but not when creating issues on dwg's.
the target_urn is the way to go. In this example, I create an issue on Drawing1.dwg on my account.
From BIM360docs folder content, I got this
{
"id": "urn:adsk.wipprod:dm.lineage:_3AoTpMBQDm060PABvgQKg",
"name": "Drawing1.dwg",
"type": "items",
"state": true,
…
}
From the Issues API, I got the following: (I removed all irrelevant properties)
[
{
"created_at": "2020-10-01T14:05:06.524Z",
"synced_at": "2020-10-01T14:05:06.528Z",
…
"starting_version": 6,
"title": "cyrille",
"target_urn": "urn:adsk.wipprod:dm.lineage:_3AoTpMBQDm060PABvgQKg",
"target_urn_page": null,
…
"pushpin_attributes": {
"type": "TwoDRasterPushpin",
"location": {
"x": 2.8286987422505243,
"y": 5.8554650473401395,
"z": 0
},
….
},
…
"sheet_metadata": {
"is3D": false,
"sheetGuid": "6882be48-1234-5238-d3df-94e9f000019d",
"sheetName": "2D View"
},
….
"id": "ae09c72c-8236-6895-ba27-0141bf6aae97"
}
]
See target_urn = urn:adsk.wipprod:dm.lineage:_3AoTpMBQDm060PABvgQKg, which match my item id = urn:adsk.wipprod:dm.lineage:_3AoTpMBQDm060PABvgQKg
starting_version will give you the BIM360docs item version you want.

How do corporate codes work in Amadeus Fligh Offers Search API?

I'm working with Amadeus Flight Offers Search API and I'd like to use my client's corporate code in order to search offers including corp nego fares. I see there is a field for corporate codes in the schema, but corporate codes need to be loaded into an OID in order to work, and I'm not specifying an OID when calling the API. How will this work?
I have tried using some corporate codes that I know and no corporate fares have appeared. This is an example I have tried.
{
"currencyCode": "EUR",
"originDestinations": [
{
"id": "1",
"originLocationCode": "MAD",
"destinationLocationCode": "NYC",
"departureDateTimeRange": {
"date": "2019-09-01",
"time": "10:00:00",
"timeWindow" : "6H"
}
},
{
"id": "2",
"originLocationCode": "NYC",
"destinationLocationCode": "MIA",
"departureDateTimeRange": {
"date": "2019-09-03",
"time": "17:00:00",
"timeWindow": "2H"
}
},
{
"id": "3",
"originLocationCode": "MCO",
"destinationLocationCode": "MAD",
"departureDateTimeRange": {
"date": "2019-09-07",
"time": "17:00:00",
"timeWindow": "6H"
}
}
],
"travelers": [
{
"id": "1",
"travelerType": "ADULT",
"fareOptions": [
"STANDARD"
]
}
],
"sources": [
"GDS", "PYTON"
],
"searchCriteria": {
"maxFlightOffers": 50,
"pricingOptions" : {
"corporateCodes" : ["000001"]
},
"flightFilters": {
"connectionRestriction":
{
"airportChangeAllowed" : false,
"maxNumberOfConnections" : 1
}
}
}
}
The result is all published fares.
In Self-Service, we only offer public fares. Negotiated or private fares are only accessible to our Enterprise users. The reference documentation is not very clear about it, the API is still in beta and we will use your feedback to improve it.

ElasticSearch filtered query with operator AND and OR

I'm intervening on an existing app which interacts with an elasticsearch sever and i'm seeing some weird responses, probably due to the fact that i'm new to elastic.
I have the indexed item below :
"_id": "59773d268770541557000012",
"_score": 0.03282923,
"_source": {
"_id": "59773d268770541557000012",
"active": null,
"address": "dummy address",
"center_ids": [],
"consultation_site_ids": [],
"coordinates": null,
"created_at": "2017-07-25T14:44:22.270+02:00",
"death_declaration_form_step_id": "56ddb086f0e0103b44000000",
"end_of_pregnancy_form_step_id": "56c34e63f0e0105e65000000",
"fax": "06.95.40.58.84",
"form_step_ids": [
"55361b215342491667030000",
"5541f16252f131f6a125a375",
"55361ba05342491667040000",
"553610835342491667010000",
"55361d225342491667050000",
"5541f34a52f131f6a125a377"
],
"hospital_id": "57c004905c5393772c002a62",
"name": "test site d'encronologie",
"phone": "06.95.40.58.84",
"short_name": "test site d'encronologie d'endcronologie",
"sites_union_ids": [],
"state": "active",
"updated_at": "2017-07-25T14:44:22.270+02:00",
"url": "http://www.testurl.com",
"user_ids": [],
"warnings_threshold": null,
"_type": "Site
AND I am querying the server with this query:
"query":{
"filtered":{
"query":{
"bool":{
"should":[
{
"multi_match":{
"fields":[
"name^5",
"name.edge^1",
"name.full^0.3"
],
"query":"enc",
"type":"cross_fields"
}
},
{
"match":{
"name":{
"query":"enc",
"type":"phrase_prefix",
"operator":"or"
}
}
},
{
"match":{
"name":{
"query":"enc",
"type":"boolean",
"boost":5
}
}
}
]
}
},
"filter":{
"and":[
{
"term":{
"hospital_id":"57c004905c5393772c002a62"
}
},
{
"term":{
"state":"active"
}
}
]
}
}
}}
Which returns nothing (no hits)
And the other hand, if I change the filter operator "AND" to "OR" I recieve my 1 hit.
I am talking about the "and" on the "filter" branch :
"filter":{
"and":[
I realy don't understand how come OR works but not AND?
Then again when I change my query term from "enc" to "zzz_enc" in all the query{} of the first branch WHILE keeping the "OR" I have zero matches, even though the filter condition hospital_id and state are true on my item.
Why does the filter operator behave like this ?
Thank you in advance.

How to use a JSON data source with assemble.io?

The assemble.io documentation gives some examples of using simple JSON as a data source, such as:
{
"title": "Assemble" ,
"author": "Brian Woodward"
}
But, what if I wanted to use a more complex JSON structure for my data (to display a list of books on a single page)? How can that be done?
{
"books": [
{
"title": "Book A",
"author": "Fred"
},
{
"title": "Book 47",
"author": "Joe"
}
]
}
Let say your library.json contain:
{
"books": [
{
"title": "Book A",
"author": "Fred"
},
{
"title": "Book 47",
"author": "Joe"
}
]
}
Use {{each}} (Assemble use handlebarjs for default templating) to display a list of books on a single page:
{{#each library.books}}
{{title}} - {{author}}
{{/each}}