Historical Trends

428 words · 2 min read

Overview

This documentation describes how to use the Historical Trend endpoint to access historical trend data for various cryptocurrencies.

Endpoint

GET /api/v2/market/trends/<COIN>

Retrieve historical trend information for a specified cryptocurrency.

Base URL

https://api.guavy.com

Full Endpoint Example

https://api.guavy.com/api/v2/market/trends/<COIN>

Replace <COIN> with the desired cryptocurrency symbol, such as BTC for Bitcoin.

Authentication

This API requires authentication using a Bearer token. Include your API key in the request header as shown below.

Request Headers

HeaderDescription
AuthorizationBearer token for API authentication.

Example Header

-H "Authorization: Bearer YOUR-API-KEY"

Response Format

The response returns data in JSON format, containing historical trend information for the specified cryptocurrency.

Example Response

{
  "Success": {
    "coin": "BTC",
    "trends": [
      {
        "date": 1670832000000.0,
        "trend": "neutral",
        "trend_started_on": "2022-12-12T08:00:00.000Z",
        "price_on_trend_start": 16931.07980434933,
        "duration_in_days": 2,
        "peak_gain": 5.170210362000719,
        "peak_loss": 1.3783680854624911,
        "max_price": 17806.45224679241,
        "min_price": 17164.452404896667
      },
      {
        "date": 1671014400000.0,
        "trend": "down",
        "trend_started_on": "2022-12-14T08:00:00.000Z",
        "price_on_trend_start": 17164.452404896667,
        "duration_in_days": 3,
        "peak_gain": 2.351987920574144,
        "peak_loss": 6.783459274239095,
        "max_price": 17532.54006359813,
        "min_price": 16343.12982237682
      }
      ...
    ]
  }
}

Field Descriptions

FieldTypeDescription
coinstringThe ticker symbol of the requested cryptocurrency.
trendsarrayAn array of trend objects, each representing a historical trend period.
- datefloatThe date of the trend event in milliseconds since the epoch.
- trendstringThe trend direction for the period. Possible values are "up", "down", and "neutral".
- trend_started_onstringThe start date and time of the trend in ISO 8601 format.
- price_on_trend_startfloatThe price of the cryptocurrency at the start of the trend period.
- duration_in_daysintegerThe duration of the trend period in days.
- peak_gainfloatThe maximum percentage gain during the trend period.
- peak_lossfloatThe maximum percentage loss during the trend period.
- max_pricefloatThe highest price reached during the trend period.
- min_pricefloatThe lowest price reached during the trend period.

Code Examples

cURL

curl -X GET "https://api.guavy.com/api/v2/market/trends/BTC" \
-H "Authorization: Bearer YOUR-API-KEY"

Python (requests library)

import requests

url = "https://api.guavy.com/api/v2/market/trends/BTC"
headers = {
    "Authorization": "Bearer YOUR-API-KEY"
}
response = requests.get(url, headers=headers)

if response.status_code == 200:
    data = response.json()
    print(data)
else:
    print("Failed to retrieve data:", response.status_code)

JavaScript (fetch API)

fetch("https://api.guavy.com/api/v2/market/trends/BTC", {
  method: "GET",
  headers: {
    "Authorization": "Bearer YOUR-API-KEY",
  },
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));