> For the complete documentation index, see [llms.txt](https://developer.barchart.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.barchart.com/market-replay-docs/api-query-types/tick-queries.md).

# Tick queries

Use tick queries to retrieve raw trade and quote events for a symbol. Each query covers up to 24 hours of market activity. Submit one API request per commodity and maturity for each 24-hour period.

For tick data by day and exchange, request access to [Market Replay SFTP/S3 file services](https://www.barchart.com/solutions/contact).

The request handler is:

```
https://historical.aws.barchart.com/historical/queryticks.ashx
```

{% hint style="info" %}
Each tick query is limited to a single day. Query multiple days one day at a time.
{% endhint %}

{% hint style="warning" %}
Tick queries can return the previous 30 days by default. Barchart's Institutional Support can configure API access to return up to 365 days of tick history. For deeper historical time series, use Market Replay Enterprise SFTP/S3 bulk flat files.
{% endhint %}

## What a tick query returns

A tick query returns all tick records for a symbol within a requested time range.

You can control:

* the symbol
* the start and end time
* the sort order
* the maximum number of records
* the session or sale conditions included

If both `start` and `end` are present, the result includes ticks from `start` and excludes ticks at `end`.

## Time rules

* Equities use Eastern Time
* Everything else uses Central Time
* `start` is inclusive
* `end` is exclusive
* Input format is `yyyymmdd[hhmm[ss]]`

Examples:

```
20090203
200902030900
20090203090000
```

## Parameters

Required:

* `username`
* `password`
* `symbol`

Optional:

* `start`
* `end`
* `maxrecords`
* `order`
* `sessionfilter`
* `type`
* `sale4Condition=true`
* `participantID=true`
* `exchId=true`

### Parameter details

#### `symbol`

Set `symbol` to the instrument you want.

This endpoint supports the `*` notation for futures, such as `RS*1`.

When you use the `*` notation, a `SYMBOL` field containing the active contract is prepended to each returned record.

#### `maxrecords`

Use `maxrecords` to cap the result size.

If the requested range contains more rows than `maxrecords`, rows are trimmed based on `order`:

* `order=asc` trims from the chronological end
* `order=desc` trims from the chronological beginning

{% hint style="warning" %}
Tick timestamps are returned to the millisecond, but query times are only specified to the second. If multiple ticks occur in the same second, all ticks in that second are returned even if the result exceeds `maxrecords`.
{% endhint %}

#### `order`

Use one of these values:

* `asc`
* `desc`

If omitted, result order is not guaranteed.

#### `sessionfilter`

`sessionfilter` changes which session codes or sale conditions are included.

Default behavior:

* NYSE and AMEX use `@EFKX56V9`
* NASDAQ uses `@ABDEFKOSXY156`
* Other markets return all session codes except settle `*`

You can override the default in four ways:

* `EFK` — include only those codes
* `!EFK` — exclude those codes
* `%2BT` — include defaults plus the specified codes
* `-EF` — use defaults except the specified codes

{% hint style="info" %}
Escape `+` as `%2B` when your client does not do it automatically.
{% endhint %}

#### `type`

When enabled for your feed, use:

* `type=T` for trades
* `type=Q` for quotes
* `type=B` for both

## Default behaviors

### When both `start` and `end` are set

All ticks in the range are returned, as long as the range stays within one day.

### When only `end` is set

* with `maxrecords`, returns up to that many records back to the beginning of the end day
* without `maxrecords`, returns all records back to the beginning of the end day

### When only `start` is set

* with `maxrecords`, returns up to that many records through the end of the start day
* without `maxrecords`, returns all records through the end of the start day

### When neither is set

* `start` defaults to the beginning of the current day
* `end` defaults to the beginning of the next day

If `maxrecords` is also set, the query behaves as if both default values were explicitly provided.

## Response format

Default tick output is comma-delimited text, one record per line:

```
YYYY-MM-DD HH:MM:SS.FFF,TRADING_DAY,SESSION_CODE,PRICE,SIZE
```

Example:

```
2009-02-03 13:30:00.000,10,G,823.5,1
2009-02-03 13:30:00.125,10,G,823.75,7
```

The session code is the futures session code or equity sale condition.

### Trade output

Trade queries can include optional exchange, participant, and extended sale condition fields.

Format:

```
YYYY-MM-DD HH:MM:SS.FFF,TRADING_DAY,EXCHANGE_ID(optional),SESSION_CODE,SALE_4BYTE_CONDITION(optional),PRICE,SIZE,PARTICIPANT_ID(optional)
```

Example:

```
2020-12-01 11:56:33.122,1,Q,I,@  I,123.1432,3,D
2020-12-01 11:56:32.734,1,Q,I,@  I,123.145,4,D
```

### Quote output

Quote queries return best bid and best offer data.

Format:

```
YYYY-MM-DD HH:MM:SS.FFF,TRADING_DAY,EXCHANGE_ID(optional),QUOTE_CONDITION,BID_PRICE,BID_SIZE,BID_PARTICIPANT_ID(optional),OFFER_PRICE,OFFER_SIZE,OFFER_PARTICIPANT_ID(optional)
```

Example:

```
2020-12-01 12:53:55.791,1,Q,R,122.83,100,Q,122.84,1000,N
2020-12-01 12:53:55.730,1,Q,R,122.83,100,Q,122.84,900,N
```

## Examples

All Apple ticks between `9:00` and `12:00` on February 3, 2009:

```
https://historical.aws.barchart.com/historical/queryticks.ashx?username=username&password=password&symbol=AAPL&start=20090203090000&end=20090203120000
```

Last `1000` Apple ticks for the current day in descending order:

```
https://historical.aws.barchart.com/historical/queryticks.ashx?username=username&password=password&symbol=AAPL&maxrecords=1000&order=desc
```

First `1000` Apple ticks for February 3, 2009 in ascending order:

```
https://historical.aws.barchart.com/historical/queryticks.ashx?username=username&password=password&symbol=AAPL&start=20090203&maxrecords=1000&order=asc
```

Trade example:

```
https://historical.aws.barchart.com/historical/queryticks.ashx?username=username&password=password&type=T&symbol=AAPL&order=desc&sessionfilter=!!&maxrecords=10&sale4Condition=true&participantID=true&exchId=true
```

## Related

* [Minute queries](/market-replay-docs/api-query-types/minute-queries.md)
* [End-of-day queries](/market-replay-docs/api-query-types/end-of-day-queries.md)
* [Events and date range queries](/market-replay-docs/api-query-types/events-queries.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.barchart.com/market-replay-docs/api-query-types/tick-queries.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
