Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda