Pulling 'My Alerts' through FlightXML2/3


#1

Hello all, I’ve just been wondering is there someway that I can pull in all of ‘My Alerts’ through some API or something like that? I had a look through the API documentation for FlightXML2/3 and I couldn’t find anything about pulling my account’s alerts, so just thought I’d ask here. Is there someway I can pull in ‘My Alerts’?

Thanks!


#2

We don’t have any way for you to pull in existing alerts. You can setup new alerts that will push to a designated endpoint though.


#3

Thank you for the information, guess I’ll have to figure it out! :slight_smile:


#4

Actually I’m sorry I forgot about the GetAlerts method in FlightXML2. If you call that it should return all the alerts setup on your account.


#5

Hello Conej,

I went and checked through the API, and was able to see the information regarding that function, so I’ve tried to pull it through in my Python script, but all I’m getting is a ‘503 - Service Unavailable’:

import sys
from suds import null, WebFault
from suds.client import Client
import logging

username = 'username'
apiKey = '1234...7890'
url = 'http://flightxml.flightaware.com/soap/FlightXML2/wsdl'

api = Client(url, username=username, password=apiKey)

print api.service.GetAlerts()

When I run the file, this is the message I get after waiting a long time (I guess it times out?):

Traceback (most recent call last):
  File "C:\test.py", line 12, in 
    print api.service.GetAlerts()
  File "C:\Python27\lib\site-packages\suds\client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "C:\Python27\lib\site-packages\suds\client.py", line 602, in invoke
    result = self.send(soapenv)
  File "C:\Python27\lib\site-packages\suds\client.py", line 649, in send
    result = self.failed(binding, e)
  File "C:\Python27\lib\site-packages\suds\client.py", line 708, in failed
    raise Exception((status, reason))
Exception: (503, u'Service Unavailable')

Is there any reason why that would return a 503? The other calls work correctly (api.service.Enroute/api.serviceMetar) that was in the example Python file.


#6

Hello again,

Just wanted to add, that I ended up testing the application in C# instead (just incase there was an issue with Python), and the project that I built can successful retrieve the METAR for something, but using the GetAlerts function ends up timing out with a 504. The account that I’m pulling has over a thousand alerts, so I’m just wondering would the server end up timing out building the response? I followed the instructions from here.

My main function is this, and it throws an exception on client.GetAlerts():

static void Main(string[] args)
        {
            FlightXML2SoapClient client = new FlightXML2SoapClient();
            client.ClientCredentials.UserName.UserName = "Username";
            client.ClientCredentials.UserName.Password = "1234...7890";

            FlightAlertListing alerts = client.GetAlerts();

            Console.WriteLine("There are {0} alerts", alerts.num_alerts);

            Console.ReadKey();
        }

Thanks!


#7

Ah you’ve discovered an unexpected issue with GetAlerts. We don’t paginate the alerts response, and since you have so many alerts the query is taking longer than the http timeout. I’ve opened a bug to see what we can do about that, and I’ll make sure the FlightXML3 implementation takes that issue into account.


#8

Thanks Conej, I’m glad to hear that! Would you happen to have an ETA on when that functionality would be implemented into XML3, or is there some place I can check to see if it gets updated with this call as the changelog says ‘not yet available’?