Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.0 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { genderApiAuth } from '../common/auth';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';

export const getStatistics = createAction({
  auth: genderApiAuth,
  name: 'getStatistics',
  classification: 'READ',
  displayName: 'Get Statistics',
  description:
    'Get account statistics including remaining credits and usage information',
  audience: 'both',
  aiMetadata: {
    description:
      'Retrieves the Gender API account statistics, including remaining credits and usage information. Use to check quota before running batches of name lookups. Takes no input; read-only and safe to repeat.',
    idempotent: true,
  },
  props: {},
  async run(context) {
    const response = await httpClient.sendRequest({
      method: HttpMethod.GET,
      url: 'https://gender-api.com/v2/statistic',
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${context.auth.secret_text}`,
      },
    });

    return response.body;
  },
});