---
title: Lookup
sidebar_position: 2
---
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
Lookup the official option symbol based on a user's text input.
## Making Requests
Utilize \[OptionsLookupRequest\] for querying the endpoint through one of the three available methods:
| Method | Execution | Return Type | Description |
|------------|-----------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------|
| **Get** | Direct | `string` | Immediately fetches and `string`, allowing direct access to the option symbol. |
| **Packed** | Intermediate | `*OptionLookupResponse` | Delivers a `*OptionLookupResponse` object containing the data, which requires unpacking to access the `string` data. |
| **Raw** | Low-level | `*resty.Response` | Offers the unprocessed `*resty.Response` for those seeking full control and access to the raw JSON or `*http.Response`. |
## OptionLookupRequest
```go
type OptionLookupRequest struct {
// contains filtered or unexported fields
}
```
OptionsLookupRequest represents a request to the [/v1/options/lookup/]() endpoint for retrieving an OCC\-formatted option symbol based on user input. It encapsulates parameters for user input to be used in the request.
#### Generated By
- `OptionsLookup() *OptionsLookupRequest`
OptionsLookup creates a new \*OptionsLookupRequest and returns a pointer to the request allowing for method chaining.
#### Setter Methods
- `UserInput(string) *OptionLookupRequest`
Sets the user input parameter for the 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.
- `Get() (string, error)`
Sends the request, unpacks the response, and returns the data in a user\-friendly format.
- `Packed() (*OptionLookupResponse, error)`
Returns a struct that contains equal\-length slices of primitives. This packed response mirrors Market Data's JSON response.
- `Raw() (*resty.Response, error)`
Sends the request as is and returns the raw HTTP response.
```go
resp, err := OptionLookup().UserInput("AAPL 7/28/2023 200 Call").Get()
if err != nil {
fmt.Print(err)
return
}
fmt.Println(resp)
```
#### Output
```
AAPL230728C00200000
```
```go
resp, err := OptionLookup().UserInput("AAPL 7/28/2023 200 Call").Packed()
if err != nil {
fmt.Print(err)
return
}
fmt.Println(resp)
```
#### Output
```
OptionLookupResponse{OptionSymbol: "AAPL230728C00200000"}
```
### OptionLookup
```go
func OptionLookup() *OptionLookupRequest
```
OptionLookup creates a new OptionsLookupRequest and uses the default client.
#### Returns
- `*OptionsLookupRequest`
A pointer to the newly created OptionsLookupRequest with default parameters and associated client.
## OptionLookupRequest Setter Methods
### UserInput
```go
func (o *OptionLookupRequest) UserInput(userInput string) *OptionLookupRequest
```
UserInput sets the user input parameter for the OptionsLookupRequest. This method is used to specify the user input for which the options data is requested.
#### Parameters
- `string`
A string representing the text to lookup with the OptionsLookupRequest endpoint.
#### Returns
- `*OptionsLookupRequest`
This method returns a pointer to the OptionsLookupRequest instance it was called on, allowing for method chaining.
## OptionLookupRequest Execution Methods
### Get
```go
func (o *OptionLookupRequest) Get() (string, error)
```
Get sends the OptionLookupRequest, unpacks the OptionsLookupResponse, and returns the unpacked data as a string. It returns an error if the request or unpacking fails.
#### Returns
- `string`
A string containing the unpacked options data from the response.
- `error`
An error object that indicates a failure in sending the request or unpacking the response.
### Packed
```go
func (o *OptionLookupRequest) Packed() (*models.OptionLookupResponse, error)
```
Packed sends the OptionLookupRequest and returns the OptionsLookupResponse.
#### Returns
- `*models.OptionsLookupResponse`
A pointer to the OptionsLookupResponse obtained from the request.
- `error`
An error object that indicates a failure in sending the request.
### Raw
```go
func (olr *OptionLookupRequest) Raw() (*resty.Response, error)
```
Raw executes the OptionLookupRequest and returns the raw \*resty.Response. The \*resty.Response allows access to the raw JSON or \*http.Response for further processing.
#### Returns
- `*resty.Response`
The raw HTTP response from the executed OptionLookupRequest.
- `error`
An error object if the request fails due to being nil, or other execution errors.
## OptionLookupResponse
```go
type OptionLookupResponse struct {
OptionSymbol string `json:"optionSymbol"` // OptionSymbol is the symbol of the option.
}
```
OptionLookupResponse encapsulates the response data for an option lookup request, primarily containing the option's symbol.
#### Generated By
- `OptionLookupRequest.Packed()`
Unmarshals the JSON response from OptionLookupRequest into OptionLookupResponse.
#### Methods
- `IsValid() bool`
Checks if the OptionLookupResponse is valid by verifying the OptionSymbol is not empty.
- `String() string`
Provides a string representation of the OptionLookupResponse, including the OptionSymbol.
- `Unpack() (string, error)`
Validates the OptionLookupResponse and returns the OptionSymbol if valid; otherwise, returns an error.
#### Notes
- This struct is primarily used for handling the response of an options lookup request in financial market data applications.
### IsValid
```go
func (olr *OptionLookupResponse) IsValid() bool
```
IsValid determines the validity of the OptionLookupResponse. It is primarily used to ensure that the response received from an option lookup request contains a non\-empty OptionSymbol, indicating a successful lookup and a valid option.
#### Returns
- `bool`
Indicates the validity of the OptionLookupResponse. Returns true if the OptionSymbol is not empty, otherwise false.
### String
```go
func (olr *OptionLookupResponse) String() string
```
#### Notes
- This method is primarily intended for debugging purposes or when there's a need to log the response details in a human\-readable format.
### Unpack
```go
func (olr *OptionLookupResponse) Unpack() (string, error)
```
Unpack checks the validity of the OptionLookupResponse and returns the OptionSymbol if the response is deemed valid. This method is primarily used when one needs to extract the OptionSymbol from a valid OptionLookupResponse, ensuring that the response is not empty or malformed before proceeding with further processing.
#### Returns
- `string`
The OptionSymbol contained within a valid OptionLookupResponse.
- `error`
An error indicating that the OptionLookupResponse is invalid, typically due to an empty OptionSymbol.
#### Notes
- This method is crucial for error handling and data validation in financial market data applications, ensuring that only valid responses are processed.