đī¸Use Python SDK
Getting Started with Lighthouse Python SDK - Store Files Permanently
Last updated
Getting Started with Lighthouse Python SDK - Store Files Permanently
Last updated
Welcome to the beginner's tutorial on using the Lighthouse Python SDK for perpetual and decentralized file storage. Lighthouse is a cutting-edge file storage protocol that revolutionizes the traditional rent-based cost model of cloud storage by enabling users to pay once for their files and store them forever. With the integration of IPFS, Filecoin, and smart contracts on various blockchain networks, Lighthouse ensures data permanence, enhanced security, and cost-efficiency. This tutorial will guide you through the essential steps of leveraging the Lighthouse Python SDK to manage files perpetually on the decentralized network.
Traditional file storage models require users to periodically renew their storage subscription, leading to recurring costs and management efforts. Lighthouse Python SDK eliminates these hassles by offering a perpetual storage model, where users pay once and store files indefinitely. This innovative approach utilizes the robustness of IPFS and the storage capacity of Filecoin's miner network, guaranteeing file permanence and redundancy. Let's dive into the Lighthouse Python SDK to harness the power of perpetual decentralized file storage.
Before starting with the Lighthouse Python SDK, ensure you have the following:
Basic knowledge of Python programming.
Python installed on your computer.
A Lighthouse API token. If you haven't obtained one yet, sign up on the Lighthouse website to get your API token.
Note: If you already have Lighthouse API key, skip Step 0 and go to Step 1: Install the Lighthouse Python SDK
Go on https://files.lighthouse.storage/ and Click on Login
Select any of the login method and perform verification steps
Click on API Key on the left side panel on the dashboard.
Insert name for your API
Copy the API Key
Begin by installing the Lighthouse Python SDK via pip, allowing you to interact with the Lighthouse protocol seamlessly:
After installing the SDK, import the required libraries and initialize the Lighthouse client with your API token:
Next, let's upload a file to Lighthouse. We can use the upload
function for this purpose. We'll demonstrate both regular file upload and file upload with tags:
After uploading a file, you might want to retrieve its information, such as the Content Identifier (CID). We can use the getUploads
function for this purpose:
Now, let's download a file from Lighthouse using its CID. We'll use the download
function to achieve this:
Lighthouse allows you to check the status of a file's deal on the network. This can be useful to ensure that the file is accessible and replicated. Use the getDealStatus
function to check the deal status:
If you've tagged your files during the upload, you can easily retrieve them by tag using the getTagged
function:
Congratulations! You have successfully learned how to interact with the Lighthouse API for file upload, download, tagging, and checking deal status. You can now integrate Lighthouse into your own applications to manage files securely and efficiently. Keep exploring the Lighthouse documentation to discover more features and functionalities offered by the platform.
Remember to handle exceptions appropriately in your applications, and make sure to secure your API token to protect your data on the Lighthouse platform. Happy coding!