## Why Filter Fights?

When you have a large number of flights, you may find it necessary to filter the number or results returned in a single request.

This API request returns a stream of line-delimited JSON where each line of output is a single JSON object representing one flight. The flight object contains the properties of the flight as well as an array of the "Ad IDs" associated with that flight.

> ### Note  
> This endpoint does not return ad objects. By default, this endpoint returns all flights saved in an account, but you can use the query parameters to filter.

## Filtering Behaviors

Use the `StartDate` and `EndDate` query parameters to filter flights by a range time periods. For example, `?beforeStartDate:2017-01-01&afterStartDate:2016-11-30` returns all flights with a StartDate between 2016-12-01 and 2016-12-31. `?afterStartDate:2016-11-30` returns all flights with a `StartDate` of 2016-12-01 or later.

You can also use `StartDate` and `EndDate` query parameters in combination, which will only return flights that fall within _both_ those ranges.

Besides `beforeEndDate` and `afterEndDate`, you can also include the `noEndDate=true` query parameter. This will return any flights without an `EndDate` set _in addition_ to any flights filtered by an `EndDate` range.

> ### Important  
> You should URL encode special characters when filtering with the `name` and `nameContains` parameters.

## API Syntax

When using the _Flight Filtering_ API call, it is important to understand the syntax required to make the request. Because the Kevel API is a RESTful API, there is a specific request format that must be followed to ensure the endpoint can process the request. The format is:

`GET https://api.kevel.co/v1/fast/flight`

Where:

- `GET` \- the type of API request being made.
- `https://api.kevel.co` \- the URL for the request.
- `v1` \- the API version.
- `fast` \- the API endpoint being called.
- `flight` \- The value returned from the

**Response Parameters**

Along with flight information, additional response parameters will be returned with this request, which are listed in the table below.

| Property | Description |
| --- | --- |
| `LastModifiedDate`<br>(string) | The date/time the flight was last updated |
| `CustomFieldsJson`<br>(string) | An object of custom fields available for the flight and their values |
| `StartDate`<br>(string) | The start date for the flight. YYYY-MM-DD HH:MM:SS |
| `PriorityId`<br>(integer) | The Priority's ID |
| `IsDeleted`<br>(boolean) | If the flight is set as deleted |
| `Id`<br>(integer) | The Flight's ID |
| `IsNoDuplicates`<br>(boolean) | If the flight is set to not serve more than once per ad request |
| `IsArchived`<br>(boolean) | If the flight is archived |
| `RateType`<br>(integer) | Enum value for the Rate of the flight |
| `FreqCap`<br>(integer) | The value of the frequency cap |
| `IsCompanion`<br>(boolean) | If the all the ads in the flight must be served together |
| `CanPassback`<br>(boolean) | If the flight can pass back to the next flight in an adChain |
| `CapType`<br>(integer) | Enum value for the Cap of the flight |
| `Price`<br>(integer) | The Flight's price |
| `IsActive`<br>(boolean) | If the flight is Active and available to serve |
| `FreqCapType`<br>(integer) | The unit of time for frequency capping |
| `CustomTargeting`<br>(string) | A JSON custom targeting query |
| `IsTrackingConversions`<br>(boolean) | If the flight is set to track conversions |
| `FreqCapDuration`<br>(integer) | How often a frequency cap should occur |
| `PassbackSortOrder`<br>(integer) | The order of the flight in its priority's adChain |
| `GoalType`<br>(integer) | Enum value for the Goal type of the flight |
| `DailyCapAmount`<br>(integer) | When a cap is set, the max events allowed per day |
| `Name`<br>(string) | The name of the flight |
| `LifetimeCapAmount`<br>(integer) | When a cap is set, the max events allowed per the lifetime of the flight |
| `AdvertiserId`<br>(integer) | The advertiser the flight belongs to |
| `Keywords`<br>(string) | The keyword targeting set on the flight |
| `EndDate`<br>(string) | The end date for the flight. YYYY-MM-DD HH:MM:SS |
| `AdIds`<br>(array) | The IDs of the ads associated with the flight |
| `Impressions`<br>(integer) | The Goal Amount of the flight |
| `CampaignId`<br>(integer) | The campaign the flight belongs to |

isActive

boolean

Defaults to false

Only return flights where `IsActive` is \[true/false\]. Default is `true`.

isArchived

boolean

Defaults to false

Only return flights where `IsArchived` is \[true/false\]. Default is `false`.

beforeStartDate

string

Only return flights where `StartDate` is before the provided date. Format: `YYYY-MM-DD HH:MM:SS`; `HH:MM:SS` optional

afterStartDate

string

Only return flights where `StartDate` is after the provided date. Format: `YYYY-MM-DD HH:MM:SS`; `HH:MM:SS` optional

beforeEndDate

string

Only return flights where `EndDate` is before the provided date. Format: `YYYY-MM-DD HH:MM:SS`; `HH:MM:SS` optional

afterEndDate

string

Only return flights where `EndDate` is after the provided date. Format: `YYYY-MM-DD HH:MM:SS`; `HH:MM:SS` optional

noEndDate

boolean

Only return flights where `EndDate` is null

name

string

Only return flights where `Name` is an exact match of the query.

nameContains

string

Only return flights where the given string is a substring of the `Name`. No wildcard characters are supported.

#

```

xxxxxxxxxx

curl -N "https://api.kevel.co/v1/fast/flight" -H "X-Adzerk-ApiKey:<API-KEY>"

# With multiple arguments

curl -N "https://api.kevel.co/v1/fast/flight?beforeStartDate=2014-01-01&noEndDate=true&isActive=false&nameContains=shoe" -H "X-Adzerk-ApiKey:<API-KEY>"
```

```

xxxxxxxxxx

{
  "LastModifiedDate": "2016-12-08T21:34:32Z",
  "CustomFieldsJson": {
    "Currency": "USD: US Dollars"
  },
  "StartDate": "2016-12-08T00:00:00Z",
  "PriorityId": 1234,
  "IsDeleted": false,
  "Id": 1234567,
  "IsNoDuplicates": false,
  "IsArchived": null,
  "RateType": 1,
  "FreqCap": 0,
  "IsCompanion": false,
  "CanPassback": false,
  "CapType": 1,
  "Price": 0,
  "IsActive": true,
  "FreqCapType": 0,
  "CustomTargeting": "",
  "IsTrackingConversions": false,
  "FreqCapDuration": 0,
  "PassbackSortOrder": null,
  "GoalType": 2,
  "DailyCapAmount": null,
  "Name": "There's a Flight",
  "LifetimeCapAmount": null,
  "AdvertiserId": 12345,
  "Keywords": "",
  "EndDate": null,
  "AdIds": [1234567],
  "Impressions": 100,
  "CampaignId": 123456
}
```
