# API for flight info

**URL:** https://discussions.flightaware.com/t/api-for-flight-info/28892
**Category:** AeroAPI
**Created:** [December 9, 2017, 9:12am UTC](https://discussions.flightaware.com/t/api-for-flight-info/28892 "2017-12-09T09:12:37Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![shaulzak](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/shaulzak/32/55133_2.png) [@shaulzak](https://discussions.flightaware.com/u/shaulzak)
#### Post date: [December 21, 2017, 12:18pm UTC](https://discussions.flightaware.com/t/api-for-flight-info/28892/7 "2017-12-21T12:18:35Z")

</div>

here is the code -

private const string fxmlUrl = “[http://flightxml.flightaware.com/json/FlightXML3](http://flightxml.flightaware.com/json/FlightXML3)”;  
private const string username = “MYUSERNAME”;  
private const string apiKey = “MYAPIKEY”;  
private static UriBuilder uriBuilder = new UriBuilder(fxmlUrl);

```
    public static void GetFlightData(string flightName)
    {
        var requestUrl = fxmlUrl.AppendPathSegment("FlightInfoStatus")
                .SetQueryParams(new { ident = "CAP85" });
        ProcessRepositories(requestUrl, username, apiKey).Wait();
    }

    private static async Task ProcessRepositories(string apiUrl, string username, string apiKey)
    {
        var serializer = new DataContractJsonSerializer(typeof(ArrayOfFlightInfoStatusStruct));
        var client = new HttpClient();
        var credentials = Encoding.ASCII.GetBytes(username + ":" + apiKey);
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials));

        var streamTask = client.GetStreamAsync(apiUrl);
        try
        {
            var arrayOfFlightInfoStatusStruct = serializer.ReadObject(await streamTask);// as ArrayOfFlightInfoStatusStruct;
        }catch(Exception e)
        {
            int y1 = 0;
        }
    }

```

---

_[View the full topic](https://discussions.flightaware.com/t/api-for-flight-info/28892)._
