# Installation & Initialization

### Install the Ternoa-js  package

The Ternos-js npm library can be found [here](https://www.npmjs.com/package/ternoa-js).

> Prerequisites: [NodeJS v.14+](https://nodejs.org/en/download/) & NPM

Install the latest stable version of the ternoa-js library in your existing project by running:

{% code fullWidth="false" %}

```
npm install ternoa-js
```

{% endcode %}

> This package provides TypeScript types, but you will need TypeScript version 4.2 or higher to use them properly.

{% hint style="info" %}

You can test out our upcoming features in our *Alpha or Release candidate* versions. These versions aren't stable and might contain some technical errors. @alpha versions are for internal and testing only whereas @rc releases tend to be the closest to its production version.

You can check out our version list over [npm](https://www.npmjs.com/package/ternoa-js?activeTab=versions). Installing a specific version is as easy as replacing the @`1.6.0-rc0` with your desired version:
{% endhint %}

```
# for version 1.6.0-rc0
npm i ternoa-js@1.6.0-rc0
```

### API Initialization

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();
  ...
}
```


---

# 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.ternoa.network/build-1/javascript/ternoa-js-library-utilities/installation-and-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.
