Reports
Export comprehensive profit reports in PDF, CSV, or JSON formats for accounting, analysis, or presentations.
Supported Formats
- PDF - Professional reports for presentations and printing
- CSV - Import into Excel, Google Sheets, or analytics tools
- JSON - Programmatic access for custom integrations
GET /v1/reports/profit
Download profit report in your preferred format.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
startDate | string | No | Start date (YYYY-MM-DD format) |
endDate | string | No | End date (YYYY-MM-DD format) |
format | string | No | pdf, csv, json (default: pdf) |
Note: If dates are not provided, defaults to last 30 days.
Format: JSON
Example Request
bash
curl -H "Authorization: Bearer looha_your_api_key" \
"https://api.looha.app/v1/reports/profit?startDate=2024-01-01&endDate=2024-01-31&format=json"Response
json
{
"success": true,
"data": {
"period": {
"startDate": "2024-01-01",
"endDate": "2024-01-31"
},
"summary": {
"revenue": 125000,
"costs": 87500,
"netProfit": 37500,
"profitMargin": 30.0
}
}
}Format: CSV
Example Request
bash
curl -H "Authorization: Bearer looha_your_api_key" \
"https://api.looha.app/v1/reports/profit?startDate=2024-01-01&endDate=2024-01-31&format=csv" \
-o profit-report.csvResponse Headers
Content-Type: text/csv; charset=utf-8
Content-Disposition: attachment; filename="profit-report-2024-01-01-2024-01-31.csv"CSV Content
csv
Metric,Value
Revenue,125000
Product Costs,62500
Ad Spend,15000
Platform Fees,3125
Payment Fees,3750
Other Costs,3125
Total Costs,87500
Net Profit,37500
Profit Margin,30.0%
ROAS,8.33
Order Count,450
Avg Order Value,277.78Use Cases:
- Import into Excel for further analysis
- Load into Google Sheets for sharing with team
- Import into accounting software
Format: PDF
Example Request
bash
curl -H "Authorization: Bearer looha_your_api_key" \
"https://api.looha.app/v1/reports/profit?startDate=2024-01-01&endDate=2024-01-31&format=pdf" \
-o profit-report.pdfResponse Headers
Content-Type: application/pdf
Content-Disposition: attachment; filename="profit-report-2024-01-01-2024-01-31.pdf"Note: PDF contains:
- Report header with date range
- Summary metrics table
- Company branding (Looha logo)
- Professional formatting
Use Cases:
- Print for physical records
- Email to accountant or investors
- Archive for compliance
Error Responses
400 Bad Request - Invalid Date
json
{
"success": false,
"error": "Invalid date format. Use YYYY-MM-DD"
}400 Bad Request - Invalid Format
json
{
"success": false,
"error": "Invalid format. Use: pdf, csv, or json"
}401 Unauthorized
json
{
"success": false,
"error": "Unauthorized"
}Use Cases
Auto-Generate Monthly Reports
javascript
const API_KEY = 'looha_your_api_key'
// Get first and last day of previous month
const now = new Date()
const firstDay = new Date(now.getFullYear(), now.getMonth() - 1, 1)
const lastDay = new Date(now.getFullYear(), now.getMonth(), 0)
const startDate = firstDay.toISOString().split('T')[0]
const endDate = lastDay.toISOString().split('T')[0]
// Download PDF report
const response = await fetch(
`https://api.looha.app/v1/reports/profit?startDate=${startDate}&endDate=${endDate}&format=pdf`,
{
headers: { Authorization: `Bearer ${API_KEY}` },
}
)
const blob = await response.blob()
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `profit-report-${startDate}-${endDate}.pdf`
a.click()Email CSV Report
python
import requests
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
import smtplib
API_KEY = 'looha_your_api_key'
# Download CSV report
response = requests.get(
'https://api.looha.app/v1/reports/profit',
params={
'startDate': '2024-01-01',
'endDate': '2024-01-31',
'format': 'csv'
},
headers={'Authorization': f'Bearer {API_KEY}'}
)
# Create email with attachment
msg = MIMEMultipart()
msg['From'] = 'noreply@looha.app'
msg['To'] = 'accountant@company.com'
msg['Subject'] = 'Monthly Profit Report - January 2024'
# Attach CSV
part = MIMEBase('text', 'csv')
part.set_payload(response.content)
encoders.encode_base64(part)
part.add_header(
'Content-Disposition',
'attachment; filename=profit-report-jan-2024.csv'
)
msg.attach(part)
# Send email
smtp = smtplib.SMTP('smtp.gmail.com', 587)
smtp.starttls()
smtp.login('your@email.com', 'password')
smtp.send_message(msg)
smtp.quit()
print('Report emailed successfully')Quarterly Reports to Google Drive
javascript
const API_KEY = 'looha_your_api_key'
async function generateQuarterlyReport(year, quarter) {
// Calculate quarter dates
const startMonth = (quarter - 1) * 3
const startDate = `${year}-${String(startMonth + 1).padStart(2, '0')}-01`
const endDate = new Date(year, startMonth + 3, 0).toISOString().split('T')[0]
// Download PDF
const response = await fetch(
`https://api.looha.app/v1/reports/profit?startDate=${startDate}&endDate=${endDate}&format=pdf`,
{
headers: { Authorization: `Bearer ${API_KEY}` },
}
)
const blob = await response.blob()
// Upload to Google Drive (requires Google Drive API setup)
const formData = new FormData()
formData.append('file', blob, `Q${quarter}-${year}-profit-report.pdf`)
formData.append('parents', ['GOOGLE_DRIVE_FOLDER_ID'])
await fetch('https://www.googleapis.com/upload/drive/v3/files', {
method: 'POST',
headers: {
Authorization: `Bearer ${GOOGLE_DRIVE_TOKEN}`,
},
body: formData,
})
console.log(`Q${quarter} ${year} report uploaded to Google Drive`)
}
// Generate all quarterly reports for 2024
for (let q = 1; q <= 4; q++) {
await generateQuarterlyReport(2024, q)
}Compare Multiple Periods
python
import requests
import pandas as pd
API_KEY = 'looha_your_api_key'
periods = [
('2024-01-01', '2024-01-31', 'January'),
('2024-02-01', '2024-02-29', 'February'),
('2024-03-01', '2024-03-31', 'March')
]
data = []
for start, end, month in periods:
response = requests.get(
'https://api.looha.app/v1/reports/profit',
params={'startDate': start, 'endDate': end, 'format': 'json'},
headers={'Authorization': f'Bearer {API_KEY}'}
)
result = response.json()
summary = result['data']['summary']
data.append({
'Month': month,
'Revenue': summary['revenue'],
'Costs': summary['costs'],
'Net Profit': summary['netProfit'],
'Profit Margin': summary['profitMargin']
})
# Create comparison DataFrame
df = pd.DataFrame(data)
print(df)
# Export to Excel
df.to_excel('quarterly-comparison.xlsx', index=False)Best Practices
1. Regular Backups
Schedule monthly report downloads for your records:
javascript
// Run this on the 1st of each month
const lastMonth = new Date()
lastMonth.setMonth(lastMonth.getMonth() - 1)
const startDate = new Date(lastMonth.getFullYear(), lastMonth.getMonth(), 1)
.toISOString()
.split('T')[0]
const endDate = new Date(lastMonth.getFullYear(), lastMonth.getMonth() + 1, 0)
.toISOString()
.split('T')[0]
// Download both PDF and CSV
for (const format of ['pdf', 'csv']) {
const response = await fetch(
`https://api.looha.app/v1/reports/profit?startDate=${startDate}&endDate=${endDate}&format=${format}`,
{ headers: { Authorization: `Bearer ${API_KEY}` } }
)
// Save to backup location
}2. Accounting Integration
Export monthly CSV for accounting software:
python
# Automate with cron job
def export_for_accounting():
# Get previous month
today = datetime.date.today()
first = today.replace(day=1)
last_month_end = first - datetime.timedelta(days=1)
last_month_start = last_month_end.replace(day=1)
# Download CSV
response = requests.get(
'https://api.looha.app/v1/reports/profit',
params={
'startDate': last_month_start.isoformat(),
'endDate': last_month_end.isoformat(),
'format': 'csv'
},
headers={'Authorization': f'Bearer {API_KEY}'}
)
# Save to accounting import folder
with open(f'/accounting/imports/looha-{last_month_start.isoformat()}.csv', 'wb') as f:
f.write(response.content)3. Stakeholder Reports
Auto-email PDF reports to stakeholders:
javascript
// Weekly reports every Monday
function emailWeeklyReport() {
const today = new Date()
const lastWeek = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000)
const startDate = lastWeek.toISOString().split('T')[0]
const endDate = today.toISOString().split('T')[0]
// Download PDF
fetch(
`https://api.looha.app/v1/reports/profit?startDate=${startDate}&endDate=${endDate}&format=pdf`,
{
headers: { Authorization: `Bearer ${API_KEY}` },
}
)
.then(res => res.blob())
.then(blob => {
// Email to stakeholders using your email service
sendEmail({
to: ['investor@company.com', 'ceo@company.com'],
subject: `Weekly Profit Report - ${startDate} to ${endDate}`,
attachment: blob,
})
})
}Next: Authentication →