Analytics API Documentation

Interact with the Treno Analytics for real-time DeFi data, risk indicators, and more. This documentation provides guidance for making API requests, handling responses, and managing errors.

Terminology

Key Terms in Our DeFi Platform:

Platform:

The underlying blockchain infrastructure where DeFi services operate. For example, Ethereum.

Provider:

DeFi services or providers that offer financial services. Examples include Uniswap, Aave, and Compound.

Active Investment Position:

A specific investment you currently hold within a provider. This could be a lending position, a liquidity provision, or a staking position.

Investment Type:

The nature of your investment. This includes categories like Lending, Liquidity Provision, and Staking.

Financial Product:

Various types of tokens and cryptocurrencies you can invest in, such as Stablecoins or Gold-tokens.

Asset:

Individual cryptocurrencies or tokens.

Portfolio:

Your collection of assets and active investment positions.

Position:

An asset that you hold in your portfolio. This includes any cryptocurrency or token that you own.

Authentication

All API requests require an API key. Add it to the `Authorization` header for authentication:

Method 1: Header Authorization

Typically used within applications.

Authorization: Bearer YOUR_API_KEY

Method 2: Query Parameter Authorization

Commonly used for single API calls, such as in widgets, Excel sheets, or when simply working with JSON. When making widgets publicly available, ensure that only read-only tokens are generated to prevent your limits from being consumed by others.

Additionally, you can restrict iframes to only be embedded on specific domains using the `X-Frame-Options` or `Content-Security-Policy` (CSP) headers.

GET /portfolios/{portfolioId}/transactions?authToken=YOUR_API_KEY

Retrieve your API key from the Dashboard.

API Endpoints

In the following, we demonstrate only the basic functionality of the API. The complete documentation is available as an OpenAPI specification in the members' section.

Success Response

Wallet Transactions

Retrieve all transactions for a given wallet address.

GET /portfolios/{portfolioId}/transactions
Headers:
Authorization: Bearer YOUR_API_KEY

Example Response:

{
  "status": "success",
  "data": [
    {
      "assetId": "usdc",
      "amount": "10.45",
      "contractAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "date": "2024-05-28",
      "direction": "in",
      "feeValue": "0",
      "platform": "ethereum",
      "subtype": "transaction-in",
      "symbol": "USDC",
      "transactionId": "0x0",
      "type": "transfer"
    }
  ]
}

Partial Success Response

Portfolio Performance

Retrieve the performance of assets held within a portfolio.

GET /portfolios/{portfolioId}/performance
Headers:
Authorization: Bearer YOUR_API_KEY

Example Response:

{
  "status": "partial_success",
  "errors": {
    "level": "WARN",
    "event": "MultipleErrors",
    "error": "Multiple errors occured calculation portfolio performance.",
    "context": {
      "origin": "getPortfolioPerformance",
      "errors": [
        {
          "level": "WARN",
          "event": "NoPriceDataError",
          "error": "Could not retrieve the asset price for the given date.",
          "context": {
            "id": "unknown-coin",
            "origin": "getHistoricPriceById",
            "date": "2024-05-28"
          }
        }
      ]
    }
  },
  "data": {
    "value30dAgo": "50000",
    "change30d": "-3",
    "diff30d": "-1500",
    "value1dAgo": "48000",
    "change1d": "1.5",
    "diff1d": "720",
    "value1hAgo": "48200",
    "change1h": "0.4",
    "diff1h": "20",
    "currentValue": "48400"
  }
}

Error Handling

The API returns various errors to assist in usage. For example, it also provides non-critical errors that can occur during processing.

Client Error Responses

401 Unauthorized

Your API key is missing or invalid. Ensure that your key is included in the `Authorization` header.

{
  "status": "error",
  "message": "Unauthorized - API key is missing or invalid"
}

429 Too Many Requests

You’ve exceeded your rate limit. You can upgrade your plan to increase the limit.

{
  "status": "error",
  "message": "Rate limit exceeded - upgrade your plan"
}

Server Error Responses

502 Bad Gateway

The API call fails due to issues within the call stack, where multiple steps are required to complete the request. A 502 error indicates that the request encountered critical errors and could not be completed. Errors of this nature should be reported to support.

{
  "status": "failure",
  "errors": {
    "level": "CRITICAL",
    "event": "ApiCallError",
    "error": "Data not found for the given contract address.",
    "context": {
      "origin": "getLendingMarkets"
    }
  }
}

Rate Limiting

API requests are limited based on your subscription tier:

  • Starter Tier: Limitations on API calls may apply.
  • Pro Tier: Full access with higher reliability and performance.
  • Enterprise Tier: Custom limits based on usage with dedicated support.

Support

If something doesn't work as expected, you can reach out to us through the following channels:

  • Email: Contact us directly via email for assistance.
  • Discord: Join our Discord server where our team and the community are happy to help with general questions and troubleshooting.
  • GitHub Issues: If you encounter a bug, feel free to create an issue on GitHub, and our team will look into it.

For general questions, the community on Discord is always ready to assist, alongside our support team.

Frequently Asked Questions (FAQ)