> For the complete documentation index, see [llms.txt](https://acxyn.gitbook.io/acxyn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://acxyn.gitbook.io/acxyn/platform/connect-with-unity-sdk.md).

# Connect with Unity SDK

#### Setup:

Initialize the instance using **API key**.

```
    API api_instance = new API("3739a640-422a-40d4-884b-3ee387ea9727");
```

#### 1. Login:

**Request:**

```
        api_instance.LoginRequest(
                        "user@test.com", // user's email
			"StrongPassword*123", // user's password
                        (API.LoginResponse response)=>{ // Custom function to consume response
                            if (response.token == null){
                                print(response.error);
                            }else{
                                print("Login Successfull");
                            }
                        }
                    )
```

**Response Interface:**

```
LoginResponse{
           string token;
           string error;
}
```

#### 2. Fetch NFT List for a collection:

**Request:**

```
const int collection_id = 1; // collection id

api_instance.GetNft(collection_id, (API.GetNFTResponse response)=>{
                print(response.response_json[2].name);
                Debug.Log(response.response_json[0]);
            })
)
```

**Response Interface:**

```
GetNFTResponse{
		bool success;
		List<NFTResponseItem> response_json;
}
```

```
NFTResponseItem{
		string token_id;
		string name;
		string symbol;
		string cid;
		string image;
}
```

#### 3. Fetch NFT Details using Token Id:

**Request:**

```
const int token_id = 2; // token id
const int collection_id = 1; // collection id

api_instance.GetNftByTokenId(
		token_id,
		collection_id,
		(API.GetNftByTokenIdResponse response)=>{
                print(response.response_json.name);
		}
)
```

**Response Interface:**

```
GetNftByTokenIdResponse{
		bool success;
		GetNftByTokenIdResponseJson response_json;
		string error_code;
		string message;
}
```

```
GetNftByTokenIdResponseJson{
		public string cid;
		string name;
		string image;
		string decimals;
		GetNftByTokenIdMetadata metadata;
}
```

```
GetNftByTokenIdMetadata{
		string name;
		string description;
		string image;
}
```

#### 4. Mint NFT:

**Request:**

```
	string ClientCode = "acxyn-client-2023";
	string RefNo = "2048";
	string TransactionDateTime = "2nd Jan 2022";
	
	string name = "Kitty #2";
	string description = "Test Test Test!";
	int collection_id = 22;
	int game_id = 20;
	string minterAddress = "tz1XcayBzWmU5us9iz82Ax2v3cERZisKU8FZ";
	string imageBase64="data:image/png;base64,iV...II=";
        
	api_instance.MintNft(
		ClientCode,
		RefNo,
		TransactionDateTime,
		collection_id,
		game_id,
		minterAddress,
		imageBase64,
		name,
		description,
		(response)=>{
		    if(response.success){
			print("Minted token id : "+response.response_json.token_id);
		    }
		    else{
			print("Failed with error: "+response.message);
		    }
		}
	)
        
```

**Response Interface:**

```
MintNftResponse
	{
		bool success;
		MintNftResponseJson response_json;
		string message;
        }
```

```
MintNftResponseJson
	{
		int token_id;
		string cid;
		string image_url;
		string tx;
		string msg;
        }
```

#### 5. Transfer NFT:

**Request:**

```
	string from = "tz1XcayBzWmU5us9iz82Ax2v3cERZisKU8FZ";
        string to = "tz1XcayBzWmU5us9iz82Ax2v3cERZisKU8FZ";
        int token_id = 1;
        int collection_id = 22;
        
	api_instance.TransferToken(
                from,
                to,
                token_id,
                collection_id,
                (response)=>{
                    if (response.success){
                        print(response.response_json.msg);
                    }else{
                        print(response.message);
                    }
                }
	)
        
```

**Response Interface:**

```
TransferTokenResponse
	{
		bool success;
		TransferTokenResponseJson response_json;
		string error_code;
		string message;
        }
```

```
TransferTokenResponseJson
	{
		int token_id;
		string tx;
		string msg;
        }
```

#### 6. Burn NFT:

**Request:**

```
	string from = "tz1XcayBzWmU5us9iz82Ax2v3cERZisKU8FZ";
        int token_id = 2;
        int collection_id = 22;
        
	 api_instance.BurnToken(
                from,
                token_id,
                collection_id,
                (response)=>{
                    if (response.success){
                        print(response.response_json.msg);
                    }else{
                        print(response.message);
                    }
                    
                    Debug.Log(response.response_json);
                }
            )
        
```

**Response Interface:**

```
BurnTokenResponse
	{
		bool success;
		BurnTokenResponseJson response_json;
		string error_code;
		string message;
        }
```

```
BurnTokenResponseJson
	{
		int token_id;
		string tx;
		string msg;
        }
```
