# Service Provider

In the WireBootstrap framework,  a Data Connector uses a JavaScript  class called a [service provider](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/data-connectors) to make calls to a data service.  The service provider is used with a [DataSource](https://docs.wirebootstrap.com/wirebootstrap/reference/wire.data/wire.data.datasource) to be able to make calls to a specific type of data service.

The *WireBootstrap Table Service Provider* is used with a data source to make calls to the WireBootstrap Query Service for executing queries against relational databases.

## Provider Key

Use the `sql`provider key to use this service provider with a data source. &#x20;

```javascript
const service = new wire.data.DataSource("sql", {
    ...    
});
```

{% hint style="info" %}
Note, early versions of the service provider used `table` as the servicer provider key.
{% endhint %}

## Configuration

| Name         | Description                                                                                                                                                                                        |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ConnectionId | The Connection Id for a data connection to a database.  See [Data Connections](/query-service/administration/data-connections.md) for details.                                                     |
| ServiceId    | The Service Id of the target query service instance.  See [Service Configuration - Credentials](/query-service/administration/service-configuration.md#credentials) for details.                   |
| ServiceKey   | The Secret Key or password required to make calls to the query service. [See Service Configuration - Credentials](/query-service/administration/service-configuration.md#credentials) for details. |

The following creates a data source using the table service provider.  The table service configuration options are specified in the `Provider` property.

```javascript
const Northwind = new wire.data.DataSource("sql", {
    ServiceRoot: "http://localhost:1895",
    Provider: {
        ServiceId: "qs_ebi-appdev2",
        SecretKey: "WireBootstrap$",
        ConnectionId: "northwind_ebi-appdev2"
    }
});
```

### Authentication

The service provider prepares the call to the query service based on the query and the configuration options passed in as part of the call. &#x20;

Calls to the query service use a `Basic` authentication scheme.  An `Authorization` header is set using a hash of the `ServiceId` and `SecretKey` provider properties.  These are used to validate each request by the query service.

```javascript
Authorization: Basic cXNfZWJpLWFwcGRldjI6V2lyZUJvb3RzdHJhcCQ=
```

### Content-Type

The `Content-Type` header is set to `text/plain` when making calls to the query service.

```javascript
Content-Type: text/html
```

### Connection

The `ConnectionId` is passed to the query service as a query parameter in the URL.

```javascript
POST: http://localhost:1895/table/exec?connection=northwind_ebi-appdev2
```

## Allow

Service providers are able to tell consumers about the functionality they support through an [`allow`](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/data-connectors#allow)  property.  Below is a list of the functionality that the table service provider supports.

| Name               | Supports |
| ------------------ | -------- |
| delete             | true     |
| discover           | true     |
| storedProcedure    | true     |
| tableQuery         | true     |
| tableQuery.orderBy | true     |
| tableQuery.groupBy | true     |
| test               | true     |
| write              | true     |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wirebootstrap.com/query-service/service-provider.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
