Register
To use the Darkfibre API, you need an API key. Registration is free and takes about 30 seconds.
Register via Browser
Section titled “Register via Browser”- Go to darkfibre.dev/register
- Select Phantom and approve the connection
- Sign the verification message when prompted (this proves you own the wallet)
- Copy your API key
Add API Key to Your Project
Section titled “Add API Key to Your Project”Open your .env file and add your API key:
DARKFIBRE_API_KEY=api_your_actual_key_hereSOLANA_PRIVATE_KEY=your_private_key_hereReplace api_your_actual_key_here with the key you just received.
If you haven’t already, add your Solana private key (exported from Phantom in the Wallet & SOL step).
Verify Your Setup
Section titled “Verify Your Setup”Create a quick test to verify everything is configured correctly. Add this to src/index.ts:
import 'dotenv/config';
console.log('API Key loaded:', process.env.DARKFIBRE_API_KEY ? 'Yes' : 'No');console.log('Private Key loaded:', process.env.SOLANA_PRIVATE_KEY ? 'Yes' : 'No');Run it:
tsx index.tsYou should see:
API Key loaded: YesPrivate Key loaded: YesIf either shows “No”, check that your .env file is in the project root and has the correct variable names.
Next: Execute your first trade