> For the complete documentation index, see [llms.txt](https://api.pyblish.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.pyblish.com/pyblish.api/abstractentity/abstractentity.data.md).

# .data

Available to [Instance](/pyblish.api/instance.md) and [Context](/pyblish.api/context.md) objects and used to pass data between library and plug-ins.

## Introduction

Data is primarily gathered during [Collection](https://github.com/pyblish/api/tree/9d41e509649f2dfb91bc4d595aebabed2dc0512f/pages/Collector.md) and used during subsequent plug-ins, such as [Validation](https://github.com/pyblish/api/tree/9d41e509649f2dfb91bc4d595aebabed2dc0512f/pages/Validator.md) and [Extraction](https://github.com/pyblish/api/tree/9d41e509649f2dfb91bc4d595aebabed2dc0512f/pages/Extractor.md). Data can also be used as a means of messaging across plug-ins.

* See [Tale of Three APIs](https://github.com/pyblish/pyblish/wiki/Tale-of-Three-APIs) for more information.

## Naming Convention

Data members are using mixedCase.

**Wrong**

```bash
instance.data["snake_case_is_for_python"] = True
instance.data["CamelCaseIsForClasses"] = False
```

**Right**

```bash
instance.data["myVariable"] = True
instance.data["longName"] = 42
instance.data["veryLongVariable"] = 5
```

The motivation is to separate between what is Python and what is Pyblish data.

## Examples

```python
import pyblish.api as pyblish
context = pyblish.Context()
context.data["myData"] = "myValue"

instance = pyblish.Instance(name="MyInstance", parent=context)
instance.data["range"] = [0, 120]
instance.data["active"] = False
```

Data of any type may be added, including complex objects.

```python
# Custom objects

import pyblish.api

class MyCustomChild(object):
   def __init__(self, name):
      self.name = name

instance = pyblish.api.Instance(name="Car")
instance.append(MyCustomChild("wheels"))
instance.append(MyCustomChild("engine"))

MyCustomType = type("MyCustomType", (object,), {})

owner = MyCustomType()
owner.value = "John Doe"
make = MyCustomType()
make.value = "Ford"

instance.data["owner"] = owner
instance.data["make"] = make
instance.data["miles"] = "123"
```

{{ file.mtime }}
