Get Trend Data
curl --request GET \
--url https://api.example.com/api/trendsimport requests
url = "https://api.example.com/api/trends"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/trends', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/trends",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/trends"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/trends")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/trends")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"[]": [
{
"mes": 123,
"año": 123,
"ingresos_cobrados": 123,
"egresos_pagados": 123,
"ingresos_devengados": 123,
"egresos_devengados": 123
}
]
}Invoices
Get Trend Data
Retrieve monthly trend data for income and expenses
GET
/
api
/
trends
Get Trend Data
curl --request GET \
--url https://api.example.com/api/trendsimport requests
url = "https://api.example.com/api/trends"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/trends', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/trends",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/trends"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/trends")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/trends")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"[]": [
{
"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
string
Filter trends by profile ID
number
Year to retrieve trends for (defaults to current year)
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 monthsaño-completo: All 12 months of the selected yearcomparar-anterior: Current year plus last 3 months of previous year
number
Cutoff month (1-12) to limit data up to a specific month. Automatically clamped to current month if in current year.
string
Filter by tax regime code
Response
Returns an array of monthly data points:array
Example Requests
Get current year trends (default)
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
{
"error": "Unauthorized",
"message": "Invalid or missing access token"
}
{
"error": "Bad Request",
"message": "Invalid query parameters"
}
{
"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_cortein the current year, it automatically clamps to the current month - Trend data is useful for charts and visualizations showing financial performance over time