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

# Ads search API

> Search a public ad library: Meta, Google, TikTok, LinkedIn, Microsoft or Pinterest. Call the Ads search API for JSON. 2 credits per call.

* **Endpoint:** `ads.search`
* **Returns:** `data` has `results`, `totalMin`, `totalMax`, `advertiserId`, `advertiserName`, `total`.
* **Cost:** 2 credits per call. Failed calls cost nothing.
* **Paging:** Yes. Send the `cursor` from the response to get the next page. See [Page through results](/guides/paging).

## Example

<CodeGroup>
  ```typescript TypeScript icon="https://mintcdn.com/sirathic/7E4w9-IC4ysabjfc/images/icons/typescript.svg?fit=max&auto=format&n=7E4w9-IC4ysabjfc&q=85&s=d8272a85e64145620f1fbbfcf7932986" theme={null}
  import { Stophy } from "stophy";

  const stophy = new Stophy({ apiKey: process.env.STOPHY_API_KEY });
  const result = await stophy.ads.search({ network: "meta", query: "nike" });
  console.log(result.data.results);
  ```

  ```python Python icon="python" theme={null}
  from stophy import Stophy

  stophy = Stophy()  # reads STOPHY_API_KEY
  result = stophy.ads.search(network="meta", query="nike")
  print(result["data"]["results"])
  ```

  ```bash cURL icon="terminal" theme={null}
  curl -X POST https://api.stophy.dev/v1/ads/search \
    -H "Authorization: Bearer $STOPHY_API_KEY" \
    -H "content-type: application/json" \
    -d '{"network":"meta","query":"nike"}'
  ```

  ```bash CLI icon="square-terminal" theme={null}
  stophy ads search nike --network meta
  ```
</CodeGroup>


## OpenAPI

````yaml api-reference/openapi.json POST /v1/ads/search
openapi: 3.1.0
info:
  title: Stophy API
  version: '1'
  description: >-
    Every endpoint is a POST that takes its input as a JSON object body. Unknown
    fields are rejected with 400.


    Responses leave out empty values: null, empty strings, empty objects and
    empty nested lists are not sent.


    x-credits is what one call costs. Every call costs the same, whatever it
    returns.


    When a response has a cursor, send it back with the same input to get the
    next page.
servers:
  - url: https://api.stophy.dev
security:
  - apiKey: []
paths:
  /v1/ads/search:
    post:
      summary: >-
        Search a public ad library: Meta, Google, TikTok, LinkedIn, Microsoft or
        Pinterest
      description: Costs 2 credits per call. Pages with cursor.
      operationId: adsSearch
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    query:
                      type: string
                      minLength: 1
                      maxLength: 200
                    country:
                      default: us
                      pattern: ^(?:[A-Za-z]{2}|[Aa][Ll][Ll])$
                      description: >-
                        ISO 3166-1 alpha-2 country code, or all. Any case is
                        accepted.
                      type: string
                    status:
                      default: active
                      type: string
                      enum:
                        - active
                        - inactive
                        - all
                    cursor:
                      type: string
                      pattern: ^(?:\d{1,4}~(?:[\w-]{10,500})?|(?:[\w-]{10,500}))$
                    network:
                      type: string
                      const: meta
                    limit:
                      type: integer
                      minimum: 1
                      maximum: 100
                      description: >-
                        Return at most this many results from the page. The
                        price stays the same.
                  required:
                    - query
                    - network
                  additionalProperties: false
                - type: object
                  properties:
                    advertiser:
                      type: string
                    domain:
                      type: string
                    country:
                      type: string
                      pattern: ^[A-Za-z]{2}$
                      description: >-
                        ISO 3166-1 alpha-2 country code, e.g. us. Any case is
                        accepted.
                    mediaType:
                      type: string
                      enum:
                        - text
                        - image
                        - video
                    cursor:
                      type: string
                      pattern: ^[\w+/=-]{8,512}$
                    network:
                      type: string
                      const: google
                    limit:
                      type: integer
                      minimum: 1
                      maximum: 100
                      description: >-
                        Return at most this many results from the page. The
                        price stays the same.
                  required:
                    - network
                  additionalProperties: false
                - type: object
                  properties:
                    query:
                      type: string
                      minLength: 1
                      maxLength: 200
                    advertiser:
                      type: string
                      minLength: 1
                      maxLength: 200
                    country:
                      type: string
                      pattern: ^[A-Za-z]{2}$
                      description: >-
                        ISO 3166-1 alpha-2 country code, e.g. us. Any case is
                        accepted.
                    cursor:
                      type: string
                      pattern: >-
                        ^(?:\d{1,4}~(?:[A-Za-z0-9+/=]{8,400})?|(?:[A-Za-z0-9+/=]{8,400}))$
                    network:
                      type: string
                      const: tiktok
                    limit:
                      type: integer
                      minimum: 1
                      maximum: 100
                      description: >-
                        Return at most this many results from the page. The
                        price stays the same.
                  required:
                    - network
                  additionalProperties: false
                - type: object
                  properties:
                    query:
                      type: string
                      maxLength: 500
                    advertiser:
                      type: string
                      maxLength: 500
                    country:
                      type: string
                      pattern: ^[A-Za-z]{2}$
                      description: >-
                        ISO 3166-1 alpha-2 country code, e.g. us. Any case is
                        accepted.
                    within:
                      default: all
                      type: string
                      enum:
                        - month
                        - year
                        - all
                    cursor:
                      type: string
                      pattern: >-
                        ^(?:\d{1,4}~(?:\d{1,20}-\d{1,20})?|(?:\d{1,20}-\d{1,20}))$
                    network:
                      type: string
                      const: linkedin
                    limit:
                      type: integer
                      minimum: 1
                      maximum: 100
                      description: >-
                        Return at most this many results from the page. The
                        price stays the same.
                  required:
                    - network
                  additionalProperties: false
                - type: object
                  properties:
                    query:
                      type: string
                      minLength: 1
                      maxLength: 200
                    advertiser:
                      type: string
                      pattern: ^\d{1,20}$
                    country:
                      type: string
                      pattern: ^[A-Za-z]{2}$
                      description: >-
                        ISO 3166-1 alpha-2 country code, e.g. us. Any case is
                        accepted.
                    cursor:
                      type: string
                      pattern: ^\d{1,3}$
                    network:
                      type: string
                      const: microsoft
                    limit:
                      type: integer
                      minimum: 1
                      maximum: 100
                      description: >-
                        Return at most this many results from the page. The
                        price stays the same.
                  required:
                    - network
                  additionalProperties: false
                - type: object
                  properties:
                    country:
                      type: string
                      pattern: ^[A-Za-z]{2}$
                      description: >-
                        ISO 3166-1 alpha-2 country code, e.g. us. Any case is
                        accepted.
                    advertiser:
                      type: string
                      minLength: 1
                      maxLength: 200
                    cursor:
                      type: string
                      pattern: >-
                        ^(?:\d{1,4}~(?:[\w+/=|-]{8,4096})?|(?:[\w+/=|-]{8,4096}))$
                    network:
                      type: string
                      const: pinterest
                    limit:
                      type: integer
                      minimum: 1
                      maximum: 100
                      description: >-
                        Return at most this many results from the page. The
                        price stays the same.
                  required:
                    - country
                    - network
                  additionalProperties: false
            example:
              network: meta
              query: nike
      responses:
        '200':
          description: The data, and the credits this call used.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/RequestId'
            x-credits-used:
              $ref: '#/components/headers/CreditsUsed'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
            x-cache:
              $ref: '#/components/headers/Cache'
            x-cache-age:
              $ref: '#/components/headers/CacheAge'
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                  - creditsUsed
                  - requestId
                properties:
                  success:
                    const: true
                  data:
                    anyOf:
                      - type: object
                        additionalProperties: false
                        properties:
                          results:
                            type: array
                            items:
                              type: object
                              additionalProperties: false
                              properties:
                                adId:
                                  type: string
                                adUrl:
                                  type: string
                                  format: uri
                                pageId:
                                  type: string
                                pageName:
                                  type: string
                                pageUrl:
                                  type: string
                                  format: uri
                                pageAvatarUrl:
                                  type: string
                                  format: uri
                                pageCategories:
                                  type: array
                                  items:
                                    type: string
                                pageLikes:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                isActive:
                                  type: boolean
                                firstShownAt:
                                  type: string
                                  format: date-time
                                  pattern: >-
                                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                                lastShownAt:
                                  type: string
                                  format: date-time
                                  pattern: >-
                                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                                platforms:
                                  type: array
                                  items:
                                    type: string
                                format:
                                  type: string
                                text:
                                  type: string
                                linkUrl:
                                  type: string
                                  format: uri
                                linkTitle:
                                  type: string
                                linkDescription:
                                  type: string
                                ctaText:
                                  type: string
                                imageUrls:
                                  type: array
                                  items:
                                    type: string
                                    format: uri
                                videoUrls:
                                  type: array
                                  items:
                                    type: string
                                    format: uri
                                cards:
                                  type: array
                                  items:
                                    type: object
                                    additionalProperties: false
                                    properties:
                                      text:
                                        type: string
                                      linkUrl:
                                        type: string
                                        format: uri
                                      linkTitle:
                                        type: string
                                      ctaText:
                                        type: string
                                      imageUrl:
                                        type: string
                                        format: uri
                                      videoUrl:
                                        type: string
                                        format: uri
                                    required: []
                                versions:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                categories:
                                  type: array
                                  items:
                                    type: string
                                paidBy:
                                  type: string
                                spendMin:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                spendMax:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                spendCurrency:
                                  type: string
                                  pattern: ^[A-Z]{3}$
                                  description: ISO 4217 currency code, e.g. USD.
                                impressionsMin:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                impressionsMax:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                reachMin:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                reachMax:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                countries:
                                  type: array
                                  items:
                                    type: string
                              required:
                                - adUrl
                                - isActive
                                - versions
                          cursor:
                            type: string
                        required: []
                      - type: object
                        additionalProperties: false
                        properties:
                          results:
                            type: array
                            items:
                              type: object
                              additionalProperties: false
                              properties:
                                adId:
                                  type: string
                                adUrl:
                                  type: string
                                  format: uri
                                advertiserId:
                                  type: string
                                advertiserName:
                                  type: string
                                advertiserUrl:
                                  type: string
                                  format: uri
                                domain:
                                  type: string
                                format:
                                  type: string
                                  enum:
                                    - text
                                    - image
                                    - video
                                    - unknown
                                firstShownAt:
                                  type: string
                                  format: date-time
                                  pattern: >-
                                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                                lastShownAt:
                                  type: string
                                  format: date-time
                                  pattern: >-
                                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                                daysShown:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                previewUrl:
                                  type: string
                                  format: uri
                                imageUrl:
                                  type: string
                                  format: uri
                              required:
                                - adUrl
                                - advertiserUrl
                                - format
                          totalMin:
                            type: integer
                            minimum: -9007199254740991
                            maximum: 9007199254740991
                          totalMax:
                            type: integer
                            minimum: -9007199254740991
                            maximum: 9007199254740991
                          cursor:
                            type: string
                        required: []
                      - type: object
                        additionalProperties: false
                        properties:
                          advertiserId:
                            type: string
                          advertiserName:
                            type: string
                          results:
                            type: array
                            items:
                              type: object
                              additionalProperties: false
                              properties:
                                adId:
                                  type: string
                                adUrl:
                                  type: string
                                  format: uri
                                advertiserName:
                                  type: string
                                headline:
                                  type: string
                                firstShownAt:
                                  type: string
                                  format: date-time
                                  pattern: >-
                                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                                lastShownAt:
                                  type: string
                                  format: date-time
                                  pattern: >-
                                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                                reachMin:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                reachMax:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                videoUrl:
                                  type: string
                                  format: uri
                                thumbnailUrl:
                                  type: string
                                  format: uri
                                imageUrls:
                                  type: array
                                  items:
                                    type: string
                                    format: uri
                              required:
                                - adUrl
                          total:
                            type: integer
                            minimum: -9007199254740991
                            maximum: 9007199254740991
                          cursor:
                            type: string
                        required: []
                      - type: object
                        additionalProperties: false
                        properties:
                          results:
                            type: array
                            items:
                              type: object
                              additionalProperties: false
                              properties:
                                adId:
                                  type: string
                                adUrl:
                                  type: string
                                  format: uri
                                creativeType:
                                  type: string
                                format:
                                  type: string
                                advertiserName:
                                  type: string
                                advertiserUrl:
                                  type: string
                                  format: uri
                                advertiserAvatarUrl:
                                  type: string
                                  format: uri
                                postedBy:
                                  type: string
                                text:
                                  type: string
                                headline:
                                  type: string
                                imageUrls:
                                  type: array
                                  items:
                                    type: string
                                    format: uri
                              required:
                                - adUrl
                          total:
                            type: integer
                            minimum: -9007199254740991
                            maximum: 9007199254740991
                          cursor:
                            type: string
                        required: []
                      - type: object
                        additionalProperties: false
                        properties:
                          results:
                            type: array
                            items:
                              type: object
                              additionalProperties: false
                              properties:
                                adId:
                                  type: string
                                advertiserId:
                                  type: string
                                advertiserName:
                                  type: string
                                headline:
                                  type: string
                                text:
                                  type: string
                                linkUrl:
                                  type: string
                                  format: uri
                                linkCaption:
                                  type: string
                                imageUrls:
                                  type: array
                                  items:
                                    type: string
                                    format: uri
                              required: []
                          total:
                            type: integer
                            minimum: -9007199254740991
                            maximum: 9007199254740991
                          cursor:
                            type: string
                        required: []
                      - type: object
                        additionalProperties: false
                        properties:
                          results:
                            type: array
                            items:
                              type: object
                              additionalProperties: false
                              properties:
                                adId:
                                  type: string
                                adUrl:
                                  type: string
                                  format: uri
                                headline:
                                  type: string
                                text:
                                  type: string
                                advertisers:
                                  type: array
                                  items:
                                    type: string
                                imageUrl:
                                  type: string
                                  format: uri
                                videoUrl:
                                  type: string
                                  format: uri
                                links:
                                  type: array
                                  items:
                                    type: string
                                    format: uri
                                firstShownAt:
                                  type: string
                                  format: date-time
                                  pattern: >-
                                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                                lastShownAt:
                                  type: string
                                  format: date-time
                                  pattern: >-
                                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                                reachMin:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                reachMax:
                                  type: integer
                                  minimum: -9007199254740991
                                  maximum: 9007199254740991
                                reachByCountry:
                                  type: array
                                  items:
                                    type: object
                                    additionalProperties: false
                                    properties:
                                      country:
                                        type: string
                                      reachMin:
                                        type: integer
                                        minimum: -9007199254740991
                                        maximum: 9007199254740991
                                      reachMax:
                                        type: integer
                                        minimum: -9007199254740991
                                        maximum: 9007199254740991
                                    required: []
                                countries:
                                  type: array
                                  items:
                                    type: string
                                ageRanges:
                                  type: array
                                  items:
                                    type: string
                                genders:
                                  type: array
                                  items:
                                    type: string
                                interests:
                                  type: array
                                  items:
                                    type: string
                                audienceTypes:
                                  type: array
                                  items:
                                    type: string
                                isCommercial:
                                  type: boolean
                              required:
                                - adUrl
                                - isCommercial
                          cursor:
                            type: string
                        required: []
                  creditsUsed:
                    type: integer
                  requestId:
                    type: string
        4XX:
          $ref: '#/components/responses/Error'
        5XX:
          $ref: '#/components/responses/Error'
components:
  headers:
    RequestId:
      description: The request id. Quote it when you report a problem.
      schema:
        type: string
    CreditsUsed:
      description: Credits this call used.
      schema:
        type: integer
    RateLimitLimit:
      description: Requests allowed in the current window.
      schema:
        type: integer
    RateLimitRemaining:
      description: Requests left in the current window.
      schema:
        type: integer
    RateLimitReset:
      description: Unix time in seconds when the current window resets.
      schema:
        type: integer
    Cache:
      description: hit if this result came from the cache, miss if it was fetched live.
      schema:
        type: string
    CacheAge:
      description: Seconds since the returned result was written to the cache.
      schema:
        type: integer
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  responses:
    Error:
      description: The request failed. retryable says whether trying again can help.
      headers:
        X-Request-ID:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - success
        - error
      properties:
        success:
          const: false
        error:
          type: object
          required:
            - code
            - message
            - retryable
            - requestId
          properties:
            code:
              type: string
              enum:
                - agentCodeCompleted
                - agentCodeNotFound
                - agentEmailMismatch
                - cliSessionCompleted
                - cliSessionExists
                - cliSessionNotFound
                - forbidden
                - insufficientCredits
                - internalError
                - invalidCliSession
                - invalidCliVerifier
                - invalidRequest
                - notFound
                - rateLimited
                - sourceChanged
                - sourceRefused
                - sourceTimeout
                - sourceUnavailable
                - tooManyInFlight
                - unauthorized
                - unsupportedMediaType
            message:
              type: string
            retryable:
              type: boolean
            retryAfterSeconds:
              type: integer
            requestId:
              type: string
            requiredCredits:
              type: number
            availableCredits:
              type: number
            billingUrl:
              type: string
              const: https://stophy.dev/billing
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````