how to use flight xml(nodejs)


#1

Hi ,

I am using a trial version.

my source

var restclient = require(‘restler’);
//date format 추가
var dateFormat = require(‘dateformat’);

var fxml_url = ‘http://usrname:api@flightxml.flightaware.com/json/FlightXML2/Enroute?airport=ICN&filter=""&howMany=100&offset=0&SetMaximumResultSize?max_size=100’;

restclient.get(fxml_url // + ‘Enroute’, {
//username: username,
//password: apiKey,
//SetMaximumResultSize:max_size,
//query: {airport: ‘ICN’, howMany: 15, filter: ‘’, offset: 0,SetMaximumResultSize:‘max_size’,max_size:60 }
//}
).on(‘success’, function(result, response) {
//util.puts(‘Aircraft en route to ICN:’);
console.log(‘Aircraft en route to ICN:’);
//util.puts(util.inspect(result, true, null));
var flights = result.EnrouteResult.enroute;

for (i in flights) {
  var flight = flights*;

 console.log(flight.ident + ' (' + flight.aircrafttype + ')	' + 
			dateFormat(flight.actualdeparturetime,"isoUtcDateTime")+'	'+dateFormat(flight.estimatedarrivaltime,"isoUtcDateTime")+'	'+flight.filed_departuretime+'	' + flight.originName + ' (' + flight.origin + ')'+'	'+flight.originCity+'목적지:'+flight.destination+'	'+flight.destinationName+'	'+flight.destinationCity );

}

//
// console.log(flight.ident + ’ (’ + flight.aircrafttype + ‘) ’ +
// flight.originName + ’ (’ + flight.origin + ‘)’+’ ‘+flight.date_start + ‘-’+flight.date_end+’-’+flight.destination+’-’+flight.airlineCode+’-’+flight.channels+’-’+’-’+flight.enabled+’-’+flight.max_weekly);
// }
});

my result
Aircraft en route to ICN:
PAC237 (B744) 2017-07-11T08:13:33Z 1970-01-18T08:32:15Z 1499480400 앵커리지 테드 스티븐스 국제공항 (PANC) Anchorage, AK목적지:RKSI 인천국제공항 Seoul (Incheon)
PAC989 (B744) 2017-07-11T08:13:33Z 1970-01-18T08:33:51Z 1499575500 앵커리지 테드 스티븐스 국제공항 (PANC) Anchorage, AK목적지:RKSI 인천국제공항 Seoul (Incheon)
TWB136 () 2017-07-11T08:13:33Z 1970-01-18T08:34:03Z 1499626200 왓따이 국제공항 (VLVT) Vientiane (Viangchan)목적지:RKSI 인천국제공항 Seoul (Incheon)
MM5 (A320) 2017-07-11T08:13:33Z 1970-01-18T08:35:50Z 1499743800 간사이 국제공항 (RJBB) Izumisano, Osaka목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR942 (74F) 2017-07-11T08:13:33Z 1970-01-18T08:35:53Z 1499747400 톈진 빈하이 국제공항 (ZBTJ) Tianjin목적지:RKSI 인천국제공항 Seoul (Incheon)
MM905 (A320) 2017-07-11T08:13:33Z 1970-01-18T08:35:54Z 1499746200 나하 공항 (ROAH) Naha, Okinawa목적지:RKSI 인천국제공항 Seoul (Incheon)
TWB284 () 2017-07-11T08:13:33Z 1970-01-18T08:36:00Z 1499753400 간사이 국제공항 (RJBB) Izumisano, Osaka목적지:RKSI 인천국제공항 Seoul (Incheon)
QTR858 (B77W) 1970-01-18T08:35:30Z 1970-01-18T08:36:00Z 1499728200 Hamad Int’l (OTHH) Doha목적지:RKSI 인천국제공항 Seoul (Incheon)
UAE322 (A388) 1970-01-18T08:35:31Z 1970-01-18T08:36:00Z 1499730000 두바이 국제공항 (OMDB) Dubai목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR201 (A388) 1970-01-18T08:35:16Z 1970-01-18T08:36:00Z 1499715600 로스앤젤레스 국제공항 (KLAX) Los Angeles, CA목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR211 (B772) 1970-01-18T08:35:19Z 1970-01-18T08:36:00Z 1499717400 샌프란시스코 국제공항 (KSFO) San Francisco, CA목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL898 (A333) 1970-01-18T08:35:54Z 1970-01-18T08:36:00Z 1499751300 상하이 푸둥 국제공항 (ZSPD) Shanghai목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL870 (B772) 1970-01-18T08:35:57Z 1970-01-18T08:36:00Z 1499754600 다롄 저우수이쯔 국제공항 (ZYTL) Dalian, Liaoning목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL24 (B748) 1970-01-18T08:35:19Z 1970-01-18T08:36:01Z 1499717400 샌프란시스코 국제공항 (KSFO) San Francisco, CA목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL1408 (B738) 1970-01-18T08:35:57Z 1970-01-18T08:36:01Z 1499757300 김해국제공항 (RKPK) Pusan목적지:RKSI 인천국제공항 Seoul (Incheon)
ACA61 (B789) 1970-01-18T08:35:12Z 1970-01-18T08:36:01Z 1499708700 토론토 피어슨 국제공항 (CYYZ) Toronto, Ontario목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL888 (B738) 1970-01-18T08:35:51Z 1970-01-18T08:36:01Z 1499751000 샤먼 가오치 국제공항 (ZSAM) Xiamen, Fujian목적지:RKSI 인천국제공항 Seoul (Incheon)
JNA264 (B738) 2017-07-11T08:13:33Z 1970-01-18T08:36:01Z 1499757900 New Kitakyushu (RJFR) Kitakyushu, Fukuoka목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL72 (B748) 1970-01-18T08:35:25Z 1970-01-18T08:36:01Z 1499723400 밴쿠버 국제공항 (CYVR) Vancouver, British Columbia목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL82 (A388) 1970-01-18T08:35:12Z 1970-01-18T08:36:01Z 1499709600 존 F. 케네디 국제공항 (KJFK) New York, NY목적지:RKSI 인천국제공항 Seoul (Incheon)
CSH827 (B738) 1970-01-18T08:35:54Z 1970-01-18T08:36:01Z 1499753700 상하이 푸둥 국제공항 (ZSPD) Shanghai목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL840 (B739) 1970-01-18T08:35:58Z 1970-01-18T08:36:01Z 1499757900 Dashuipo (ZSWH) Weihai, Shandong목적지:RKSI 인천국제공항 Seoul (Incheon)
JNA114 (B738) 1970-01-18T08:35:51Z 1970-01-18T08:36:02Z 1499750400 홍콩 국제공항 (VHHH) Hong Kong목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL124 (A333) 1970-01-18T08:35:27Z 1970-01-18T08:36:02Z 1499725500 Brisbane (YBBN) 브리즈번 AU목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR271 (B772) 1970-01-18T08:35:24Z 1970-01-18T08:36:02Z 1499722800 시애틀 터코마 국제공항 (KSEA) Seattle, WA목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL130 (B77W) 1970-01-18T08:35:22Z 1970-01-18T08:36:02Z 1499719500 오클랜드 국제공항 (뉴질랜드) (NZAA) Auckland목적지:RKSI 인천국제공항 Seoul (Incheon)
JNA22 (B738) 1970-01-18T08:35:48Z 1970-01-18T08:36:02Z 1499747700 막탄 세부 국제공항 (RPVM) Lapu-Lapu City목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL828 (B739) 1970-01-18T08:35:50Z 1970-01-18T08:36:02Z 1499748300 선전 바오안 국제공항 (ZGSZ) Shenzhen, Guangdong목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR308 (A321) 1970-01-18T08:35:59Z 1970-01-18T08:36:02Z 1499758500 옌타이 라이산 국제공항 (ZSYT) Yantai, Shandong목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR702 (B77L) 1970-01-18T08:35:49Z 1970-01-18T08:36:02Z 1499746500 니노이 아키노 국제공항 (RPLL) Metro Manila목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL848 (B739) 1970-01-18T08:35:58Z 1970-01-18T08:36:02Z 1499756700 지난 야오창 공항 (ZSJN) Jinan, Shandong목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL1414 (B738) 1970-01-18T08:35:59Z 1970-01-18T08:36:02Z 1499759100 대구국제공항 (RKTN) Daegu목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL622 (B773) 1970-01-18T08:35:50Z 1970-01-18T08:36:02Z 1499746800 니노이 아키노 국제공항 (RPLL) Metro Manila목적지:RKSI 인천국제공항 Seoul (Incheon)
JJA1901 (737) 1970-01-18T08:35:54Z 1970-01-18T08:36:02Z 1499752800 신치토세 공항 (RJCC) Chitose, Hokkaidō (near Sapporo)목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR722 (B763) 1970-01-18T08:35:51Z 1970-01-18T08:36:02Z 1499749800 홍콩 국제공항 (VHHH) Hong Kong목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL18 (A388) 1970-01-18T08:35:18Z 1970-01-18T08:36:02Z 1499715600 로스앤젤레스 국제공항 (KLAX) Los Angeles, CA목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL842 (B739) 1970-01-18T08:35:58Z 1970-01-18T08:36:02Z 1499755800 칭다오 류팅 국제공항 (ZSQD) Qingdao, Shandong목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR350 (A321) 1970-01-18T08:35:57Z 1970-01-18T08:36:02Z 1499755800 난징 루커우 국제공항 (ZSNJ) Nanjing, Jiangsu목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL790 (A333) 1970-01-18T08:35:58Z 1970-01-18T08:36:02Z 1499757900 후쿠오카 공항 (RJFF) Fukuoka, Fukuoka목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR998 (B763) 2017-07-11T08:13:33Z 1970-01-18T08:36:03Z 1499758200 톈진 빈하이 국제공항 (ZBTJ) Tianjin목적지:RKSI 인천국제공항 Seoul (Incheon)
ESR632 (B738) 1970-01-18T08:35:53Z 1970-01-18T08:36:03Z 1499752200 나하 공항 (ROAH) Naha, Okinawa목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL122 (A333) 1970-01-18T08:35:26Z 1970-01-18T08:36:03Z 1499723100 시드니 공항 (YSSY) Sydney, NSW목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL54 (B748) 1970-01-18T08:35:32Z 1970-01-18T08:36:03Z 1499728200 호놀룰루 국제공항 (PHNL) Honolulu, HI목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR221 (A388) 1970-01-18T08:35:14Z 1970-01-18T08:36:03Z 1499709000 존 F. 케네디 국제공항 (KJFK) New York, NY목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR360 (A333) 1970-01-18T08:35:57Z 1970-01-18T08:36:03Z 1499756400 항저우 샤오산 국제공항 (ZSHC) Hangzhou, Zhejiang목적지:RKSI 인천국제공항 Seoul (Incheon)
JJA2102 (737) 1970-01-18T08:35:52Z 1970-01-18T08:36:03Z 1499751300 홍콩 국제공항 (VHHH) Hong Kong목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR231 (A333) 1970-01-18T08:35:30Z 1970-01-18T08:36:04Z 1499724600 호놀룰루 국제공항 (PHNL) Honolulu, HI목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR334 (A321) 2017-07-11T08:13:33Z 1970-01-18T08:36:04Z 1499757600 베이징 서우두 국제공항 (ZBAA) Beijing목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR728 (B744) 1970-01-18T08:35:50Z 1970-01-18T08:36:04Z 1499750400 노이 바이 국제공항 (VVNB) Hanoi목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR247 (B744) 1970-01-18T08:35:37Z 1970-01-18T08:36:04Z 1499713200 앵커리지 테드 스티븐스 국제공항 (PANC) Anchorage, AK목적지:RKSI 인천국제공항 Seoul (Incheon)
ASV703 (A321) 1970-01-18T08:35:58Z 1970-01-18T08:36:04Z 1499757900 다카마쓰 공항 (RJOT) Takamatsu, Kagawa목적지:RKSI 인천국제공항 Seoul (Incheon)
PAC751 (B744) 1970-01-18T08:35:36Z 1970-01-18T08:36:04Z 1499735400 앵커리지 테드 스티븐스 국제공항 (PANC) Anchorage, AK목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR724 (A321) 1970-01-18T08:35:53Z 1970-01-18T08:36:04Z 1499751600 홍콩 국제공항 (VHHH) Hong Kong목적지:RKSI 인천국제공항 Seoul (Incheon)
ESR932 (B738) 1970-01-18T08:35:51Z 1970-01-18T08:36:04Z 1499749200 홍콩 국제공항 (VHHH) Hong Kong목적지:RKSI 인천국제공항 Seoul (Incheon)
JNA214 (B772) 1970-01-18T08:35:59Z 1970-01-18T08:36:05Z 1499759100 간사이 국제공항 (RJBB) Izumisano, Osaka목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL318 (B772) 1970-01-18T08:36:00Z 1970-01-18T08:36:05Z 1499760000 톈진 빈하이 국제공항 (ZBTJ) Tianjin목적지:RKSI 인천국제공항 Seoul (Incheon)
EVA160 (A333) 1970-01-18T08:35:57Z 1970-01-18T08:36:05Z 1499757300 타이완 타오위안 국제공항 (RCTP) Taipei목적지:RKSI 인천국제공항 Seoul (Incheon)
AAR320 (A321) 2017-07-11T08:13:33Z 1970-01-18T08:36:05Z 1499760600 칭다오 류팅 국제공항 (ZSQD) Qingdao, Shandong목적지:RKSI 인천국제공항 Seoul (Incheon)
ESR642 () 1970-01-18T08:36:00Z 1970-01-18T08:36:05Z 1499759700 후쿠오카 공항 (RJFF) Fukuoka, Fukuoka목적지:RKSI 인천국제공항 Seoul (Incheon)
KAL480 (A333) 1970-01-18T08:35:51Z 1970-01-18T08:36:05Z 1499750700 노이 바이 국제공항 (VVNB) Hanoi목적지:RKSI 인천국제공항 Seoul (Incheon)

There are 60 data records.

Can I get 15 pieces of information each time? and

I wonder if I received only 60 data because I am a trial version.

If you can get more than 60 data, please tell me what code I need to add.

How do I get data in IATA code?

and

I want to know how to elaborate search conditions.

For example startdate: 20170711 enddate: 20170711 Departure airport:iCN arrival airport: NRT

OR startdate: 20170711 enddate: 20170711 Departure airport:iCN

OR startdate: 20170711 enddate: 20170711 arrival airport: ICN

I would be grateful if you could give me a detailed answer to my question.


#2

You received 60 flights back because your maximum result size is set to 60 (so even if you request more than 60 in your howMany parameters, you’ll only get 60).
If you want to receive 15 at a time then set your howMany to 60
The result includes a “next_offset” parameter that will tell you if there are more flights available. So in your example next_offset was most likely 60. If you want to get the next 60 results then repeat your query with offset=60. If there are no more results available then next_offset will be -1.

The next_offset will be found here:
var nextOffset = result.EnrouteResult.next_offset;

For the second part of your question regarding search conditions, what method are you referring to there?