Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
Facebook marketing API only returning 25 results/ads

Im not getting more than 25 ads from my ad account with this request. I work at a company and this is how the previous guy have built it, so I would appreciate a solution for this way of calling the api. Everything works, its just that im not getting more than 25 records.

I have read that you could add a "limit" parameter to the URI/request followed by a number (shown here, at part 9: https://mixedanalytics.com/knowledge-base/import-facebook-ad-data-to-google-sheets/#num9)

In my case, I have tried adding a "limit" variable in the interface, in the fields array, I have tried sneaking in "limit" in the account.getAds() call. Pretty much everything that seems logical in the presented code below:

import logger from "../****/****";
import { FB_ACCESS_TOKEN } from "../****/****";
import { AdAccount, FacebookAdsApi } from "facebook-nodejs-business-sdk";

let isInitialized = false;

function initFacebookApi(): void {
    if (!isInitialized) {
        FacebookAdsApi.init(FB_ACCESS_TOKEN);
        isInitialized = true;
    }
}

interface FacebookAdParam {
    filtering?: {
        field: string;
        operator: string;
        value: string;
    }[];
}

export async function searchFBAds(facebookAccountId: string, search: string | undefined) {
    try {
        initFacebookApi();

        const fullAccountId = `act_${facebookAccountId}`;
        const account = new AdAccount(fullAccountId);
        const params: FacebookAdParam = {};
        const fields = ['id', 'name'];

        if (search) { //Our GUI features a search function, to filter by name, after fetching all records
            params.filtering = [
                {
                    field: 'name',
                    operator: 'CONTAIN',
                    value: search,
                },
            ];
        }

        const ads: any[] = await account.getAds(fields, params);
        return ads.map(({ id, name }) => {
            return {
                id: id,
                name: name
            };
        });
    }
    catch (e) {
        logger.error('Something went wrong when searching for a facebook ad', e);
    }
}

Thanks in advance //Ibrahim, junior dev.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!