# libtmux.neo.fetch_obj

- **Module:** libtmux.neo
- **Package:** libtmux
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/neo.py#L1275
- **Page:** https://libtmux.org/reference/py/libtmux-neo-fetch_obj/

```
libtmux.neo.fetch_obj(server: Server, obj_key: str, obj_id: str, list_cmd: ListCmd = "list-panes", list_extra_args: ListExtraArgs = None) -> OutputRaw
```

Fetch the single ``list-*`` row whose *obj_key* equals *obj_id*.

A listing enumerates :term:`winlinks <winlink>`, so a window linked into one
session at two indexes matches twice. :func:`_best_winlink` then picks the
row tmux itself would act on, rather than whichever sorted last.

## Parameters

- `server` (Server) — The tmux server to query.
- `obj_key` (str) — Identity field to match, e.g. ``"pane_id"``.
- `obj_id` (str) — Value the identity field must equal, e.g. ``"%3"``.
- `list_cmd` (ListCmd) — tmux list subcommand to run.
- `list_extra_args` (ListExtraArgs) — Extra arguments appended verbatim to the tmux command, e.g.
``("-t", "%3")`` to scope the listing to one object's parent.

## Returns

OutputRaw
    The matching row, as a dict of tmux format fields.

## Raises

- `TmuxObjectDoesNotExist` — When the object does not exist -- whether tmux said so on stderr
(``can't find pane: %99``, for a ``-t``-scoped listing) or the object
simply never appeared in the rows.
- `LibTmuxException` — For every other tmux failure, notably an unreachable server.

## Example

```python
>>> from libtmux.neo import fetch_obj
>>> fetch_obj(
...     server=pane.server,
...     obj_key="pane_id",
...     obj_id=pane.pane_id,
...     list_cmd="list-panes",
...     list_extra_args=("-t", pane.pane_id),
... )["pane_id"] == pane.pane_id
True
```

## Example

A pane that does not exist on a live server is a :exc:`~libtmux.exc.TmuxObjectDoesNotExist`, not a bare tmux error:

```python
>>> from libtmux import exc
>>> try:
...     fetch_obj(
...         server=pane.server,
...         obj_key="pane_id",
...         obj_id="%99999",
...         list_cmd="list-panes",
...         list_extra_args=("-t", "%99999"),
...     )
... except exc.TmuxObjectDoesNotExist as e:
...     print(e)
Could not find pane_id=%99999 for list-panes ('-t', '%99999')
```
