How to set the maxFlightTime in a flight offers search with the Amadeus API? - amadeus

I am making a POST to the Amadeus API for flight offers.
I am trying to set the maxFlightTime parameter.
The API documentation says:
maxFlightTime number example: 200 This option allows to modify the
value for the Elapsed Flying Time (EFT) masterPricer option
https://developers.amadeus.com/self-service/category/air/api-doc/flight-offers-search/api-reference
My question is:
What does this parameter expect? The documentation says a number and provides 200 as an example.
What does the number represent? Is it minutes, hours, or something different?

maxFlightTime is a bit complex to use. The number is a percentage expressing how much longer the flight offers you want to find can be compared to the shortest flight that exists for these search criteria.
Let's take an example:
We are looking for a flight from MAD to SFO (and we are returning only 1 offer for the sake of the example) using the POST endpoint of Flight Offers Search:
JSON Body:
{
"currencyCode": "EUR",
"originDestinations": [
{
"id": "1",
"originLocationCode": "MAD",
"destinationLocationCode": "SFO",
"departureDateTimeRange": {
"date": "2021-05-01",
"time": "10:00:00"
}
}
],
"travelers": [
{
"id": "1",
"travelerType": "ADULT",
"fareOptions": [
"STANDARD"
]
}
],
"sources": [
"GDS"
],
"searchCriteria": {
"maxFlightOffers": 1,
"flightFilters": {
"cabinRestrictions": [
{
"cabin": "ECONOMY",
"coverage": "MOST_SEGMENTS",
"originDestinationIds": [
"1"
]
}
]
}
}
}
If you check the JSON response you will see that the offer is MAD to IST (duration PT4H15M so 4h15) and IST to SFO (duration PT13H20M so 13h20M) so in total duration of 17h35. Note that this API always returns the cheapest flight offers for the given criteria.
If now we want to do the same request adding maxFlightTime but we don't want to have such a long trip, we want to have a maximum total duration of 110% longer than the shortest flight available.
We can use this JSON body
{
"currencyCode": "EUR",
"originDestinations": [
{
"id": "1",
"originLocationCode": "MAD",
"destinationLocationCode": "SFO",
"departureDateTimeRange": {
"date": "2021-05-01",
"time": "10:00:00"
}
}
],
"travelers": [
{
"id": "1",
"travelerType": "ADULT",
"fareOptions": [
"STANDARD"
]
}
],
"sources": [
"GDS"
],
"searchCriteria": {
"maxFlightOffers": 1,
"flightFilters": {
"maxFlightTime": 110,
"cabinRestrictions": [
{
"cabin": "ECONOMY",
"coverage": "MOST_SEGMENTS",
"originDestinationIds": [
"1"
]
}
]
}
}
}
This is the response you will get:
MAD to DFW for a duration of PT10H35M (10h35) and then DAL (another Dallas Airport?) to SFO for a duration of
PT4H4M (4h04) so a total duration of 14h39.
This is why maxFlightTime can only be between 100 and 999.
The API specification is not very clear for this parameter, we will update it very soon.

Related

Adobe Analytics - how to get report API 2.0 to get multi-level breakdown data using Java

I need help in getting adobe-analytics data when multiple IDs are passed for multi-level breakdown using API 2.0.
I am getting first level data for V124 ----
"metricContainer": {
"metrics": [
{
"columnId": "0",
"id": "metrics/event113",
"sort": "desc"
}
]
},
"dimension": "variables/evar124",
but i want to use IDs returned in above call response to in second level breakdown of v124 to get v125 as---
"metricContainer": {
"metrics": [
{
"columnId": "0",
"id": "metrics/event113",
"sort": "desc",
"filters": [
"0"
]
}
],
"metricFilters": [
{
"id": "0",
"type": "breakdown",
"dimension": "variables/evar124",
"itemId": "2629267831"
},
{
"id": "1",
"type": "breakdown",
"dimension": "variables/evar124",
"itemId": "2629267832"
}
]
},
"dimension": "variables/evar125",
This always returns data only for 2629267831 ID and not 2629267832.
I want to get data for thousands of IDs (returned from first API call) in a single API call. What am i doing wrong?

I keep getting numberOfstops in the flightOffer API response as 0 even when there is a stop

I am new to the Amadeus API and generally the flight business as a whole but I have set up a dev account with Amadeus and I am on a test Plan at the moment. I made a call to the flightOffers API thus;
await Amadeus.shopping.flightOffersSearch.get({myRequestPayload})
I got a successful response with 2 offers. However, my confusion is around the field numberOfStops which is 0 in the response. Please see the segments below as copied from the response I got;
"segments": [
{
"departure": {
"iataCode": "SYD",
"terminal": "1",
"at": "2022-11-01T11:35:00"
},
"arrival": {
"iataCode": "MNL",
"terminal": "2",
"at": "2022-11-01T16:50:00"
},
"carrierCode": "PR",
"number": "212",
"aircraft": {
"code": "333"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT8H15M",
"id": "1",
"numberOfStops": 0,
"blacklistedInEU": false
},
{
"departure": {
"iataCode": "MNL",
"terminal": "1",
"at": "2022-11-01T19:20:00"
},
"arrival": {
"iataCode": "BKK",
"at": "2022-11-01T21:50:00"
},
"carrierCode": "PR",
"number": "732",
"aircraft": {
"code": "321"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT3H30M",
"id": "2",
"numberOfStops": 0,
"blacklistedInEU": false
}
]
From my understanding from what I have read recently about Direct, NonStops flights, this flight is definitely not NonStop since there is a stop at MNL.
Hence I think the numberOfStops should be say 2 since:
It is a round trip
For each trip, it stops at MNL
I am just guessing this Number based on what is apparent to me. Please correct me If I am wrong.
I need to understand why numberOfStops = 0 and not > 0.
Is there a way to determine the numberOfStops without relying on the value returned?
Thanks and I anticipate any help soonest.
numberOfStops is the number of stops planned on the segment for technical or operation purpose i.e. refueling. The API will rarely return with a value but when it does it means that a segment is flown with the same plane. This represents a scheduled stop for technical/operational purposes like for example to refuel. You can check the description of the parameter in the specification file.
The API does not directly return the number of flight connections. This will need to be checked by looking at the segment size. If a segment has 2 items it means it has 2 flights. In the case of a round trip, then itineraries[0] contains the segments of the way to go back, and itineraries[1] contains the segments (flights) of the way back.

Querying/flattening multi-level nested JSON in Cosmos DB when array name is random on one level deep down

I would like to get some help to write a query to get a flat JSON to feed Power BI.
The data store is a Cosmos DB container with JSON. The structure is fixed.
The example JSON stucture is this:
"orderid": "999888777",
"name": "dwayne.johnson",
"mainData": {
"giftData": {
"name": "Rocketship",
"giftDetails": {
"**123456789**": {
"boxInfo": [
{
"name": "Leonardo Da Vinci Big Box",
"city": "London",
"country": "United Kingdom",
"currency": "EUR",
"price": 99.43,
}
],
"colorScheme": [
{
"name": "Red Apple Delight",
"code": "123AAA",
}
],
"CourierInfo": [
{
"name": "UPS",
"code": "BBBA333",
}
],
"orderid": "444333434",
"name": "chris.rock",
"mainData": {
"giftData": {
"name": "Junglemaster XXL",
"giftDetails": {
"**32432423424**": {
"boxInfo": [
{
"name": "Gerba Tool Big O",
"city": "München",
"country": "Germany",
"currency": "EUR",
"price": 103.22,
}
],
"colorScheme": [
{
"name": "Green Mix",
"code": "999DDD",
}
],
"CourierInfo": [
{
"name": "GLS",
"code": "CCCGV3",
}
],
I would like to get to following output:
orderid
currency*
price**
999888777
EUR
99.43
444333434
EUR
103.22
*The path would be giftData.giftDetails.123456789 or 32432423424 or any random.boxInfo.currency
**The path would be giftData.giftDetails.123456789 or 32432423424 or any random.boxInfo.price
The question is how can I select the currency and price info 4 levels deep, when the container array name is a random number (in bold)?
Thank you very much for your time and help!

eBay API issues - cannot publish an offer

All of the following is being performed in eBay's API sandbox.
I am attempting to list an item by using the inventory API. Specifically, I have created an inventory item and a relevant offer for that item. When I make a POST request to the publish offer endpoint, I get the following error:
{
"errors": [
{
"errorId": 25016,
"domain": "API_INVENTORY",
"subdomain": "Selling",
"category": "REQUEST",
"message": "The title value is invalid. Seller Provided Title Value is missing."
},
{
"errorId": 25002,
"domain": "API_INVENTORY",
"subdomain": "Selling",
"category": "REQUEST",
"message": "A user error has occurred. The duration \"GTC\" day(s) is not available for this listing type, or invalid for category \"49996\".",
"parameters": [
{
"name": "0",
"value": "GTC"
},
{
"name": "1",
"value": "49996"
}
]
}
]
}
I can't see any reference in any of the API documentation to a "Seller Provided Title". The duration error is also confusing as the API says it only supports "GTC" listings. The product has a title so it must be in reference to something else.
My inventory item is as follows:
{
"sku": "13725",
"product": {
"title": "Harley Davidson bike",
"aspects": {
"Year": [
"2016"
],
"Model": [
"Road Glide Special"
],
"Manufacurer": [
"Harley-Davidson®"
],
"Type": [
"Touring"
],
"For Sale By": [
"Dealer"
],
"Vehicle Title": [
"Clear"
],
"Mileage": [
"13393"
],
"VIN (Vehicle Identification Number)": [
"1HD1KTM10GB627264"
],
"Color": [
"Black Quartz"
]
},
"description": "Item description goes here",
"imageUrls": [
"https://dw4i9za0jmiyk.cloudfront.net/2018/01/12/pre_ic60e5df584b870c3d2a55c86800eede_70618b24eb08.jpg"
]
},
"condition": "USED_EXCELLENT",
"availability": {
"pickupAtLocationAvailability": [
{
"quantity": 1,
"merchantLocationKey": "425",
"availabilityType": "IN_STOCK",
"fulfillmentTime": {
"value": 1,
"unit": "DAY"
}
}
]
}
}
And my offer object is as follows:
{
"offerId": "5852159010",
"sku": "13725",
"marketplaceId": "EBAY_MOTORS",
"format": "FIXED_PRICE",
"availableQuantity": 0,
"pricingSummary": {
"price": {
"value": "18294.0",
"currency": "USD"
}
},
"listingPolicies": {
"paymentPolicyId": "5807565000",
"fulfillmentPolicyId": "5806186000"
},
"categoryId": "49996",
"merchantLocationKey": "425",
"tax": {
"applyTax": false
},
"status": "UNPUBLISHED",
"eBayPlusEligible": false
}
I had similar issues on sandbox, and came to the conculsion it was broken.
They also have some limits on only certain categories working.
Have you tried it agains the live API, I have found this to be far more reliable, ignoring the fact doing development work live is dangerous!
For your info here is my working code offer:
inventory_template = {
"availability": {
"shipToLocationAvailability": {
"quantity": product.quantity_available
}
},
"condition": "NEW",
"product": {
"aspects": {spec.name: [spec.value] for spec in product.specifics},
"brand": product.product_brand,
"description": product.product_description,
"imageUrls": [
"https://ebay.mydomain.co.uk/{}".format(img.image_link) for img in product.images],
"mpn": product.product_mpn,
"title": product.product_title,
"upc": [
product.product_upc,
],
"ean": [
product.product_ean,
],
# "epid": "string"
},
"sku": sku,
}
offer_body = {
"availableQuantity": offer.available_quantity,
"categoryId": offer.category_id,
"listingDescription": html,
"listingPolicies": {
"paymentPolicyId": offer.payment_policy_id,
"returnPolicyId": offer.return_policy_id,
"fulfillmentPolicyId": offer.fulfillment_policy_id,
},
"merchantLocationKey": offer.merchant_location_key,
"pricingSummary": {
"price": {
"value": offer.summary_price_value,
"currency": offer.summary_price_currency
}
},
"sku": offer.sku,
"marketplaceId": offer.marketplace_id,
"format": offer.format
}
the offer.available_quantity etc are items from my database, its the structure I'm showing.

Improve search result based on field boost in elasticsearch

I am using ElasticSearch 1.7 first time and I have setup weight based on fields. It might change as per requirement. I am getting result from my query but issue is that if I change field weight dramatically then I can't see that much effect on records. Please check my below query and let me know if I am doing anything wrong.
ElasticSearch Query :
{
"from": 0,
"size": 10,
"highlight": {
"pre_tags": [
"<b>"
],
"post_tags": [
"</b>"
],
"fields": {
"title": {},
"description": {}
}
},
"query": {
"function_score": {
"query": {
"query_string": {
"query": "any keyword",
"fields": [
"fullText",
"title^100",
"authors^4",
"pubYear^4",
"publisher^4",
"abstract^2",
"documentTypeName^2",
"topic^6",
"topicSynonym^6"
"quality_value^6",
"domain^2"
],
"default_operator": "AND",
"analyze_wildcard": true
}
},
"score_mode": "sum",
"boost_mode": "sum",
"max_boost": 100
}
}
}
Sample Data:
{
"took": 44,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1465,
"max_score": 14.961364,
"hits": [
{
"_index": "snData",
"_type": "report",
"_id": "159",
"_score": 14.961364,
"_source": {
"str_ID": "159",
"topic": [
"strategy",
"Consumer-targeted strategy"
],
"topicSynonym": [
"assistance",
"coping",
"coping strategies",
"encouragement",
"support"
],
"fullText": "Background: As the incidence and prevalence of prostate cancer continue to rise, the number of men needing help and support to assist them in coping with disease and treatment-related symptoms and their psychosocial effects is likely to increase.",
"quality_value": 1,
"ID": 24034,
"title": "Psychosocial interventions for men with prostate cancer",
"authors": "Parahoo K E Noyes",
"pubYear": "2013",
"publisher": "",
"abstractEN": "Background: As the incidence and prevalence of prostate cancer continue to rise, the number of men needing help and support to assist them in coping with disease and treatment-related symptoms and their psychosocial effects is likely to increase.",
"uniqueID": "",
"documentTypeName": "Review of effects",
"viewCount": 28,
},
"highlight": {
"title": [
"Interventions for men with prostate <b>cancer</b>"
],
"abstract": [
"Background: As the incidence and prevalence of prostate <b>cancer</b> continue to rise, the number of men"
]
}
}
]
}
}
Use Case : If I change weight of quality_value or of anyone else then it should change result based on field weight. I am not sure whether my query is correct or I am missing anything. I am using ElasticSearch 1.7.