Skip to main content

Quick Start

In this section, we will see how to:

  1. Create an API Key
  2. Upload a file
  3. View the file
  4. Get Filecoin deals
  5. What's Next?

This Quick Start guide walks you through the essentials: creating an API key, uploading a file, viewing it, and tracking its storage status. While the examples below use Node.js, you can easily adapt them for other environments using our How-To section.

1. Create an API Key​

  1. Login into Lighthouse files dapp (https://files.lighthouse.storage/)

  2. Go to the API key section and generate the API key as shown in image below

info

You can also generate the API key from CLI

API Key Generation

2. Upload a File​

  1. Install the lighthouse package in your Node application
npm i @lighthouse-web3/sdk
  1. Run the following script
import lighthouse from '@lighthouse-web3/sdk'

const apiKey = 'YOUR_API_KEY_HERE';
const uploadResponse = await lighthouse.upload(
'/home/cosmos/Desktop/wow.jpg',
apiKey
);

console.log(uploadResponse);

On success, you'll receive an object containing the file name, its CID ("Hash"), and sizeβ€”example shown below:

{
"data": {
"Name": "wow.jpg",
"Hash": "QmUHDKv3NNL1mrg4NTW4WwJqetzwZbGNitdjr2G6Z5Xe6s",
"Size": "31735"
}
}

3. View the File​

The file can be viewed from an IPFS gateway: https://gateway.lighthouse.storage/ipfs/QmWC9AkGa6vSbR4yizoJrFMfmZh4XjZXxvRDknk2LdJffc

4. Get Filecoin Deal​

info

Filecoin deals can take up to couple of hours to 1 day to appearβ€”this is expected. Use the dealStatus function as shown below to monitor progress. Once sealed, files are verifiably stored.

const status = await lighthouse.dealStatus('bafkreia4ruswe7ghckleh3lmpujo5asrnd7hrtu5r23zjk2robpcoend34')

The response will look like this:

{
"data": [
{ "DealID": 100046008, "Provider": 10479 },
{ "DealID": 100049432, "Provider": 97777 },
{ "DealID": 101757861, "Provider": 2942349 }
]
}

5. What's Next?​

Explore further with:

  • CLI tools
  • Python SDK examples
  • Encrypted uploads (Kavach)
  • Token gating & access control
  • Image resizing, IPNS, and more…