# Option Lookup

Generate a properly formatted OCC option symbol based on the user's human-readable description of an option. This endpoint converts text such as "AAPL 12/17/27 $250 Call" to OCC option symbol format: AAPL271217C00250000. The user input must be URL-encoded.

## Endpoint
```
https://api.marketdata.app/v1/options/lookup/{userInput}/
```
### Method
```
GET
```
## Request Example

### HTTP

**GET** [https://api.marketdata.app/v1/options/lookup/AAPL%2012/17/2027%20250%20Call/](https://api.marketdata.app/v1/options/lookup/AAPL%2012/17/2027%20250%20Call/)

### JavaScript

```js title="app.js"
import { MarketDataClient } from "@marketdata/sdk";

const client = new MarketDataClient();

try {
  const data = await client.options.lookup("AAPL 12/17/2027 250 Call");
  console.log(data.optionSymbol);  // "AAPL271217C00250000"
} catch (error) {
  console.error(error);
}
```

### TypeScript

```typescript title="app.ts"
import { MarketDataClient } from "@marketdata/sdk";
import type { OptionsLookupResponse } from "@marketdata/sdk";

const client = new MarketDataClient();

try {
  const data: OptionsLookupResponse = await client.options.lookup("AAPL 12/17/2027 250 Call");
  console.log(data.optionSymbol);  // "AAPL271217C00250000"
} catch (error) {
  console.error(error);
}
```

### Python

```python title="app.py"
from marketdata import MarketDataClient

client = MarketDataClient()
lookup = client.options.lookup("AAPL 12/17/2027 250 Call")
print(lookup)
```

### Go

```go title="optionLookup.go"

import (
  "fmt"

  api "github.com/MarketDataApp/sdk-go"
)

func ExampleOptionLookupRequest() {
	optionSymbol, err := OptionLookup().UserInput("AAPL 12/17/2027 250 Call").Get()
	if err != nil {
		fmt.Print(err)
		return
	}

	fmt.Println(optionSymbol)
}
```

### PHP

```php title="optionLookup.php"
use MarketDataApp\Client;

$client = new Client();
$lookup = $client->options->lookup("AAPL 12/17/2027 250 Call");

// Display the OCC symbol
echo $lookup;
```

### Java

```java title="OptionLookup.java"
import com.marketdata.sdk.MarketDataClient;
import com.marketdata.sdk.options.OptionsLookupRequest;

try (MarketDataClient client = new MarketDataClient()) {
    System.out.println(client.options().lookup(OptionsLookupRequest.of("AAPL 12/17/2027 250 Call")).values());  // "AAPL271217C00250000"
}
```

### Kotlin

```kotlin title="OptionLookup.kt"
import com.marketdata.sdk.MarketDataClient
import com.marketdata.sdk.options.OptionsLookupRequest

MarketDataClient().use { client ->
    val optionSymbol =
        client.options().lookup(OptionsLookupRequest.of("AAPL 12/17/2027 250 Call")).values()
    println(optionSymbol)  // "AAPL271217C00250000"
}
```

### C#

```csharp title="OptionLookup.cs"
using MarketDataApp;

using var client = await MarketDataClient.CreateAsync();

var lookup = await client.Options.GetLookupAsync("AAPL 12/17/2027 250 Call");
Console.WriteLine(lookup.Values);  // "AAPL271217C00250000"
```

## Response Example

```json
{
  "s": "ok",
  "optionSymbol": "AAPL271217C00250000"
}
```

## Request Parameters

### Required

- **userInput** `string`

  The human-readable string input that contains (1) stock symbol (2) strike (3) expiration date (4) option side (i.e. put or call). This endpoint will translate the user's input into a valid OCC option symbol.

## Response Attributes

### Success

- **s** `string`

  Status will always be `ok` when the OCC option symbol is successfully generated.

- **optionSymbol** `string`

  The generated OCC option symbol based on the user's input.

### Error

- **s** `string`

  Status will be `error` if the request produces an error response.

- **errmsg** `string`
  An error message.

## Notes

- This endpoint will return an error if the option symbol that would be formed by the user's input does not exist.

## Usage Information

### Data Availability

This endpoint provides option symbol lookup functionality. This endpoint does not require any exchange entitlements and is available to all users.

| User Type | Exchange Entitlement | Data Type    |
|-----------|----------------------|--------------|
| All Users | Not Required         | Utility Data |

### Pricing

The cost of using the lookup API endpoint is 1 credit per API call.

| Data Type   | Cost Basis   | Credits Required per Unit |
|-------------|--------------|---------------------------|
| Lookup Data | Per API call | 1 credit                  |
