### Install DeFi LLM Node.js SDK Source: https://docs.de.fi/api/api Instructions for installing the DeFi LLM SDK using npm for Node.js environments. ```bash npm i @de-fi/sdk ``` -------------------------------- ### Query Protocols (V1 & V2) Source: https://docs.de.fi/api/api Fetches information about supported protocols. Use `version: V2` for TOP EVM chains and `version: V1` for other platforms, including non-EVM chains. The V2 endpoint list is expanding. ```graphql query { protocols (version: V2) { name slug features { list } } } ``` ```graphql query { protocols (version: V1) { name slug features { list } } } ``` -------------------------------- ### Query Opportunity Farms Source: https://docs.de.fi/api/api Fetches all platforms and features supported by De.Fi's Explore Yield feature, providing insights into farming opportunities. ```graphql query { opportunityFarms { # fields to query } } ``` -------------------------------- ### DeFi LLM API Pricing and Rate Limits Source: https://docs.de.fi/api/api Details the credit cost and rate limits per minute for various endpoints of the DeFi LLM API. Essential for understanding usage costs and API access constraints. ```APIDOC DeFi LLM API Endpoints: Endpoint: assetBalances Credit Cost: 10 Rate Limit (per minute): 20 Endpoint: assets Credit Cost: 1 Rate Limit (per minute): 100 Endpoint: assetsPrices Credit Cost: 1 Rate Limit (per minute): 100 Endpoint: chains Credit Cost: 1 Rate Limit (per minute): 100 Endpoint: credits Credit Cost: 1 Rate Limit (per minute): 100 Endpoint: opportunities Credit Cost: 3 Rate Limit (per minute): 100 Endpoint: opportunityFarms Credit Cost: 1 Rate Limit (per minute): 100 Endpoint: protocolBalance Credit Cost: 10 Rate Limit (per minute): 20 Endpoint: protocols Credit Cost: 1 Rate Limit (per minute): 100 Endpoint: rekts Credit Cost: 3 Rate Limit (per minute): 100 Endpoint: shields Credit Cost: 10 Rate Limit (per minute): 20 Endpoint: shieldApprovals Credit Cost: 10 Rate Limit (per minute): 20 Endpoint: shieldApprovalsNft Credit Cost: 5 Rate Limit (per minute): 20 Endpoint: shieldAdvanced Credit Cost: 5 Rate Limit (per minute): 20 Endpoint: scannerLiquidityAnalysis Credit Cost: 10 Rate Limit (per minute): 20 Endpoint: scannerHolderAnalysis Credit Cost: 5 Rate Limit (per minute): 20 Endpoint: scannerProject Credit Cost: 25 Rate Limit (per minute): 20 ``` -------------------------------- ### Query De.Fi Supported Chains Source: https://docs.de.fi/api/api Fetches a list of all chains supported by the De.Fi API, including their IDs and names. This is a foundational call to understand available blockchain networks. ```graphql query { chains { id name } } ``` -------------------------------- ### Query Protocol Balances (V2) Source: https://docs.de.fi/api/api Retrieves user positions and balances for TOP De.Fi supported platforms. Requires chain IDs and wallet addresses. Returns potential errors and balance details per protocol. ```graphql query { protocolBalanceV2 ( chainIds: [1,2] walletAddresses:["...wallet #1...", "...wallet #2..."] ){ errors balances { protocol { slug } address total } } } ``` -------------------------------- ### General API Endpoints Source: https://docs.de.fi/api/api Access general information about the De.Fi API, including credit status, supported blockchains, and asset data. The base URL for all queries is https://public-api.de.fi/graphql. ```APIDOC General API Endpoints: Base URL: https://public-api.de.fi/graphql credits - Retrieves credit information associated with your API key. - Returns: Credit details. chains - Fetches information about supported blockchains. - Important: Provides `chain_id` values used in other calls. Note that internal `chain_id` values (e.g., 1 for Ethereum, 2 for BNB) differ from absolute values (e.g., 56 for BSC, 137 for Polygon). Please use values from this endpoint's response. - Returns: List of chains with their IDs and details. assets - Retrieves paginated data for supported assets. - Returns: Paginated list of assets. ``` -------------------------------- ### Portfolio and Wallet Balance Endpoints Source: https://docs.de.fi/api/api Query wallet balances, including ERC20 tokens and protocol-specific holdings, across multiple addresses and chains. These endpoints provide detailed insights into a user's DeFi portfolio. ```APIDOC Portfolio and Wallet Balance Endpoints: assetBalances - Retrieves ERC20 token balances for a given wallet address. - Parameters: - wallet_address: The address to query. - Returns: List of ERC20 token balances for the wallet. assetBalancesAdvanced (BETA) - Fetches ERC20 balances for multiple wallet addresses and chains in a single request. - Parameters: - wallet_addresses: Array of wallet addresses. - chain_ids: Array of chain IDs to query. - Returns: Detailed ERC20 balances across specified wallets and chains. protocols - Includes information about the many dapps integrated into the De.Fi dashboard. - Returns: List of supported protocols. protocolBalanceV2 (BETA) - Retrieves protocol balances for multiple wallet addresses and chains in a single request. - Parameters: - wallet_addresses: Array of wallet addresses. - chain_ids: Array of chain IDs to query. - Returns: Protocol-specific balances across specified wallets and chains. protocolBalance - Retrieves protocol balances for a given wallet address. - Parameters: - wallet_address: The address to query. - Returns: List of protocol balances for the wallet. ``` -------------------------------- ### Opportunities Endpoints Source: https://docs.de.fi/api/api Discover DeFi yield opportunities based on search criteria and retrieve lists of available yield farming opportunities. These endpoints help users find profitable DeFi strategies. ```APIDOC Opportunities Endpoints: opportunities - Retrieves information regarding DeFi yield opportunities based on preferred search terms. - Parameters: - search_terms: Keywords or criteria for finding opportunities. - Returns: List of relevant DeFi yield opportunities. opportunityFarms - Lists available DeFi yield farming opportunities. - Returns: Comprehensive list of yield farming opportunities. ``` -------------------------------- ### Query Opportunities Source: https://docs.de.fi/api/api Retrieves all available yield opportunities. Allows filtering by platform, feature, chain, and other criteria to find specific investment options. ```graphql query { opportunities { # fields to query } } ``` -------------------------------- ### Query Scanner Project Source: https://docs.de.fi/api/api Performs advanced security analysis for smart contract addresses. This endpoint is part of the Scanner Dashboard functionality. ```graphql query { scannerProject(smartContractAddresses: ["..."]) { # fields to query } } ``` -------------------------------- ### Query Protocol Balance (Specific) Source: https://docs.de.fi/api/api Retrieves user positions and balances for specific chain-wallet-protocol combinations, including non-EVM chains. Requires detailed balance parameters. ```graphql query { protocolBalance ( balances: { chainIds: [1] walletAddress: "...wallet..." protocolName: "Arrakis" } ){ protocol { slug } total chains { total } } } ``` -------------------------------- ### De.Fi API Authentication Source: https://docs.de.fi/api/api Details on how to authenticate API requests. Requires obtaining an API key and including it in the `X-Api-Key` header for all GraphQL queries. ```APIDOC API Authentication: To use the De.Fi API, you must first obtain a valid API key by sending a request to info@de.fi. All requests must include an `X-Api-Key` header with your obtained key. Example usage in a GraphQL playground: Request Header: { "X-Api-Key": "YOUR_API_KEY" } ``` -------------------------------- ### Query Asset Balances (EVM & Non-EVM) Source: https://docs.de.fi/api/api Retrieves asset balances for specified wallet addresses. Use `assetBalancesAdvanced` for EVM chains and `assetBalances` for non-EVM chains. Requires chain IDs and wallet addresses as input. ```graphql query { assetBalancesAdvanced( chainIds: [1, 2] walletAddresses: ["...wallet #1...", "...wallet #2..."]) { total wallet chains { chain { id } } } } ``` ```graphql query { assetBalances( chainIds: [1, 2] walletAddresses: ["...wallet #1...", "...wallet #2..."]) { total wallet chains { chain { id } } } } ``` -------------------------------- ### Query Scanner Holder Analysis Source: https://docs.de.fi/api/api Provides holder information for tokens associated with smart contracts. This is used within the Scanner Dashboard for deeper analysis. ```graphql query { scannerHolderAnalysis(tokenAddresses: ["..."]) { # fields to query } } ``` -------------------------------- ### Query Shield Advanced Source: https://docs.de.fi/api/api Fetches advanced security information for smart contract addresses. This endpoint is used in conjunction with `shieldApprovals` to analyze token security. ```graphql query { shieldAdvanced(smartContractAddresses: ["..."]) { # fields to query } } ``` -------------------------------- ### Query Scanner Liquidity Analysis Source: https://docs.de.fi/api/api Retrieves liquidity information for tokens associated with smart contracts. This endpoint is crucial for the Scanner Dashboard's analysis capabilities. ```graphql query { scannerLiquidityAnalysis(tokenAddresses: ["..."]) { # fields to query } } ``` -------------------------------- ### Query Shield Approvals Source: https://docs.de.fi/api/api Retrieves all token approvals granted by a specific wallet address. This is useful for security audits and identifying potential risks. ```graphql query { shieldApprovals(walletAddress: "...") { # fields to query } } ``` -------------------------------- ### Security and Scanner Endpoints Source: https://docs.de.fi/api/api Access security-related data, including hack/exploit information, wallet safety scores, token approvals, and smart contract analysis. These endpoints help assess risk and security posture. ```APIDOC Security and Scanner Endpoints: rekts - Retrieves paginated data about all hacks and exploits in the Rekt Database. - Returns: Paginated list of security incidents. shieldAdvanced - Fetches safety information from De.Fi Shield for any given wallet address(es). - Parameters: - wallet_addresses: Array of wallet addresses. - Returns: Safety assessment for the provided wallet addresses. shieldApprovals - Lists all ERC20 token approvals for any given wallet address(es). - Parameters: - wallet_addresses: Array of wallet addresses. - Returns: List of ERC20 approvals and their details. shieldApprovalsNft - Lists all ERC721 and ERC1155 token approvals for any given wallet address(es). - Parameters: - wallet_addresses: Array of wallet addresses. - Returns: List of NFT approvals and their details. scannerLiquidityAnalysis - Provides global liquidity distribution, top 10 LP holders, and top 10 liquidity pairs for any given token address. - Parameters: - token_address: The address of the token. - Returns: Liquidity analysis data for the token. scannerHolderAnalysis - Retrieves information on the top 10 holders for any given token address. - Parameters: - token_address: The address of the token. - Returns: Top 10 holder data for the token. scannerProject - Fetches a list of all issues found (static and dynamic), security score, similar contracts, and on-chain governance info for any given smart contract address. - Parameters: - contract_address: The address of the smart contract. - Returns: Comprehensive security and governance analysis for the contract. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.