Doot client to handle o1js compatible data feeds For The Mina Protocol.
npm install @dootfoundation/clientGet real-time cryptocurrency prices with zero-knowledge proofs on the Mina blockchain.
Doot provides verified price data for 10 major cryptocurrencies using zero-knowledge proofs. Your app gets fast, reliable prices with automatic fallback across multiple sources.
``bash`
npm install @dootfoundation/client
`javascript
import { Client } from '@dootfoundation/client';
const client = new Client('your-api-key');
const price = await client.getData('bitcoin');
console.log(Bitcoin: $${price.price_data.price});`
When using in zkApp-CLI projects, you may need to add @ts-ignore for TypeScript compilation:
`typescript
import dotenv from 'dotenv';
dotenv.config();
// @ts-ignore
import { Client } from '@dootfoundation/client';
const client = new Client(process.env.DOOT_API_KEY);
const price = await client.getData('bitcoin');
`
This is only a TypeScript compilation issue - the package works perfectly at runtime in zkApp-CLI environments.
- bitcoin - Bitcoin (BTC)ethereum
- - Ethereum (ETH)mina
- - Mina Protocol (MINA)solana
- - Solana (SOL)chainlink
- - Chainlink (LINK)ripple
- - XRP (XRP)dogecoin
- - Dogecoin (DOGE)polygon
- - Polygon (MATIC)avalanche
- - Avalanche (AVAX)cardano
- - Cardano (ADA)
Doot uses a 3-layer fallback system:
1. API (fastest, ~100ms) - Direct from Doot servers
2. L2 (fast, ~10-30s) - Zeko Layer 2 blockchain
3. L1 (secure, ~30-60s) - Mina mainnet blockchain
If one source fails, it automatically tries the next one.
javascript
const price = await client.getData('ethereum');
`$3
Get price directly from API (requires valid key)
`javascript
const price = await client.getFromAPI('bitcoin');
`$3
Get price from Zeko L2 blockchain
`javascript
const price = await client.getFromL2('solana');
`$3
Get price from Mina L1 blockchain
`javascript
const price = await client.getFromL1('mina');
`$3
Check if your API key works
`javascript
const valid = await client.isKeyValid();
`$3
List of supported tokens
`javascript
import { validtokens } from '@dootfoundation/client';
console.log(validtokens); // ['bitcoin', 'ethereum', ...]
`Response Format
All methods return the same format:
`javascript
{
source: 'API', // Which source provided the data
fromAPI: true, // Boolean flags for source
fromL2: false,
fromL1: false,
price_data: {
token: 'bitcoin',
price: '65432.12', // Price as string
decimals: '10', // Decimal places
aggregationTimestamp: '1640995200000',
signature: 'ABC123...', // ZK proof signature
oracle: 'B62q...' // Oracle public key
},
proof_data: '{...}' // Zero-knowledge proof data
}
`Get an API Key
1. Visit doot.foundation/dashboard
2. Sign up for a free account
3. Generate your API key
4. Start building!
Examples
$3
`javascript
import { Client } from '@dootfoundation/client';const client = new Client('your-api-key');
// Get Bitcoin price with fallback
const btc = await client.getData('bitcoin');
console.log(
BTC: $${btc.price_data.price});// Get multiple prices
const tokens = ['bitcoin', 'ethereum', 'solana'];
for (const token of tokens) {
const price = await client.getData(token);
console.log(
${token}: $${price.price_data.price});
}
`$3
`javascript
import { Client } from '@dootfoundation/client';const client = new Client(process.env.DOOT_API_KEY);
async function checkPrices() {
try {
const eth = await client.getData('ethereum');
const btc = await client.getData('bitcoin');
const ethPrice = parseFloat(eth.price_data.price);
const btcPrice = parseFloat(btc.price_data.price);
console.log(
ETH/BTC ratio: ${(ethPrice / btcPrice).toFixed(4)});
} catch (error) {
console.error('Price fetch failed:', error.message);
}
}setInterval(checkPrices, 60000); // Check every minute
`$3
`bash
.env file
DOOT_API_KEY=your-api-key-here
``javascript
import dotenv from 'dotenv';
dotenv.config();const client = new Client(process.env.DOOT_API_KEY);
`Error Handling
`javascript
try {
const price = await client.getData('bitcoin');
console.log('Success:', price);
} catch (error) {
if (error.message.includes('Invalid token')) {
console.log('Token not supported');
} else if (error.message.includes('401')) {
console.log('Invalid API key');
} else {
console.log('Network or service error');
}
}
``- Node.js 18+
- Internet connection
- API key for fastest access (free at doot.foundation)
This package works in any Node.js environment. No special blockchain setup needed - just install and use!
- Documentation: docs.doot.foundation
- Issues: GitHub Issues
- Website: doot.foundation
ISC License - see LICENSE.md file for details.