Forecast API Documentation

Welcome to the Forecast API documentation. This API provides comprehensive price forecasts for cryptocurrency tokens on the Solana blockchain, including price predictions, volatility information, and support/resistance levels. Designed for developers, this guide will help you integrate and utilize the API effectively.

Base URL

All API endpoints are accessible via the following base URL:

https://api.dith.ai/

Authentication

Authentication is required using a Bearer token. Users must have sufficient token holdings (DITHER or MET tokens) or own whitelisted NFTs to access the forecast functionality.

Format: Bearer <your_token>

You can generate a bearer token after verifying your token holdings with our Telegram bot here.

Endpoints

1. Generate Forecast

Endpoint: /forecast/v2/forecast
Method: POST
Description: Generates price forecasts for cryptocurrency tokens on the Solana blockchain, providing price predictions, volatility information, and support/resistance levels.

Request

Headers:

Content-Type: application/json
Authorization: Bearer <your_token>

Body:

{
  "token_address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "timeframe": 60,
}

Parameters

Parameter Type Required Description
token_address string Yes The mint address of the token to forecast
timeframe integer No Candle timeframe in minutes (5, 15, 60, or 240). Default is 60

Response

Success (200 OK):
{
  "token_details": {
    "name": "USD Coin",
    "symbol": "USDC",
    "description": "USD Coin (USDC) is a stablecoin pegged to the US dollar",
    "supply": "5234532100000000",
    "decimals": 6,
    "price_per_token": 1.00
  },
  "current_price": 1.00,
  "consensus_score": 0.89,
  "forecast": [
    {
      "timestamp": "2025-02-26T14:00:00.000Z",
      "price": 1.0002
    },
    {
      "timestamp": "2025-02-26T15:00:00.000Z",
      "price": 1.0001
    },
    // Additional forecast points...
  ],
  "input_data": [
    {
      "timestamp": "2025-02-25T14:00:00.000Z",
      "price": 0.9998
    },
    {
      "timestamp": "2025-02-25T15:00:00.000Z",
      "price": 0.9999
    },
    // Additional historical data points...
  ],
  "volatility_info": {
    "annualized_stdev_estimate": 0.0012,
    "atr": 0.0005
  },
  "support_resistance": [
    {
      "price": 0.9995,
      "type": "support"
    },
    {
      "price": 1.0005,
      "type": "resistance"
    }
  ],
  "trade_levels": {
    "action": "BUY",
    "entry_price": 0.9998,
    "stop_loss": 0.9992,
    "take_profit": 1.0006,
    "support_levels": [0.9995, 0.9990],
    "resistance_levels": [1.0005, 1.0010],
    "hit_probabilities": {
      "p_hit_tp": 0.68,
      "p_hit_sl": 0.22,
      "p_no_hit": 0.10
    }
  },
  "technical_indicators": {
    "ma20_latest": 0.9999,
    "ma50_latest": 1.0001,
    "rsi": 54.2,
    "stoch_rsi": 62.5,
    "stoch_rsi_k": 65.3,
    "stoch_rsi_d": 58.7,
    "ma20_series": [
      {
        "timestamp": "2025-02-25T10:00:00.000Z",
        "value": 0.9997
      },
      // Additional MA20 data points...
    ],
    "ma50_series": [
      // MA50 data points...
    ]
  }
}

Response Fields

Field Type Description
token_details object Information about the token
current_price number Current token price
consensus_score number Confidence score of the forecast (0-1)
forecast array Array of predicted price points with timestamps
input_data array Historical data used for the forecast
volatility_info object Volatility metrics
support_resistance array Key support and resistance price levels
trade_levels object Termi Trading
technical_indicators object Technical indicator values

2. Get Last Predictions

Endpoint: /forecast/v2/last-predictions
Method: GET
Description: Retrieves the most recent predictions made by the system.

Request

Headers:

Authorization: Bearer <your_token>

Query Parameters:

limit=10

Response

Success (200 OK):
{
  "predictions": [
    {
      "timestamp": "2025-02-27T12:30:45.000Z",
      "token_address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      "response_body": {
        // Full forecast response
      }
    },
    // Other predictions
  ]
}

Example Usage

Below are examples demonstrating how to interact with the API using cURL and Python's requests library.

Using cURL

Example: Generate Forecast

curl -X POST https://api.dith.ai/forecast/v2/forecast \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_token>" \
  -d '{
    "token_address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "timeframe": 60
  }'

Example: Get Last Predictions

curl -X GET https://api.dith.ai/forecast/v2/last-predictions?limit=5 \
  -H "Authorization: Bearer <your_token>"

Using Python (Requests)

Example: Generate Forecast

import requests
import json

url = "https://api.dith.ai/forecast/v2/forecast"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <your_token>"
}
payload = {
    "token_address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "timeframe": 60
}

response = requests.post(url, headers=headers, json=payload)

if response.status_code == 200:
    forecast_data = response.json()
    print(f"Current Price: {forecast_data['current_price']}")
    print(f"Consensus Score: {forecast_data['consensus_score']}")
    print(f"Forecast Points: {len(forecast_data['forecast'])}")
    print(f"Trading Action: {forecast_data['trade_levels']['action']}")
else:
    print(f"Error: {response.status_code} - {response.text}")

Example: Get Last Predictions

import requests

url = "https://api.dith.ai/forecast/v2/last-predictions"
params = {"limit": 5}
headers = {
    "Authorization": "Bearer <your_token>"
}

response = requests.get(url, headers=headers, params=params)

if response.status_code == 200:
    predictions = response.json()['predictions']
    for i, pred in enumerate(predictions):
        print(f"Prediction {i+1}:")
        print(f"  Token: {pred['token_address']}")
        print(f"  Time: {pred['timestamp']}")
        print(f"  Current Price: {pred['response_body']['current_price']}")
        print()
else:
    print(f"Error: {response.status_code} - {response.text}")

Error Handling

The API may return the following errors. Ensure to handle them appropriately in your application:

Common Errors

Status Code Error Message Description
400 Bad Request No data provided The request did not include required parameters.
400 Bad Request Token address is required The token_address parameter is missing.
400 Bad Request Unable to retrieve token data Could not fetch token data from the blockchain.
400 Bad Request Insufficient data points Not enough historical data to generate a forecast.
400 Bad Request Failed to generate valid forecasts The forecast generation process did not produce valid results.
401 Unauthorized Bearer token required Authentication token is missing.
401 Unauthorized Invalid bearer token The provided authentication token is invalid.
403 Forbidden Insufficient token holdings The user does not have enough tokens to access the service.
404 Not Found No predictions found No historical predictions are available.
500 Internal Server Error Unexpected error An unexpected error occurred on the server.

Notes

  • Caching: Results for the same token address may be cached.
  • Data Requirements: The API needs at least 500 historical data points to generate a forecast.
  • Disclaimer: Forecasts should be considered experimental and not financial advice.
  • Token Requirements: Users must hold DITHER tokens (minimum 49,999) or MET tokens (minimum 69 from this pool) to access the service.
  • Technical Analysis: The API provides various technical indicators including MA20, MA50, RSI, and Stochastic RSI.
  • Termi Trading: Trade levels include entry points, stop-loss, take-profit, and probability assessments based on simplistic algorithms (Not advice or recommendations).