# Initialization

Here is the instructions on how to initialize the Wepin Widget Javascript SDK.

## init

It initializes the Wepin SDK. Defines the attributes needed for the widget during initialization.

```javascript
await wepinSdk.init(attributes?)
```

### **Parameters**

* `attributes` \<object> **optional** &#x20;
* `type` \<string>\
  It determines how to display the app widget window on the first load. The default value is `hide`. Currently, only `hide` is supported.\
  `hide` hides the widget window on the first load. The widget window can be displayed later using `openWindow()`.
* `defaultLanguage`: \<string>\
  It sets the default language of the widget. The default value is `ko`. Currently, supported languages are `en` , `ko` and `ja`.
* `defaultCurrency`**:** \<string>\
  It sets the default currency of the widget. The default value is `KRW`. Currently, supported currencies are `USD`,  `KRW` and  `JPY`
* `loginProviders`: \<string\[]> **optional**  \
  It's the list of login providers. Currently, supported providers are `google`, `apple`, `naver`, and `discord`. Define only the necessary login providers.
  * If this value is not specified, all provided providers can be used.
  * If an empty array is provided, only email login is available. (Supported from version v0.0.3)

### **Return value**

* `Promise`\<void>

### Example

<pre class="language-javascript"><code class="lang-javascript">await wepinSdk.init({
    type: 'hide',
    defaultLanguage: 'ko',
    defaultCurrency: 'KRW',
})

// google, apple login
<strong>await wepinSdk.init({
</strong>    type: 'hide',
    defaultLanguage: 'ko',
    defaultCurrency: 'KRW',
    loginProviders: ['google', 'apple']
})

// only email login
await wepinSdk.init({
    type: 'hide',
    defaultLanguage: 'ko',
    defaultCurrency: 'KRW',
    loginProviders: []
})
</code></pre>

## isInitialized

It checks if WepinSDK is initialized properly.

```javascript
wepinSdk.isInitialized()
```

### **Parameters**

* \<void>

### **Return Value**

* `<boolean>`\
  It returns <mark style="color:orange;">`true`</mark> if init was successful, otherwise returns <mark style="color:orange;">`false`</mark>.

### **Example**

```javascript
await wepinSdk.init({
    type: 'hide',
    defaultLanguage: 'ko',
    defaultCurrency: 'KRW',
})

if(wepinSdk.isInitialized()) {
  console.log('wepinSDK is initialized!')
}
```

## changeLanguage

It allows changing the language and currency of the widget.

```javascript
wepinSdk.changeLanguage({language, currency})
```

### **Parameters**

* `language` \<string>\
  It specifies the language to be displayed in the widget. Currently, supported languages are `en`, `ko` and `ja`.
* `currency` \<string>\
  It specifies the currency to be displayed in the widget. Currently, supported currencies are `USD` , `KRW` and `JPY`

### Example

```javascript
wepinSdk.changeLanguage({
   currency: 'KRW',
   language: 'ko'
})
```


---

# 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.wepin.io/en/widget-integration/web-javascript-sdk/widget/initialization.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.
