# Entity JavaScript API

## Connector functions entity JS API guide

This API allows users to extract data from entity object.

### Entity Object Methods

> The following methods also work with the *gateway* object since it has the same structure as *entity*.

#### entity._value (datastream, index)

Extract from entity specified datastream “value” field value using parameters

**Returns**: <code>\*</code> - Specified datastream "value" field. It can be complex object. null if datastream does not exist.  

| Param      | Type   | Description                        |
| ---------- | ------ | ---------------------------------- |
| datastream | string | The datastream name.               |
| index      | any    | Element index of datastream array. |

Example of use:
```javascript
var value = entity._value('provision.device.identifier');
```

#### entity._at (datastream, index)

Extract from entity specified datastream “at” field value using parameters

**Returns**: Specified datastream "at" field. It can be complex object. null if datastream does not exist.  

| Param      | Type   | Description                        |
| ---------- | ------ | ---------------------------------- |
| datastream | string | The datastream name.               |
| index      | any    | Element index of datastream array. |

Example of use:
```javascript
var at = entity._at('provision.device.identifier');
```

#### entity._date (datastream, index)

Extract from entity specified datastream date field value using parameters

**Returns**: Specified datastream "date" field. It can be complex object. null if datastream does not exist.  

| Param      | Type   | Description                        |
| ---------- | ------ | ---------------------------------- |
| datastream | string | The datastream name.               |
| index      | any    | Element index of datastream array. |

Example of use:
```javascript
var date = entity._date('provision.device.identifier');
```

#### entity._source (datastream, index)

Extract from entity specified datastream “source” field value using parameters

**Returns**: Specified datastream "source" field. It can be complex object. null if datastream does not exist.  

| Param      | Type   | Description                        |
| ---------- | ------ | ---------------------------------- |
| datastream | string | The datastream name.               |
| index      | any    | Element index of datastream array. |

Example of use:
```javascript
var source = entity._source('provision.device.identifier');
```

#### entity._sourceInfo(datastream, index)

Extract from entity specified datastream “sourceInfo” field value using parameters

**Returns**: Specified datastream "sourceInfo" field. It can be complex object. null if datastream does not exist.    

| Param      | Type   | Description                        |
| ---------- | ------ | ---------------------------------- |
| datastream | string | The datastream name.               |
| index      | any    | Element index of datastream array. |

Example of use:
```javascript
var sourceInfo = entity._sourceInfo('provision.device.identifier');
```