> For the complete documentation index, see [llms.txt](https://docs.transactionlink.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.transactionlink.io/docs/workflows/js-api/methods.md).

# Methods

Here are the methods available in our JavaScript API

#### Show

Make TransactionLinks widget reveal itself.

```javascript
window.transactionlink.open();
```

#### Hide

Hide TransactionLink widget.

```javascript
window.transactionlink.close();
```

#### SetOptions

Use this method to set options of widget.&#x20;

```javascript
window.transactionlink.setOptions({
  token: 'exampleToken'
});
```

#### Ready

Trigger a function when a widget is fully loaded.

```javascript
 window.transactionlink_ready = () => {
      transactionlink.setOptions({
          token: 'exampleToken'
      })
      window.transactionlink.open()
}
```

#### On

We expose the methods that allow reacting and listening to events emitted from the widget.

Listening for the event about opening widget

```javascript
transactionlink.on("widget-opened", () => {
    console.log("OPENED")
})
```

Listening for the event about closing widget

```javascript
transactionlink.on("widget-closed", () => {
    console.log("CLOSED")
})
```

Listening for the event about error

```javascript
transactionlink.on("error", () => {
    console.log("ERROR")
})
```

Listening for the event about workflow finished

```javascript
transactionlink.on("workflow-finished", (event) => {
    console.log(event)
})
```

#### UnmountWidget

Use this method to remove widget from DOM. Once unmounted, reload widget script and repeat initialisation of widget. \
(<https://docs.transactionlink.io/docs/js-api#how-to-implement-widget-communication>)

```
window.transactionlink.unmountWidget()
```


---

# 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 dynamically by asking a question.

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

```
GET https://docs.transactionlink.io/docs/workflows/js-api/methods.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
