Skip to main content
GET
/
api
/
trends
Get Trend Data
curl --request GET \
  --url https://api.example.com/api/trends
{
  "[]": [
    {
      "mes": 123,
      "año": 123,
      "ingresos_cobrados": 123,
      "egresos_pagados": 123,
      "ingresos_devengados": 123,
      "egresos_devengados": 123
    }
  ]
}

Authentication

This endpoint requires authentication. Include your access token in the Authorization header.
Authorization: Bearer YOUR_ACCESS_TOKEN

Query Parameters

profile_id
string
Filter trends by profile ID
año
number
Year to retrieve trends for (defaults to current year)
period_view
enum
default:"año-actual"
View mode for the trend data:
  • año-actual: Only the selected year up to the current month (default)
  • últimos-12-meses: Rolling window of the last 12 months
  • año-completo: All 12 months of the selected year
  • comparar-anterior: Current year plus last 3 months of previous year
mes_corte
number
Cutoff month (1-12) to limit data up to a specific month. Automatically clamped to current month if in current year.
regimen_fiscal
string
Filter by tax regime code

Response

Returns an array of monthly data points:
[]
array
Array of monthly trend data points

Example Requests

curl -X GET "https://api.contafy.com/api/trends?profile_id=prof_123" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Get last 12 months rolling window

curl -X GET "https://api.contafy.com/api/trends?profile_id=prof_123&period_view=últimos-12-meses" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Get full year with comparison

curl -X GET "https://api.contafy.com/api/trends?profile_id=prof_123&año=2026&period_view=comparar-anterior" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Get year up to specific month

curl -X GET "https://api.contafy.com/api/trends?profile_id=prof_123&año=2026&mes_corte=6" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Example Response

[
  {
    "mes": 1,
    "año": 2026,
    "ingresos_cobrados": 120000.00,
    "egresos_pagados": 70000.00,
    "ingresos_devengados": 150000.00,
    "egresos_devengados": 85000.00
  },
  {
    "mes": 2,
    "año": 2026,
    "ingresos_cobrados": 135000.00,
    "egresos_pagados": 75000.00,
    "ingresos_devengados": 160000.00,
    "egresos_devengados": 90000.00
  },
  {
    "mes": 3,
    "año": 2026,
    "ingresos_cobrados": 150000.00,
    "egresos_pagados": 80000.00,
    "ingresos_devengados": 200000.00,
    "egresos_devengados": 100000.00
  }
]

Error Responses

401 Unauthorized
{
  "error": "Unauthorized",
  "message": "Invalid or missing access token"
}
400 Bad Request
{
  "error": "Bad Request",
  "message": "Invalid query parameters"
}
500 Internal Server Error
{
  "error": "Internal Server Error",
  "message": "An unexpected error occurred"
}

Period View Modes

año-actual (Default)

Returns only the selected year up to the current month (or mes_corte if specified). This is the most common view for tracking year-to-date performance. Example: For March 2026, returns data for January, February, and March 2026 only.

últimos-12-meses

Returns a rolling 12-month window ending at the current month. Useful for seeing trends without year boundaries. Example: For March 2026, returns April 2025 through March 2026.

año-completo

Returns all 12 months of the selected year, regardless of the current date. Months without data return zero values. Example: Returns January through December of the selected year.

comparar-anterior

Returns the current year plus the last 3 months of the previous year for comparison. Only works when viewing the current year. Example: For March 2026, returns October-December 2025 and January-March 2026.

Notes

  • The endpoint aggregates metrics data from multiple months into a single response
  • Data points with no activity will have zero values for all numeric fields
  • Trends use the same cash flow and accrual calculations as the metrics endpoint
  • The response is sorted chronologically (oldest to newest)
  • When using mes_corte in the current year, it automatically clamps to the current month
  • Trend data is useful for charts and visualizations showing financial performance over time