# Quick Start

## Importing the packages

First you need to import the packages needed. There are 2 packages: dash and dashAuth. dashAuth. DashAuth is build upon [xboxlive-auth](https://www.npmjs.com/package/@xboxreplay/xboxlive-auth) and all credit for authenticating goes to them.

Since dash is built using javascript, this quick start will also use javascript.

{% tabs %}
{% tab title="Node" %}

```javascript
const { dash } = require('@pyrondev/dash');
const { comboAuthenticate} = require('@pyrondev/dash-auth');
```

{% endtab %}
{% endtabs %}

## Authenticating

Dash is authenticated using a email and password. You will need to authenticate dash before you can continue.

Make sure to have your microsoft account email and password combo on hand.

{% tabs %}
{% tab title="Node (async)" %}

```javascript
const { dash } = require('@pyrondev/dash');
const { comboAuthenticate } = require('@pyrondev/dash-auth');

(async () => {
	const DashAuth = await comboAuthenticate("EMAIL", "PASSWORD");
	var Dash = new dash(dashAuth);
})();
```

{% endtab %}

{% tab title="Node" %}

```javascript
```

{% endtab %}
{% endtabs %}

In this demo we have replaced the email and password of your microsoft account with their respective names, your real email and password should not be shared with anyone and should look along the lines of

```
something@something.something
```

```
whatever
```

### Using a microsoft code to authenticate

{% tabs %}
{% tab title="Node (async)" %}

```javascript
const { dash } = require('@pyrondev/dash');
const { msaCodeAuthenticate } = require('@pyrondev/dash-auth');

(async () => {
	const DashAuth = await msaCodeAuthenticate('', './profiles', {
		flow: "msal",
		relyingParty: 'https://pocket.realms.minecraft.net/'
	});
	var Dash = new dash(dashAuth);
})();
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}

`./profiles` is a folder for account cache. To see more about how this is used go [here](https://github.com/PrismarineJS/prismarine-auth)

## Realm

To use the realm methods you can initialise a realm class with a realm id or realm invite code.

{% tabs %}
{% tab title="Node (async)" %}

```javascript
const { dash } = require('@pyrondev/dash');
const { comboAuthenticate } = require('@pyrondev/dash-auth');

(async () => {
	const DashAuth = await comboAuthenticate("EMAIL", "PASSWORD");
	var Dash = new dash(dashAuth);
	var Realm = await Dash.realm(12345678);
})();
```

{% endtab %}

{% tab title="Node" %}

```javascript
// require the myapi module and set it up with your API key
const myapi = require('myapi')(YOUR_API_KEY);

const newPet = away myapi.pet.create({
    name: 'Wilson',
    owner_id: 'sha7891bikojbkreuy',
    species: 'Dog',
    breed: 'Golden Retriever',
})
```

{% endtab %}
{% endtabs %}

Or by using an invite code:

{% tabs %}
{% tab title="Node (async)" %}

```javascript
const { dash } = require('@pyrondev/dash');
const { comboAuthenticate } = require('@pyrondev/dash-auth');

(async () => {
	const DashAuth = await comboAuthenticate("EMAIL", "PASSWORD");
	var Dash = new dash(dashAuth);
	var Realm = await Dash.realmFromInvite("LTzLhdSCdE");
})();
```

{% endtab %}

{% tab title="Node" %}

```javascript
```

{% endtab %}
{% endtabs %}

Note that all of these examples are using fake realm information, you will need to use your own informaton.

## Client

To use the client methods you can initialise a client class, no paramaters are needed.

{% tabs %}
{% tab title="Node (async)" %}

```javascript
const { dash } = require('@pyrondev/dash');
const { comboAuthenticate } = require('@pyrondev/dash-auth');

(async () => {
	const DashAuth = await comboAuthenticate("EMAIL", "PASSWORD");
	var Dash = new dash(dashAuth);
	var Client = await Dash.client();
})();
```

{% endtab %}

{% tab title="Node" %}

{% endtab %}
{% endtabs %}

For all methods in either the realm or client class, refer to the documentation.
