# Python

The TransferChain Infrastructure SDK for Python enables you to write code to manage TransferChain Infrastructure resources.

## Getting Started

* To Start building the your product, please go ahead and check out <https://github.com/TransferChain/transferchain-python-sdk>
* For further information on documentation and technical specs, please visit <https://transferchain-python-sdk.readthedocs.io/>
* API token and Secret needs to be requested from TransferChain via <support@transferchain.io> or please contact your customer success manager to obtain them.

## Initialize TransferChain

````python
```python
# Import the TransferChain class from the SDK
from transferchain.client import TransferChain

# Initialize TransferChain
tc = TransferChain()
```
````

## Add Master User

````python
```python
# Import the TransferChain class from the SDK
from transferchain.client import TransferChain

# Initialize TransferChain
tc = TransferChain()

# When the SDK is initialized for the first time, creating a master user for that SDK is facilitated by using the 'add_master_user' operation.
# Example: Create a Master User
result_add_master_user = tc.add_master_user()
master_user = result_add_master_user.data
print(f"Master User created: {master_user.id}")
```
````

## Add User

````python
```python
# Import the TransferChain class from the SDK
from transferchain.client import TransferChain

# Initialize TransferChain
tc = TransferChain()

# Example: Add a User
result_add_user = tc.add_user()
added_user = result_add_user.data
print(f"User added: {added_user.id}")
```
````

## Get User

````python
```python
# Import the TransferChain class from the SDK
import os
from transferchain.client import TransferChain

# Initialize TransferChain
tc = TransferChain()

# Get TRANSFERCHAIN_USER_ID variable from env
user_id = os.environ.get('TRANSFERCHAIN_USER_ID')

# When any storage or transfer operation is desired, a user is required, and the 'get_user' method provides the necessary information related to the required user.
# Example: Get a User
user_id_to_get = user_id
user_info = tc.get_user(user_id_to_get)
print(f"User information: {user_info.id}")
```
````

## Restore Master User

````python
```python
# Import the TransferChain class from the SDK
from transferchain.client import TransferChain

# Initialize TransferChain
tc = TransferChain()

# It writes the addresses of the master and user in the blockchain to the SDK database using the mnemonics found in the environment, and returns all transactions found to the SDK user.
# Example: Restore a Master User
result_restore_master_user = tc.restore_master_user()
restored_master_user = result_restore_master_user.data
print(f"Master User restored: {restored_master_user}")
```
````


---

# 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.transferchain.io/client-sdks-and-network/python.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.
