---
title: Expirations
sidebar_position: 1
---





Get a list of current or historical option expiration dates for an underlying symbol.

## Making Requests

Utilize [OptionsExpirationsRequest](<#OptionsExpirationsRequest>) for querying the endpoint through one of the three available methods:

| Method     | Execution       | Return Type                   | Description                                                                                                                      |
|------------|-----------------|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| **Get**    | Direct          | `[]time.Time`                 | Immediately fetches and returns a slice of `[]time.Time`, allowing direct access to each expiration date.                        |
| **Packed** | Intermediate    | `*OptionsExpirationsResponse` | Delivers a `*OptionsExpirationsResponse` object containing the data, which requires unpacking to access the `[]time.Time` slice. |
| **Raw**    | Low-level       | `*resty.Response`             | Offers the unprocessed `*resty.Response` for those seeking full control and access to the raw JSON or `*http.Response`.          |


<a name="OptionsExpirationsRequest"></a>
## OptionsExpirationsRequest

```go
type OptionsExpirationsRequest struct {
    // contains filtered or unexported fields
}
```

OptionsExpirationsRequest represents a request for retrieving options expirations data from the [/v1/options/expirations/](<https://www.marketdata.app/docs/api/options/expirations>) endpoint. It encapsulates parameters for the underlying symbol and strike price to be used in the request. This struct provides methods such as UnderlyingSymbol\(\) and Strike\(\) to set these parameters respectively.

#### Generated By

- <a href="#OptionsExpirations">`OptionsExpirations() *OptionsExpirationsRequest`</a>

  OptionsExpirations creates a new \*OptionsExpirationsRequest and returns a pointer to the request allowing for method chaining.


#### Setter Methods

- <a href="#OptionsExpirationsRequest.Strike">`Strike(float64) *OptionsExpirationsRequest`</a>

  Sets the strike price parameter for the options expirations request.

- <a href="#OptionsExpirationsRequest.UnderlyingSymbol">`UnderlyingSymbol(string) *OptionsExpirationsRequest`</a>

  Sets the underlying symbol parameter for the options expirations request.


#### Execution Methods

These methods are used to send the request in different formats or retrieve the data. They handle the actual communication with the API endpoint.

- <a href="#OptionsExpirationsRequest.Get">`Get() ([]time.Time, error)`</a>

  Sends the request, unpacks the response, and returns \[\]time.Time allowing direct\-access to the data.

- <a href="#OptionsExpirationsRequest.Packed">`Packed() (*OptionsExpirationsResponse, error)`</a>

  Returns a struct that contains equal\-length slices of primitives. This packed response mirrors Market Data's JSON response.

- <a href="#OptionsExpirationsRequest.Raw">`Raw() (*resty.Response, error)`</a>

  Sends the request as is and returns the raw HTTP response.




<a name="OptionsExpirations"></a>
### OptionsExpirations

```go
func OptionsExpirations() *OptionsExpirationsRequest
```

OptionsExpirations creates a new OptionsExpirationsRequest with the default client.

#### Returns

- `*OptionsExpirationsRequest`

  A pointer to the newly created OptionsExpirationsRequest with default parameters.

## OptionsExpirationsRequest Setter Methods

<a name="OptionsExpirationsRequest.Date"></a>
### Date

```go
func (oer *OptionsExpirationsRequest) Date(q interface{}) *OptionsExpirationsRequest
```

Date sets the date parameter for the OptionsExpirationsRequest. This method is used to specify the date for which the options expirations are requested. It modifies the dateParams field of the OptionsExpirationsRequest instance to store the date value.

#### Parameters

- `interface{}`

  An interface\{\} that represents the starting date. It can be a string, a time.Time object, a Unix timestamp or any other type that the underlying dates package can process.


#### Returns

- `*OptionsExpirationsRequest`

  This method returns a pointer to the OptionsExpirationsRequest instance it was called on. This allows for method chaining. If the receiver \(\*OptionsExpirationsRequest\) is nil, it returns nil to prevent a panic.


<a name="OptionsExpirationsRequest.Strike"></a>
### Strike

```go
func (o *OptionsExpirationsRequest) Strike(strike float64) *OptionsExpirationsRequest
```

Strike sets the strike price parameter for the OptionsExpirationsRequest. This method is used to specify a particular strike price for filtering the options expirations.

#### Parameters

- `float64`

  A float64 representing the strike price to be set.


#### Returns

- `*OptionsExpirationsRequest`

  This method returns a pointer to the OptionsExpirationsRequest instance it was called on, allowing for method chaining.


<a name="OptionsExpirationsRequest.UnderlyingSymbol"></a>
### UnderlyingSymbol

```go
func (o *OptionsExpirationsRequest) UnderlyingSymbol(symbol string) *OptionsExpirationsRequest
```

UnderlyingSymbol sets the underlying symbol parameter for the OptionsExpirationsRequest. This method is used to specify the symbol of the underlying asset for which the options expirations are requested.

#### Parameters

- `string`

  A string representing the underlying symbol to be set.


#### Returns

- `*OptionsExpirationsRequest`

  This method returns a pointer to the OptionsExpirationsRequest instance it was called on, allowing for method chaining.



## OptionsExpirationsRequest Execution Methods
<a name="OptionsExpirationsRequest.Get"></a>
### Get

```go
func (o *OptionsExpirationsRequest) Get() ([]time.Time, error)
```

Get sends the OptionsExpirationsRequest, unpacks the OptionsExpirationsResponse, and returns a slice of time.Time. It returns an error if the request or unpacking fails. This method uses the default client for the request.

#### Returns

- `[]time.Time`

  A slice of time.Time containing the unpacked options expirations data from the response.

- `error`

  An error object that indicates a failure in sending the request or unpacking the response.



<a name="OptionsExpirationsRequest.Packed"></a>
### Packed

```go
func (o *OptionsExpirationsRequest) Packed() (*models.OptionsExpirationsResponse, error)
```

Packed sends the OptionsExpirationsRequest and returns the OptionsExpirationsResponse. This method uses the default client for the request.

#### Returns

- `*models.OptionsExpirationsResponse`

  A pointer to the OptionsExpirationsResponse obtained from the request.

- `error`

  An error object that indicates a failure in sending the request.


<a name="OptionsExpirationsRequest.Raw"></a>
### Raw

```go
func (oer *OptionsExpirationsRequest) Raw() (*resty.Response, error)
```

Raw executes the OptionsExpirationsRequest and returns the raw \*resty.Response. This method uses the default client for the request. The \*resty.Response can be used to directly access the raw JSON or \*http.Response.

#### Returns

- `*resty.Response`

  The raw HTTP response from the executed OptionsExpirationsRequest.

- `error`

  An error object if the OptionsExpirationsRequest is nil or if an error occurs during the request execution.



<a name="OptionsExpirationsResponse"></a>
## OptionsExpirationsResponse

```go
type OptionsExpirationsResponse struct {
    Expirations []string // Expirations is a slice of strings representing the expiration dates of options.
    Updated     int64    // Updated is a UNIX timestamp indicating when the data was last updated.
}
```

OptionsExpirationsResponse encapsulates the expiration dates of options and the last update timestamp.

#### Generated By

- <a href="#OptionsExpirationsRequest.Packed">`OptionsExpirationsRequest.Packed()`</a>

  Generates an OptionsExpirationsResponse after fetching data from Market Data.


#### Methods

- <a href="#OptionsExpirationsResponse.IsValid">`IsValid() bool`</a>

  Checks if the expiration dates are valid and correctly formatted.

- <a href="#OptionsExpirationsResponse.String">`String() string`</a>

  Returns a string representation of the OptionsExpirationsResponse.

- <a href="#OptionsExpirationsResponse.Unpack">`Unpack() ([]time.Time, error)`</a>

  Converts expiration date strings to a slice of time.Time objects.


#### Notes

- The Expirations field contains dates in string format which should be parsed considering the "America/New\_York" timezone.



<a name="OptionsExpirationsResponse.IsValid"></a>
### IsValid

```go
func (oer *OptionsExpirationsResponse) IsValid() bool
```

IsValid checks the validity of the OptionsExpirationsResponse. This method is primarily used to ensure that the Expirations slice is not empty and that each expiration date string within it can be successfully parsed into a time.Time object according to the "America/New\_York" timezone. This validation is crucial for preventing errors in subsequent operations that rely on the integrity of the expiration dates data.

#### Returns

- `bool`

  Indicates whether the OptionsExpirationsResponse is valid. A return value of true means all expiration dates are correctly formatted and the Expirations slice is not empty.


#### Notes

- The parsing of expiration date strings is sensitive to the timezone specified. Incorrect timezone handling may lead to validation errors.

<a name="OptionsExpirationsResponse.String"></a>
### String

```go
func (oer *OptionsExpirationsResponse) String() string
```

String returns a string representation of the OptionsExpirationsResponse. This method is primarily used for logging or debugging purposes, where a human\-readable format of the OptionsExpirationsResponse is required. It formats the expirations and the updated timestamp into a readable string.

#### Returns

- `string`

  A string that represents the OptionsExpirationsResponse object.


<a name="OptionsExpirationsResponse.Unpack"></a>
### Unpack

```go
func (oer *OptionsExpirationsResponse) Unpack() ([]time.Time, error)
```

Unpack converts the expiration date strings in the OptionsExpirationsResponse to a slice of time.Time objects, adjusting each to 4:00 PM Eastern Time, the typical expiration time for options contracts. This method is essential for users who need to work with the actual expiration times of options rather than just the dates.

#### Returns

- `[]time.Time`

  A slice of time.Time objects representing the expiration dates and times.

- `error`

  An error if any date string cannot be parsed or if the "America/New\_York" timezone cannot be loaded.


#### Notes

- This method assumes that all expiration times are at 4:00 PM Eastern Time, which may not be accurate for all options contracts.









