This API requires an API key with appropriate permissions. Regular organization API keys can only access metrics for their associated organizations.

Quick Start

Authentication

Include your API key in the Authorization header:

Authorization: Bearer your_api_key

Example Request

curl -X POST 'https://api.chainpatrol.io/public/getOrganizationMetrics' \
  -H 'Authorization: Bearer your_api_key' \
  -H 'Content-Type: application/json' \
  -d '{
    "organizationSlugs": ["your-org"],
    "startDate": "2024-01-01T00:00:00Z",
    "endDate": "2024-03-01T00:00:00Z"
  }'

Example Implementation

async function fetchOrganizationMetrics(organizationSlugs, startDate, endDate) {
  const response = await fetch(
    "https://api.chainpatrol.io/public/getOrganizationMetrics",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: "Bearer YOUR_API_KEY_HERE",
      },
      body: JSON.stringify({
        organizationSlugs,
        startDate,
        endDate,
      }),
    }
  );
  return response.json();
}

// Example usage
fetchOrganizationMetrics(
  ["your-org"],
  "2024-01-01T00:00:00Z",
  "2024-03-01T00:00:00Z"
)
  .then((data) => console.log("Metrics:", data))
  .catch((error) => console.error("Error fetching metrics:", error));

API Details

Request Parameters

ParameterTypeRequiredDescription
organizationSlugsstring[]YesArray of organization slugs to query
startDateDateNoStart date for metrics (default: all time)
endDateDateNoEnd date for metrics (default: current date)

Response Format

{
  combinedMetrics: {
    reportsCount: number;                    // Total number of reports
    threatsBlockedCount: number;             // Total number of threats blocked
    threatsBlockedByAssetType: Array<{       // Threats blocked grouped by asset type
      assetType: string;
      count: number;
    }>;
    domainsBlockedCount: number;             // Number of domains blocked
    activeThreatsCount: number;              // Number of active threats
    totalTakedownsFiledCount: number;        // Total number of takedowns filed
    totalTakedownsCompletedCount: number;    // Total number of completed takedowns
  };
  perOrgMetrics: {                           // Same metrics as above, but per organization
    [organizationSlug: string]: {
      reportsCount: number;
      threatsBlockedCount: number;
      threatsBlockedByAssetType: Array<{
        assetType: string;
        count: number;
      }>;
      domainsBlockedCount: number;
      activeThreatsCount: number;
      totalTakedownsFiledCount: number;
      totalTakedownsCompletedCount: number;
    };
  };
}

Error Handling

Status CodeDescription
401 UnauthorizedInvalid or missing API key
403 ForbiddenAPI key does not have permission to query the requested organizations
500 Internal Server ErrorServer error occurred while processing the request

Notes

  • If no date range is provided, metrics will be returned for all time
  • The response includes both combined metrics across all requested organizations and per-organization breakdowns
  • Special organization API keys (Sui, Consensys) can query metrics for any organization
  • Regular organization API keys can only query their own organization’s metrics