Skip to main content

How Do I Automate Reports Using API Calls?

Updated over a month ago

Automating reports with the BrandMentions API allows you to replace manual, repetitive reporting work with a fully programmatic workflow. This is especially valuable for agencies and teams that must deliver reports regularly for many brands or clients.

With automation, you can:

  • Generate reports on a fixed schedule

  • Standardize structure and metrics across clients

  • Share data faster, with fewer manual steps

The two step reporting workflow

Automated reporting usually follows a simple two step process:

  1. Fetch the data with the BrandMentions API

  2. Generate and distribute the report in your desired format

You can implement both steps with a script or a small service, written in a language like Python, Node.js, PHP, or similar.

Step 1. Fetching data with the BrandMentions API

You can combine several endpoints to get everything you need for your reports:

  • GetProjectMentions
    Use this to fetch raw mentions for a project.
    Useful for:

    • Sample mentions in the report

    • Sentiment breakdowns

    • Source and country distribution

  • GetProjectInfluencers
    Use this to fetch top influencers for the project.
    Useful for:

    • Influencer leaderboards

    • Highlighting VIP accounts or high reach profiles

  • GetMentionsCount
    Use this for high level metrics, such as total mention volume for a project.
    Useful for:

    • Overall volume trends

    • Summary KPIs per period

You will typically:

  1. Write a script that:

    • Authenticates with your API key

    • Calls the endpoints you need

    • Applies filters such as date range, sources, countries, sentiment

  2. Store the data:

    • In a local file, such as CSV or JSON

    • In a database, such as PostgreSQL, MySQL, or a data warehouse

    • In memory, if you generate the report immediately

Example flow:

  • Once a week, fetch:

    • Total mentions for last week

    • Mentions list for last week

    • Top influencers for last week

  • Pass that data into your reporting layer in the next step.

Step 2. Generating the report

Once you have the data, you can generate reports in different formats depending on what your stakeholders prefer.

1. PDF reports

Best for: polished, client ready documents.

How to generate:

  • Use a PDF library in your language of choice, for example:

    • Python: ReportLab, WeasyPrint

    • Node.js: PDFKit, Puppeteer with HTML templates

    • PHP: FPDF, TCPDF

With these tools you can:

  • Insert your logo and brand colors

  • Add charts, tables, and summary metrics

  • Include snippets of mentions as examples

Typical flow:

  1. Load the data from step 1

  2. Build charts and tables in code

  3. Render them into a PDF template

  4. Save the PDF and optionally email it or upload it to a client portal

2. Excel

Best for: data heavy reports and teams that like to analyze in Excel.

Most languages have libraries to help with this, for example:

  • Python: pandas, openpyxl, xlsxwriter

  • Node.js: exceljs

  • PHP: PhpSpreadsheet

Use this approach if you:

  • Want to give clients full access to raw mention data

  • Want internal analysts to build their own pivots and charts

  • Need to integrate with tools that import CSV or Excel files

3. HTML dashboards

Best for: interactive and always on reporting.

How to generate:

  • Build a simple web application that:

    • Reads the data from your database or API

    • Renders charts and tables in a browser

You can use:

  • Frontend frameworks: React, Vue, Svelte

  • Chart libraries: Chart.js, D3.js, ECharts, Highcharts

Typical pattern:

  1. Use a backend script or scheduled job to pull data from the BrandMentions API

  2. Store it in a database

  3. Your dashboard reads from that database and updates automatically

This gives your stakeholders a live reporting portal that updates whenever your jobs run.

Automating the full pipeline

To fully automate the process, you need a scheduler to run your scripts without manual effort.

Options for scheduling

  • Linux servers

    • Use cron to run scripts hourly, daily, weekly, and so on

  • Windows servers

    • Use Task Scheduler to run scripts on a fixed schedule

  • Cloud platforms

    • AWS: Lambda with EventBridge, or ECS tasks on a schedule

    • Google Cloud: Cloud Scheduler calling Cloud Functions or Cloud Run

    • Azure: Functions with Time Triggers or Logic Apps

Example automation setup:

  1. Every Monday at 09:00:

    • Job runs a script

    • Script calls BrandMentions API endpoints for the previous week

    • Script generates a PDF and Excel file

    • Script emails the files to stakeholders and uploads them to shared storage

  2. Every day at 06:00:

    • Job updates a dashboard database with the latest mentions and counts

    • Internal dashboards show fresh data when the team starts work

Putting it all together

To automate reports using the BrandMentions API:

  1. Fetch data programmatically

    • Use GetProjectMentions, GetProjectInfluencers, GetMentionsCount and any other required endpoints.

  2. Generate the report

    • Create PDF, Excel, CSV, or HTML dashboards using the data.

  3. Schedule the workflow

    • Use cron, Task Scheduler, or cloud schedulers to run everything automatically.

Once this is set up, your reporting becomes:

  • Consistent

  • Scalable across many brands and projects

  • Much less dependent on manual effort and copy paste work.

Did this answer your question?