> **For coding agents and LLMs:** This is one page from the Social Fetch docs (markdown export). The sections below mirror the orientation block in [`/llms.txt`](https://www.socialfetch.dev/llms.txt); use [`/llms.json`](https://www.socialfetch.dev/llms.json) when you need a structured operation inventory. The catalog covers documented operations with on-site reference pages.

## This page

- **On-site (HTML):** [https://www.socialfetch.dev/docs/api/v1/facebook/ad-library/companies/search/get](https://www.socialfetch.dev/docs/api/v1/facebook/ad-library/companies/search/get)
- **Markdown (.mdx) URL:** [https://www.socialfetch.dev/docs/api/v1/facebook/ad-library/companies/search/get.mdx](https://www.socialfetch.dev/docs/api/v1/facebook/ad-library/companies/search/get.mdx)

## API base URL and authentication

- **API origin (from OpenAPI `servers`):** `https://api.socialfetch.dev`
- **Authentication:** send `x-api-key: sfk_...` on `/v1/**` routes unless the operation is explicitly anonymous (check OpenAPI `security`, the [API reference hub](https://www.socialfetch.dev/docs/api.mdx), [`/llms.txt`](https://www.socialfetch.dev/llms.txt), or [`/llms.json`](https://www.socialfetch.dev/llms.json) for each route).
- **OpenAPI JSON:** [https://www.socialfetch.dev/openapi.json](https://www.socialfetch.dev/openapi.json)

## Recommended docs entrypoints (this site)

- [Documentation overview](https://www.socialfetch.dev/docs.mdx) — top-level orientation (markdown).
- [Quickstart](https://www.socialfetch.dev/docs/quickstart.mdx) — authenticate with `x-api-key`, validate auth with `whoami`, and understand the JSON envelope.
- [SDK](https://www.socialfetch.dev/docs/sdk.mdx) — official TypeScript SDK guide, including `SocialFetchClient`, `Result`, and `unwrap()`.
- [SDK reference](https://www.socialfetch.dev/docs/sdk-reference.mdx) — exhaustive SDK method inventory and route mapping for agents, tooling, and power users.
- [Choose the right endpoint](https://www.socialfetch.dev/docs/choose-endpoint.mdx) — task-oriented route selection for smoke tests, profiles, list endpoints, and single-item lookups.
- [Capability matrix](https://www.socialfetch.dev/docs/capability-matrix.mdx) — fast comparison of identifiers, pagination, outcomes, media download, and SDK coverage.
- [`/llms.json`](https://www.socialfetch.dev/llms.json) — structured machine-readable operation inventory with parameter names, pagination, outcomes, credits, and SDK mapping.
- [API reference hub](https://www.socialfetch.dev/docs/api.mdx) — human-friendly index of operations with links into generated pages.
- [Errors](https://www.socialfetch.dev/docs/errors.mdx) — shared error envelope and HTTP status guidance.
- [Credits](https://www.socialfetch.dev/docs/credits.mdx) — metering, `402`, and planning batch jobs.
- Outcome semantics such as `found`, `not_found`, and `private` are documented in [Errors](https://www.socialfetch.dev/docs/errors.mdx) and on operation pages when present in the OpenAPI contract.

## Markdown docs convention

- Every docs page has a markdown twin: append **`.mdx`** to the docs pathname (for example `/docs/quickstart` → `/docs/quickstart.mdx`).
- Agents that send `Accept: text/markdown` on `/docs/**` HTML URLs may receive markdown directly (same URL, `Vary: Accept`).

---
# Search Facebook ad library companies (https://www.socialfetch.dev/docs/api/v1/facebook/ad-library/companies/search/get)

## Summary

Search Facebook ad library companies by name.

**Tags:** `Facebook`

## HTTP

- **Method:** GET
- **Path:** `/v1/facebook/ad-library/companies/search`
- **Base URL:** `https://api.socialfetch.dev`

## Capability summary

- **SDK mapping:** `client.facebook.searchAdLibraryCompanies({ query })`
- **Pagination:** none

## Credits

- **Base:** 1 credit per successful lookup.
- **Maximum on success (200):** 1 credit.
- **Normalization failure (502):** 1 credit charged.
- **Authoritative field:** `meta.creditsCharged`.

## Authentication

- **`x-api-key`**: API key (`sfk_...`)

## Parameters

### `query` (query)

- **Required:** yes
- **Constraints:** type `string`; minLength: 1; maxLength: 512
- **Description:** Search query text for Facebook ad library companies.

## Responses (status codes)

- **200**: Company search results for the requested query.
- **400**: Invalid query parameters
- **401**: Missing or invalid API key
- **402**: Insufficient credits
- **500**: Unexpected or billing error
- **502**: Lookup could not be completed from the response (unexpected or invalid data).
- **503**: Service temporarily unavailable; safe to retry with backoff.

## Response body (200)

Company search results for the requested query.

### Field outline

- **data** (required) — type `object`. Endpoint-specific response payload.
  - **query** (required) — type `string`. Search query that was evaluated for this response.
  - **companies** (required) — type `array`. Companies returned for the search query.
    - _items:_
      - **platform** (required) — type `string`; enum: facebook. Social platform for this company result.
      - **pageId** (required) — type `string`; minLength: 1. Facebook page id for use with other ad library endpoints.
      - **name** (required) — type `string`; minLength: 1. Company or page name.
      - **category** (required) — type `string`; nullable. Page category label when available.
      - **imageUrl** (required) — type `string`; nullable. Profile image URL when available.
      - **likes** (required) — type `integer`; minimum: 0; nullable. Page like count when available.
      - **verification** (required) — type `string`; nullable. Verification status label when available.
      - **country** (required) — type `string`; nullable. Country associated with the page when available.
      - **entityType** (required) — type `string`; nullable. Entity type reported for the page when available.
      - **pageAlias** (required) — type `string`; nullable. Public page alias or username when available.
      - **pageDeleted** (required) — type `boolean`; nullable. Whether the page is marked as deleted when reported.
      - **instagram** (required) — type `object`. Linked Instagram details when available.
        - **username** (required) — type `string`; nullable. Linked Instagram username when available.
        - **followers** (required) — type `integer`; minimum: 0; nullable. Linked Instagram follower count when available.
        - **verified** (required) — type `boolean`; nullable. Whether the linked Instagram account is verified.
  - **totalCompanies** (required) — type `integer`; minimum: 0. Number of companies returned in this response.
- **meta** (required) — type `object`. Metadata describing the request and billing outcome.
  - **requestId** (required) — type `string`; minLength: 1. Unique request identifier for tracing this API call.
  - **creditsCharged** (required) — type `integer`; minimum: 0. Credits charged for this request.
  - **version** (required) — type `string`; enum: v1. Public API version that served the response.

### Example JSON (results)

```json
{
  "data": {
    "query": "nike",
    "companies": [
      {
        "platform": "facebook",
        "pageId": "15087023444",
        "name": "Nike",
        "category": "Sportswear Store",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/284964043_10159903868513445_7696353984967674128_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=1&ccb=1-7&_nc_sid=418b77&_nc_ohc=MiIsRq9OtIgQ7kNvwFgCp6a&_nc_oc=AdrXoklhItyWvS7gYnP-xTbs9w35g-Zev7ZQrqGOdJx0XFHnJajR5gWpwJAjTACjSC8&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af4JfJ7GXcjJfD73EzCRIweoZ1DcMFjFVMJaguf7-UxWyA&oe=6A136F70",
        "likes": 39651323,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "nike",
        "pageDeleted": false,
        "instagram": {
          "username": "nike",
          "followers": 292091915,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "51212153078",
        "name": "Nike Football",
        "category": "Product/service",
        "imageUrl": "https://scontent-sea5-1.xx.fbcdn.net/v/t39.30808-1/387181570_863325755161415_3589774989337788111_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=103&ccb=1-7&_nc_sid=418b77&_nc_ohc=sN-QY749hScQ7kNvwERPNzg&_nc_oc=Adr-ZWflDPtXfKZY9u0PCuR_SMegkZkfHNkVqCPwX_LJ0EjC_04-rUj2wvo6pxaDrEQ&_nc_zt=24&_nc_ht=scontent-sea5-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af7xAAZ1i9TOZOfYpYIfGX_ZAqVANozGqDRSe5nxuSObuA&oe=6A133F05",
        "likes": 40289396,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "nikefootball",
        "pageDeleted": false,
        "instagram": {
          "username": "nikefootball",
          "followers": 44531917,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "65604112975",
        "name": "Nike Run Club",
        "category": "Sports & Recreation Venue",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/381660358_828089658776016_1921906525565601948_n.png?stp=dst-png_s200x200&_nc_cat=1&ccb=1-7&_nc_sid=418b77&_nc_ohc=a7GstbZ0h1IQ7kNvwEFinJQ&_nc_oc=AdpIYlJXBsbnsm2DvwQK8BrlJLZw1M_qEVcbKSkPVrvSJ2S_ohkRCGgdBgGUYFI-pzk&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af4NhpUn247aaa_lMj5ZxTWUBM-R1xrs7BHiVl_PbBDo3Q&oe=6A135DAA",
        "likes": 15389635,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "nikerunning",
        "pageDeleted": false,
        "instagram": {
          "username": "nikerunning",
          "followers": 6159794,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "20825389113",
        "name": "Nike Sportswear",
        "category": "Product/service",
        "imageUrl": "https://scontent-sea5-1.xx.fbcdn.net/v/t39.30808-1/352238800_1378999996006774_4240209247781423917_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=103&ccb=1-7&_nc_sid=418b77&_nc_ohc=PDgiTeeaToMQ7kNvwFUpfX_&_nc_oc=AdoPVng7k1O1D9dkg1C7mPtwnCosnArc173w1RKXhmrynh8cwdqxw7lha_6kwv8A8mw&_nc_zt=24&_nc_ht=scontent-sea5-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af55HGXPrMqpa8FtVemYSE9Bc9rQGVY9B4N-QSMfbSKS_A&oe=6A136F5F",
        "likes": 15607617,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "nikesportswear",
        "pageDeleted": false,
        "instagram": {
          "username": "nikesportswear",
          "followers": 7649375,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "5941596308",
        "name": "Nike Basketball",
        "category": "Product/service",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/352779693_291587943296654_5195981052627043005_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=106&ccb=1-7&_nc_sid=418b77&_nc_ohc=JfQ2Z6FsYZMQ7kNvwHGw5Pd&_nc_oc=AdridIF5njuV4TCjkA6_6TUSvbMTN4-qX2WQ0qvAD2oeTJdOtKSoMDCcFF2uEREgyHk&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af4x8j3beeQuxg5NCbTGjnkmM6UEaTrtd2YiyLPHP49Zcw&oe=6A136412",
        "likes": 7596493,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "nikebasketball",
        "pageDeleted": false,
        "instagram": {
          "username": "nikebasketball",
          "followers": 15598428,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "108379289247689",
        "name": "Nike Skateboarding",
        "category": "Product/service",
        "imageUrl": "https://scontent-sea5-1.xx.fbcdn.net/v/t39.30808-1/352706208_1588401181639202_901415604300420876_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=110&ccb=1-7&_nc_sid=418b77&_nc_ohc=8b2tKLriJowQ7kNvwGZJOrS&_nc_oc=AdoikV4vVmgkKWXefcxwXA0yRtHNnO_5SfMhIhEHr_dNTaGjbq7o880Red3M-7Mr_cQ&_nc_zt=24&_nc_ht=scontent-sea5-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af5bIb5k2gN1n0kEbr4ysr416Qqo40TXOuJEYtleAJ-iZQ&oe=6A133C00",
        "likes": 8565227,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "NikeSkateboarding",
        "pageDeleted": false,
        "instagram": {
          "username": "nikesb",
          "followers": 6522898,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "6261664682",
        "name": "NikeWomen",
        "category": "Product/service",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/360155777_843020267183742_6325909005771886494_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=106&ccb=1-7&_nc_sid=418b77&_nc_ohc=jotiXAWViJ0Q7kNvwEpgokd&_nc_oc=AdrleSk6nuEJ2SSrw-BINO289yD5AXG5aICvcnO0ktTPZjzJZF60hGxmQ1e8zV2OMDQ&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af4Wo3XwCbwTLZZnclDFHMoBfnxiIhZIP48r2ySwAQujJg&oe=6A133D4E",
        "likes": 5469288,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "nikewomen",
        "pageDeleted": false,
        "instagram": {
          "username": "nikewomen",
          "followers": 6801362,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "128198963716100",
        "name": "Nike Strength",
        "category": "Brand",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/387074276_122113082780063867_240960197833276102_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=104&ccb=1-7&_nc_sid=418b77&_nc_ohc=4OzVCLrKQ18Q7kNvwHHSlR3&_nc_oc=AdpQIA0x1rMOiHlhy_21rdhQt-yvxBYxypD_koWOdq2GyZqETipTECrdLIO0MMbqOVQ&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af6P_ei7GNoQpZx5IIBGu2BZcXZpYhfcuMLILUBDpKXnRA&oe=6A135153",
        "likes": 11911,
        "verification": "NOT_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "nikestrength",
        "pageDeleted": false,
        "instagram": {
          "username": "nikestrength",
          "followers": 237633,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "1461718484118285",
        "name": "Niké je tipovanie",
        "category": "Interest",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/341111328_738870064578442_1225960234040314537_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=100&ccb=1-7&_nc_sid=418b77&_nc_ohc=kN8dqNq-tE0Q7kNvwF4RPje&_nc_oc=AdqSe6LPwuX8z-oPQSFmfl4NdrLFNCYQYVkCF1qx0Jon1iNHKb3ehTh8tEq6inBmz3s&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af6ZagiZJoMQGi7O_u1SawjcFh325MePsGe36zpATQ86lQ&oe=6A136FB0",
        "likes": 99477,
        "verification": "NOT_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "NIKEjetipovanie",
        "pageDeleted": false,
        "instagram": {
          "username": null,
          "followers": null,
          "verified": null
        }
      },
      {
        "platform": "facebook",
        "pageId": "57460905720",
        "name": "Nike Football",
        "category": "Retail Company",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/352241125_115307234918826_7034162321122119580_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=100&ccb=1-7&_nc_sid=418b77&_nc_ohc=2DtU1XbmIsgQ7kNvwEWOURK&_nc_oc=AdrkelCwgql3YSwJ7DyeSTEJ6Yit21DSoKP5RsMhWVbmxnZsYTnv7ozl9IqUeSDOY-Q&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af49yXhVXsLQo_wF8Dj7WN0l4rUB_1QtcN_SIRPeg7G67g&oe=6A136E54",
        "likes": 5887624,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "usnikefootball",
        "pageDeleted": false,
        "instagram": {
          "username": "usnikefootball",
          "followers": 2237600,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "1957446251204909",
        "name": "Nikema Williams",
        "category": "Politician",
        "imageUrl": "https://scontent-sea5-1.xx.fbcdn.net/v/t39.30808-1/263004090_404760094355264_2047193406290386818_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=107&ccb=1-7&_nc_sid=418b77&_nc_ohc=_zVdoTWH8L0Q7kNvwEVCjfU&_nc_oc=Adq8jDOBnLszYCJQUdAz1pNP802_WFApXEJ3nJqbeDLamFL4rrQwPogEKHqetpGWAoE&_nc_zt=24&_nc_ht=scontent-sea5-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af4JzrvFmi7g7_XPrUloiwouXsxsF3ticKFXIgOvHTRhHA&oe=6A133D30",
        "likes": 13193,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "NikemaforCongress",
        "pageDeleted": false,
        "instagram": {
          "username": null,
          "followers": null,
          "verified": null
        }
      },
      {
        "platform": "facebook",
        "pageId": "682288964969542",
        "name": "Nike Product Testers",
        "category": "Apparel & Clothing",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/511193282_10160755385761783_9018986867387327551_n.jpg?stp=dst-jpg_p200x200_tt6&_nc_cat=104&ccb=1-7&_nc_sid=418b77&_nc_ohc=DEm8pUuMRoIQ7kNvwEsq02k&_nc_oc=Adre5PhnXySnvIOIASm0dW6PEwYguYT3SMo_SypOGPFYYFN6-P9g0OernJ2BmbyuKOo&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af43WWGy-28uLV1ernBysuNWncTIT_r21gjbYu8h7DoXSA&oe=6A136FD7",
        "likes": 5810,
        "verification": "NOT_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": null,
        "pageDeleted": false,
        "instagram": {
          "username": null,
          "followers": null,
          "verified": null
        }
      },
      {
        "platform": "facebook",
        "pageId": "276907439024459",
        "name": "Nike Japan (ナイキ)",
        "category": "Retail Company",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/351525976_226734210145102_5521153730850946611_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=1&ccb=1-7&_nc_sid=418b77&_nc_ohc=5YSkaOG1XVYQ7kNvwHLunjh&_nc_oc=AdrOli4Dc4OWM6Pc57LEvXPZCACYYeIrCPW2T-IopFT9z7JU05Vt-SGNM8YEuXan7Ik&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af6_DpacjK4C38ORqMkqctnpQvKrHyAk2CPaqi34mtKsKw&oe=6A1348ED",
        "likes": 310870,
        "verification": "BLUE_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "nikejapan",
        "pageDeleted": false,
        "instagram": {
          "username": "niketokyo",
          "followers": 565981,
          "verified": true
        }
      },
      {
        "platform": "facebook",
        "pageId": "319786157889879",
        "name": "US Sports Camps - NIKE Sports Camps",
        "category": "Sports & Recreation Venue",
        "imageUrl": "https://scontent-sea5-1.xx.fbcdn.net/v/t39.30808-1/558050782_122206770398343145_1567215682791490112_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=109&ccb=1-7&_nc_sid=418b77&_nc_ohc=AQgxHs0Qgh8Q7kNvwH46SrX&_nc_oc=AdqqCFXZnxABd6H3qnlQ1PI7Lsk-EMA8CA5l1EYAaYqWFv5iBgBsEqsZMZ_HbLc5kJQ&_nc_zt=24&_nc_ht=scontent-sea5-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af6dVMEEFrn6IeFJ-YgPxy-cBFjHnwCyPsy0sz1qE0ehXQ&oe=6A1352BF",
        "likes": 9832,
        "verification": "NOT_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "ussportscamps",
        "pageDeleted": false,
        "instagram": {
          "username": "ussportscamps",
          "followers": 20285,
          "verified": false
        }
      },
      {
        "platform": "facebook",
        "pageId": "112856680258791",
        "name": "Niké Kasíno",
        "category": "Casino",
        "imageUrl": "https://scontent-sea1-1.xx.fbcdn.net/v/t39.30808-1/452564838_1004892101644091_1489770994966080016_n.jpg?stp=dst-jpg_s200x200_tt6&_nc_cat=100&ccb=1-7&_nc_sid=418b77&_nc_ohc=Ax03zAjZW2IQ7kNvwHUt8Ic&_nc_oc=Adrcp5Vu9dFApbJ-MiBZiLLnsSh-fWTjYERSqDxDSTd7teaqw8okSpCS5bEFRj1kegc&_nc_zt=24&_nc_ht=scontent-sea1-1.xx&_nc_gid=L7LRVTkiKt_29Ewfz1O2-w&_nc_ss=70289&oh=00_Af7lG7O3jIivavvf-Q-jobnytAthSBQza14lmSDH2VQT-w&oe=6A136F5A",
        "likes": 19662,
        "verification": "NOT_VERIFIED",
        "country": null,
        "entityType": "PERSON_PROFILE",
        "pageAlias": "NikeKasino",
        "pageDeleted": false,
        "instagram": {
          "username": "nike_kasino",
          "followers": 1504,
          "verified": false
        }
      }
    ],
    "totalCompanies": 15
  },
  "meta": {
    "requestId": "req_01example",
    "creditsCharged": 1,
    "version": "v1"
  }
}
```

### Example JSON (empty)

```json
{
  "data": {
    "query": "zzzxxyyqqnomatchfixture999",
    "companies": [],
    "totalCompanies": 0
  },
  "meta": {
    "requestId": "req_01example_empty",
    "creditsCharged": 1,
    "version": "v1"
  }
}
```

### Machine-readable error codes

When an error JSON body is returned, it may include one of these `error.code` values (derived from the OpenAPI schemas for this operation; additional codes may exist at runtime):

- `bad_request`

## Error handling & retries

Interpret HTTP status codes using the descriptions below. Do not assume a JSON body unless the OpenAPI schema defines one for that status.

- **400**: Invalid query parameters **Retry:** Fix the request; retrying the same invalid payload will not help.
- **401**: Missing or invalid API key **Retry:** Fix the API key first; retrying without changes will not help.
- **402**: Insufficient credits **Retry:** Do not retry without resolving billing/credits (retrying the same request will not help).
- **500**: Unexpected or billing error
- **502**: Lookup could not be completed from the response (unexpected or invalid data). **Retry:** May be transient; a few retries with backoff are reasonable.
- **503**: Service temporarily unavailable; safe to retry with backoff. **Retry:** Usually safe to retry with exponential backoff and jitter.

### Suggested client defaults

- Send the API key using the `x-api-key` header on every request.
- On `503` (and sometimes `502`), retry with backoff; cap retries and surface a clear error to the user.
- On `402`, surface an actionable billing message rather than blind retries.

## Examples

### TypeScript SDK

```typescript
import { SocialFetchClient } from "@socialfetch/sdk";

const client = new SocialFetchClient({
  apiKey: process.env.SOCIALFETCH_API_KEY!,
});

const result = await client.facebook.searchAdLibraryCompanies({
  query: "value",
});

if (!result.ok) {
  console.error(result.error);
} else {
  console.log(result.value.data);
}
```

### Node.js

```javascript
const response = await fetch(
  "https://api.socialfetch.dev/v1/facebook/ad-library/companies/search?query=value",
  {
    headers: {
      "x-api-key": "YOUR_API_KEY",
    }
  }
);

const data = await response.json();
console.log(data);
```

### cURL

```bash
curl "https://api.socialfetch.dev/v1/facebook/ad-library/companies/search?query=value" \
  -H "x-api-key: YOUR_API_KEY"
```

### Python

```python
import requests

response = requests.get(
    "https://api.socialfetch.dev/v1/facebook/ad-library/companies/search?query=value",
    headers={"x-api-key": "YOUR_API_KEY"},
)
data = response.json()
print(data)
```