> For the complete documentation index, see [llms.txt](https://docs.ternoa.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ternoa.network/getting-started/javascript-sdk/ternoa-js-library/initialization.md).

# Initialization

> Prerequisites: [Install the ternoa-js library.](/getting-started/javascript-sdk/ternoa-js-library/installation.md)

To initialize the library, add the following code to your dApp:

```typescript
import { initializeApi } from "ternoa-js";

await initializeApi();
```

Once the Ternoa-JS library is initialized, you will be able to use all the powerful NFT FRAMEs designed by Ternoa to build your dApps.

{% hint style="info" %}
The default network used is **Alphanet**. To connect to the Mainnet network it is as simple as passing the desired WSS endpoint:
{% endhint %}

```typescript
import { initializeApi } from "ternoa-js";

// The endpoint here will make the init API on the Ternoa Mainnet network
await initializeApi("wss://mainnet.ternoa.io");
```

That's it! You're ready to build your dApp on Ternoa.

### Accessing the Ternoa API

Ternoa SDK provides **a powerful** function named `getRawApi()` to interact with the API. If the API is connected, it will be directly returned. You can use it all throughout your development experience to access passed data, subscribe to blockchain events, and access real-time blockchain info outside of extrinsics, constants, or queries.&#x20;

```js
  ...
   //we assume that API has been initiated before
   const api = await getRawApi()

   // Do something
   // example: To get the last block
   const signedBlock = await api.rpc.chain.getBlock();
  ...
}
```
