# Python

{% hint style="danger" %}
shdwDrive v1.5 is no longer maintained. Please migrate to v2 and consult the new [developer guide](https://docs.shdwdrive.com/guide/start-building) for instructions.
{% endhint %}

* [**Install Python SDK**](#installing-shadow-drive)
* [**Examples**](#example-end-to-end-script)
* [**Github**](#about-the-github-repo)
* [**Methods**](#methods)

## **Installing ShdwDrive**

`pip install shadow-drive`

Also for running the examples:

`pip install solders`

Check out the [`examples`](https://github.com/GenesysGo/shadow-drive-rust/tree/main/py) directory for a demonstration of the functionality.

<https://shdw-drive.genesysgo.net/\\[STORAGE\\_ACCOUNT\\_ADDRESS>]

### **Example -** Create Account, File Upload, Add or Reduce Storage, and Delete Account using Python

```python
from shadow_drive import ShadowDriveClient
from solders.keypair import Keypair
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--keypair', metavar='keypair', type=str, required=True,
                    help='The keypair file to use (e.g. keypair.json, dev.json)')
args = parser.parse_args()

# Initialize client
client = ShadowDriveClient(args.keypair)
print("Initialized client")

# Create account
size = 2 ** 20
account, tx = client.create_account("full_test", size, use_account=True)
print(f"Created storage account {account}")

# Upload files
files = ["./files/alpha.txt", "./files/not_alpha.txt"]
urls = client.upload_files(files)
print("Uploaded files")

# Add and Reduce Storage
client.add_storage(2**20)
client.reduce_storage(2**20)

# Get file
current_files = client.list_files()
file = client.get_file(current_files[0])
print(f"got file {file}")

# Delete files
client.delete_files(urls)
print("Deleted files")

# Delete account
client.delete_account(account)
print("Closed account")
```

#### **About the** [**Github Repo**](https://github.com/GenesysGo/shadow-drive-rust/tree/main/py)

This package uses PyO3 to build a wrapper around the official ShdwDrive Rust SDK. For more information, see the [Rust SDK documentation](https://github.com/GenesysGo/shadow-drive-rust/tree/main/sdk).

#### **Methods**

Section under development.


---

# 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.shdwdrive.com/build/the-sdk/sdk-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.
