+++
# -----------------------------------------------------------------------
# Do not edit this file. It is automatically generated by API Documenter.
# -----------------------------------------------------------------------
title = "DataSourceWithBackend"
keywords = ["grafana","documentation","sdk","@grafana/runtime"]
type = "docs"
+++

## DataSourceWithBackend class

Extend this class to implement a data source plugin that is depending on the Grafana backend API.

<b>Signature</b>

```typescript
export declare class DataSourceWithBackend<TQuery extends DataQuery = DataQuery, TOptions extends DataSourceJsonData = DataSourceJsonData> extends DataSourceApi<TQuery, TOptions> 
```
<b>Import</b>

```typescript
import { DataSourceWithBackend } from '@grafana/runtime';
```
<b>Constructors</b>

|  Constructor | Modifiers | Description |
|  --- | --- | --- |
|  [constructor(instanceSettings)](#constructor-instancesettings) |  | Constructs a new instance of the <code>DataSourceWithBackend</code> class |

<b>Methods</b>

|  Method | Modifiers | Description |
|  --- | --- | --- |
|  [applyTemplateVariables(query)](#applytemplatevariables-method) |  | Override to apply template variables |
|  [callHealthCheck()](#callhealthcheck-method) |  | Run the datasource healthcheck |
|  [getResource(path, params)](#getresource-method) |  | Make a GET request to the datasource resource path |
|  [postResource(path, body)](#postresource-method) |  | Send a POST request to the datasource resource path |
|  [query(request)](#query-method) |  | Ideally final -- any other implementation may not work as expected |
|  [testDatasource()](#testdatasource-method) |  | Checks the plugin health |

### constructor(instanceSettings)

Constructs a new instance of the `DataSourceWithBackend` class

<b>Signature</b>

```typescript
constructor(instanceSettings: DataSourceInstanceSettings<TOptions>);
```
<b>Parameters</b>

|  Parameter | Type | Description |
|  --- | --- | --- |
|  instanceSettings | <code>DataSourceInstanceSettings&lt;TOptions&gt;</code> |  |

### applyTemplateVariables method

Override to apply template variables

<b>Signature</b>

```typescript
/** @virtual */
applyTemplateVariables(query: DataQuery): DataQuery;
```
<b>Parameters</b>

|  Parameter | Type | Description |
|  --- | --- | --- |
|  query | <code>DataQuery</code> |  |

<b>Returns:</b>

`DataQuery`

### callHealthCheck method

Run the datasource healthcheck

<b>Signature</b>

```typescript
callHealthCheck(): Promise<HealthCheckResult>;
```
<b>Returns:</b>

`Promise<HealthCheckResult>`

### getResource method

Make a GET request to the datasource resource path

<b>Signature</b>

```typescript
getResource(path: string, params?: any): Promise<any>;
```
<b>Parameters</b>

|  Parameter | Type | Description |
|  --- | --- | --- |
|  path | <code>string</code> |  |
|  params | <code>any</code> |  |

<b>Returns:</b>

`Promise<any>`

### postResource method

Send a POST request to the datasource resource path

<b>Signature</b>

```typescript
postResource(path: string, body?: any): Promise<any>;
```
<b>Parameters</b>

|  Parameter | Type | Description |
|  --- | --- | --- |
|  path | <code>string</code> |  |
|  body | <code>any</code> |  |

<b>Returns:</b>

`Promise<any>`

### query method

Ideally final -- any other implementation may not work as expected

<b>Signature</b>

```typescript
query(request: DataQueryRequest): Observable<DataQueryResponse>;
```
<b>Parameters</b>

|  Parameter | Type | Description |
|  --- | --- | --- |
|  request | <code>DataQueryRequest</code> |  |

<b>Returns:</b>

`Observable<DataQueryResponse>`

### testDatasource method

Checks the plugin health

<b>Signature</b>

```typescript
testDatasource(): Promise<any>;
```
<b>Returns:</b>

`Promise<any>`

