> For the complete documentation index, see [llms.txt](https://docs.abtasty.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.abtasty.com/server-side/integrations/open-feature/open-feature-js/open-feature-js-reference.md).

# Reference

{% hint style="info" %}
📘 Flagship SDK Reference

Please refer to the [JS SDK Documentation](https://docs.developers.flagship.io/docs/javascript-reference-beta#/) for Flagship classes
{% endhint %}

## ABTastyProvider class

The `ABTastyProvider` implements the OpenFeature Provider interface and is responsible for:

* Initializing the Flagship Client:\
  It starts the Flagship client using the provided environment ID, API key, and correct config.
* Creating a Visitor:\
  It instantiates a visitor with context details (e.g., targetingKey, user context), fetches the associated flags, and updates context (if needed).
* Logging Adaptation:\
  Uses an AdapterLogger to map Flagship logging to the OpenFeature Logger interface.
* Delegating Resolution:\
  Delegates flag resolution tasks to the ABTastyResolver, which performs the resolution based on visitor context.

### Key Methods

#### constructor(envId: string, apiKey: string, config?: IFlagshipConfig, logger?: OpenFeatureLogger)

* Description: Initializes the Flagship client. It:
  * Starts the Flagship client using the provided environment ID and API key.
* Arguments:

| Name   | Type   | Required     | Description                                                                |
| ------ | ------ | ------------ | -------------------------------------------------------------------------- |
| envId  | String | **Required** | Environment ID provided by Flagship.                                       |
| apiKey | String | **Required** | Api authentication key provided by Flagship.                               |
| config | Object | **Optional** | Custom flagship configuration. [see SDK configuration](#sdk-configuration) |
| logger | Object | **Optional** | AdapterLogger instance.                                                    |

Example:

```javascript
const {
    ABTastyProvider,
} = require("@flagship.io/openfeature-provider-js");

// Step 1: Start the OpenFeature SDK by providing the environment ID and API key
let provider = new ABTastyProvider("<ENV_ID>", "<API_KEY>");
```

#### initialize(context?: EvaluationContext)

* Description: Internally called by the OpenFeature class when the provider is set and initializes the visitor. It:
  * Creates a new visitor with the given evaluation context.
  * Fetches feature flags.
  * Instantiates the ABTastyResolver.
  * Emits the provider's Ready event.
* Arguments:
  * context: Optional context (e.g., targeting key and additional user data).
* Returns:
  * A promise that resolves when initialization completes.

Example:

```javascript
const {
    ABTastyProvider,
} = require("@flagship.io/openfeature-provider-js");
const { OpenFeature } = require("@openfeature/server-sdk");

// Step 1: Start the OpenFeature SDK by providing the environment ID and API key
let provider = new ABTastyProvider("<ENV_ID>", "<API_KEY>");

// Step 2: Set Flagship SDK as provider
await OpenFeature.setProviderAndWait(provider);
```

#### getConfig(): IFlagshipConfig

* Description: Retrieves the current configuration settings used by the Flagship client.
* Returns:
  * The configuration object (IFlagshipConfig).

#### close(): Promise\<void>

* Description: Gracefully shuts down the Flagship client connection.
* Returns:
  * A promise that resolves when the client has successfully closed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.abtasty.com/server-side/integrations/open-feature/open-feature-js/open-feature-js-reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
