# API

## Constructor

Creates a new AstralClient Instance to utilize the following functions.

**`new AstralClient(_ethAddress, _endpoint?);`**

| Name             | Type   | Attributes | Description                                                                                   |
| ---------------- | ------ | ---------- | --------------------------------------------------------------------------------------------- |
| **\_ethAddress** | string | REQUIRED   | The Ethereum Address of the user.                                                             |
| **\_endpoint**   | string | OPTIONAL   | The Graph Endpoint. Already has a default value that can be overloaded with another endpoint. |

## Methods

### **CreateGenesisGeoDID**

Creates a GenesisGeoDID Document. This creates a new root node for the linked data structure.

**`async createGenesisGeoDID(_typeOfGeoDID: string): Promise<IDocumentInfo>{}`**

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

| **Name**           | Type       | Attributes | Description                                                       |
| ------------------ | ---------- | ---------- | ----------------------------------------------------------------- |
| **\_typeOfGeoDID** | GeoDidType | REQUIRED   | The type of Genesis GeoDID you want to create. OfType GeoDidType. |
| {% endtab %}       |            |            |                                                                   |

{% tab title="Returns" %}

| Type              | Description                                                                          |
| ----------------- | ------------------------------------------------------------------------------------ |
| **IDocumentInfo** | Returns info regarding the Document Type, like the geodidid and the Document Itself. |

```
interface IDocumentInfo {
    geodidid: string;
    documentVal: any;
    parentid?: string;
}
```

{% endtab %}
{% endtabs %}

### **CreateChildGeoDID**

Creates a Child GeoDIDDocument. This creates a child node for an existing linked data structure.

**`async createChildGeoDID(_typeOfGeoDID: string, _parentID: string, _path: string): Promise<IDocumentInfo>{}`**

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

| Name               | Type       | Attributes | Description                                                       |
| ------------------ | ---------- | ---------- | ----------------------------------------------------------------- |
| **\_typeOfGeoDID** | GeoDidType | REQUIRED   | The type of Genesis GeoDID you want to create. OfType GeoDidType. |
| **\_parentID**     | string     | REQUIRED   | The Parent GeoDID ID of this new Child GeoDID                     |
| **\_path**         | string     | REQUIRED   | The path that will be appended to the Parent GeoDID ID            |
| {% endtab %}       |            |            |                                                                   |

{% tab title="Returns" %}

| Type             | Description                                                                                      |
| ---------------- | ------------------------------------------------------------------------------------------------ |
| **DocumentInfo** | Returns information regarding the Document, like the GeoDID ID and the contents of the Document. |

```
interface IDocumentInfo {
    geodidid: string;
    documentVal: any;
    parentid?: string;
}
```

{% endtab %}
{% endtabs %}

### **PinDocument**

Pins the Document to IPFS or FFS via Powergate.

**`async pinDocument(_documentInfo: IDocumentInfo, _token?: string): Promise<IPinInfo>{}`**

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

| Name               | Type          | Attributes | Description                                                                                                                                                                                     |
| ------------------ | ------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **\_documentInfo** | IDocumentInfo | REQUIRED   | The Info related to the Document that is required for pinning.                                                                                                                                  |
| **\_token**        | string        | OPTIONAL   | The Auth Token of the Powergate Instance that you want to pin the document on. If you don't have one yet, the client will automatically create a new one for you and return it for you to save. |
| {% endtab %}       |               |            |                                                                                                                                                                                                 |

{% tab title="Returns" %}

| Type         | Description                                                                                            |
| ------------ | ------------------------------------------------------------------------------------------------------ |
| **IPinInfo** | Returns information regarding the Pin, like the GeoDID ID, cid, Powergate Auth token, and the pinDate. |

```
interface IPinInfo {
    geodidid: string;
    cid: string;
    pinDate: Date;
    token: string
} 
```

{% endtab %}
{% endtabs %}

### **LoadDocument**

Loads the Document by the DocID and the Powergate Auth token associated with it.

**`async loadDocument(_docId: string, _token: string): Promise<ILoadInfo>{}`**

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

| Name         | Type   | Attribute | Description                                                               |
| ------------ | ------ | --------- | ------------------------------------------------------------------------- |
| **\_docId**  | string | REQUIRED  | The GeoDID id of the DID Document.                                        |
| **\_token**  | string | REQUIRED  | The Auth Token for the Powergate Instance that the Document in stored on. |
| {% endtab %} |        |           |                                                                           |

{% tab title="Returns" %}

| Type          | Description                                                                                                                      |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| **ILoadInfo** | Returns information regarding the Load, like the DocumentInfo as well as the Powergate Instance that the Document was pinned on. |

```
interface LoadInfo {
    documentInfo: IDocumentInfo;
    powergateInstance: Powergate 
}
```

{% endtab %}
{% endtabs %}


---

# 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://astral-protocol.gitbook.io/astral/archive/geodids/build-with-astral/quickstart/geodid-quick-start.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.
