> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aitasker.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Global Ad Library Platform Counts

> Per-platform ad counts for the Explore pill bar.

Library-wide by default — Explore browses the complete ad library, so its
pill counts must cover every advertiser. Pass ``advertiser_id`` to scope
the pills to one brand (the Full Brand Page ads grid). Each platform's
count uses the same filter semantics ``/search`` applies for that platform
value.

Brand Library tenancy applies to the SCOPED call only (finding M6). An
``advertiser_id`` arrives from the query string with nothing vouching for
it — the same client-supplied-id shape as finding C2 — and the answer is
a precise fact about one brand ("47 Facebook ads"), so an id the caller
cannot see 404s exactly like the advertiser detail route.

The library-wide call is deliberately NOT filtered. Its answer is an
aggregate over the whole library, identical for every caller, which is
what lets ``cached_platform_counts`` key on ``advertiser_id`` alone; a
per-caller predicate would make the cache per-caller and cost a query on
the hottest Explore call to hide a number nobody can attribute to a
brand. The consequence is honest and bounded: the library-wide total can
exceed what a filtered ``/search`` returns.



## OpenAPI

````yaml /openapi.json get /api/v1/ad-library/platform-counts
openapi: 3.1.0
info:
  title: AITasker
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/ad-library/platform-counts:
    get:
      tags:
        - Ad Library
        - Ad Library
      summary: Get Global Ad Library Platform Counts
      description: >-
        Per-platform ad counts for the Explore pill bar.


        Library-wide by default — Explore browses the complete ad library, so
        its

        pill counts must cover every advertiser. Pass ``advertiser_id`` to scope

        the pills to one brand (the Full Brand Page ads grid). Each platform's

        count uses the same filter semantics ``/search`` applies for that
        platform

        value.


        Brand Library tenancy applies to the SCOPED call only (finding M6). An

        ``advertiser_id`` arrives from the query string with nothing vouching
        for

        it — the same client-supplied-id shape as finding C2 — and the answer is

        a precise fact about one brand ("47 Facebook ads"), so an id the caller

        cannot see 404s exactly like the advertiser detail route.


        The library-wide call is deliberately NOT filtered. Its answer is an

        aggregate over the whole library, identical for every caller, which is

        what lets ``cached_platform_counts`` key on ``advertiser_id`` alone; a

        per-caller predicate would make the cache per-caller and cost a query on

        the hottest Explore call to hide a number nobody can attribute to a

        brand. The consequence is honest and bounded: the library-wide total can

        exceed what a filtered ``/search`` returns.
      operationId: >-
        get_global_ad_library_platform_counts_api_v1_ad_library_platform_counts_get
      parameters:
        - name: advertiser_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: uuid
              - type: 'null'
            title: Advertiser Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdLibraryPlatformCountsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    AdLibraryPlatformCountsResponse:
      properties:
        generated_at:
          type: string
          format: date-time
          title: Generated At
        total_ads:
          type: integer
          title: Total Ads
          default: 0
        platforms:
          items:
            $ref: '#/components/schemas/AdLibraryPlatformCount'
          type: array
          title: Platforms
      type: object
      required:
        - generated_at
      title: AdLibraryPlatformCountsResponse
      description: |-
        Library-wide per-platform ad counts for the Explore pill bar.

        Per-platform counts use the search's own platform-filter semantics
        (a Facebook+Instagram ad counts under both pills); ``total_ads`` is the
        distinct library-wide count, so the platform rows intentionally don't
        sum to it.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AdLibraryPlatformCount:
      properties:
        platform:
          type: string
          title: Platform
        total_ads:
          type: integer
          title: Total Ads
          default: 0
      type: object
      required:
        - platform
      title: AdLibraryPlatformCount
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````