## Scrip master
The daily [scrip master](/api/v1/reference/scrip-master/) file of every
instrument, and lookups over it.

- **The file** is downloaded from `https://assets.sahi.com/external/instruments.csv`.
  To use another copy, pass `scrip_master_url=` when you build the client or set
  `SAHI_SCRIP_MASTER_URL`.
- **Columns.** `id` is the `instrument_id` for market data; `symbol` and
  `segment` are what orders take as `symbol` and `exchange_segment`.
- **Values are strings**, except `id`, `lot_size`, `freeze_quantity`, `token`
  and `price_precision`. See [Units in the file](#units-in-the-file).
- **Loaded once per process**, on first use, and refreshed after the daily
  rebuild around 06:00 IST. It takes over 100 MB in memory.

### api.get_instruments(...) — Every instrument

Every row of the file.

#### Signature

```python
api.get_instruments(*, refresh: bool = False, timeout: float | None = None) -> list[dict]
```

| Parameter | Type | Required | Notes |
|---|---|---|---|
| `refresh` | bool | no | Download again even if the copy is current. |
| `timeout` | float | no | Download timeout; default 30 seconds. |

#### Returns

A list of row dicts. Treat them as read-only.

#### Raises

- [`SahiConnectionException`](/sdk/python/errors/#sahiconnectionexception), [`SahiTimeoutException`](/sdk/python/errors/#sahitimeoutexception) or [`SahiAPIException`](/sdk/python/errors/#sahiapiexception): the download failed.

#### Units in the file

The file and the API use different units; the SDK converts neither.

| Column | In the file | In the API |
|---|---|---|
| `tick_size`, `strike_price` | Rupees, string: `"0.05"` | Paise, integer: `5` |
| `expiry_date` | `DD-MM-YYYY` | `YYYY-MM-DD` |

#### Find an index

Indices have no `symbol`; find one by `company_name`.

```python
nifty = [r for r in api.get_instruments() if r["company_name"] == "Nifty 50"][0]["id"]
```

#### Find an option contract

Filter on the underlying, type, strike and expiry, in the file's units. Or
start from the [option chain](/sdk/python/market-data/#apiget_option_chain--option-chain),
whose legs carry the `instrument_id`.

```python
option = [
    r for r in api.get_instruments()
    if r["underlying_symbol"] == "NIFTY" and r["option_type"] == "CE"
    and float(r["strike_price"]) == 22750 and r["expiry_date"] == "27-10-2026"
][0]
```

#### Example

```python
print(len(api.get_instruments()), "instruments")
```

### api.get_instrument_by_id(...) — Instrument by id

The row for an `instrument_id`, or `None`.

#### Signature

```python
api.get_instrument_by_id(instrument_id: int, *, timeout: float | None = None) -> dict | None
```

#### Raises

- As for `get_instruments`, on the first load only.

#### Example

```python
row = api.get_instrument_by_id(instrument_id)
print(row["symbol"], row["lot_size"])
```

### api.get_instruments_by_symbol(...) — Instruments by symbol

The rows with this `symbol`, as a list: a symbol can be in more than one
segment.

#### Signature

```python
api.get_instruments_by_symbol(symbol: str, exchange_segment: str | None = None, *, timeout: float | None = None) -> list[dict]
```

| Parameter | Type | Required | Notes |
|---|---|---|---|
| `symbol` | str | yes | The file's `symbol` column. |
| `exchange_segment` | str | no | Narrow to `NSE`, `NFO`, `BSE` or `BFO`. |
| `timeout` | float | no | Download timeout for the first load. |

#### Raises

- As for `get_instruments`, on the first load only.

#### Example

```python
reliance = api.get_instruments_by_symbol("RELIANCE", SahiAPI.EXCHANGE_SEGMENT_NSE)[0]
```

### api.get_instruments_by_isin(...) — Instruments by ISIN

The rows with this ISIN; a stock on both exchanges returns two.

#### Signature

```python
api.get_instruments_by_isin(isin: str, *, timeout: float | None = None) -> list[dict]
```

#### Raises

- As for `get_instruments`, on the first load only.

#### Example

```python
for row in api.get_instruments_by_isin("INE002A01018"):
    print(row["symbol"], row["segment"])
```

