# Migrate from Apify (Meta and Yelp ads actors)

> Move Apify Facebook Ads Library and Yelp actor runs to /v1/ads/meta and /v1/ads/yelp, with input and output field mapping.

`POST /v1/ads/meta` and `POST /v1/ads/yelp` take an Apify actor's input JSON as the request body and return the dataset items as a JSON array, like Apify's run-sync-get-dataset-items call. There's no run to start, poll or fetch a dataset from.

> **Note:** Beta: both parsers were written from public documentation and haven't been checked against a live response yet.

## 1. Change the call

| | Apify | DataForGAIO |
|---|---|---|
| URL | `https://api.apify.com/v2/acts/<actor>/run-sync-get-dataset-items` | `https://api.dataforgaio.com/v1/ads/meta` or `/v1/ads/yelp` |
| Auth | Apify token | Your `dg_` key: Bearer, `X-API-Key` or Basic |
| Body | Actor input JSON | The same input JSON |
| Response | JSON array of dataset items | JSON array of dataset items, each with `receipt_id` |

## 2. Meta ads

### Input

Field names from the popular Facebook Ads Library actors are accepted:

| Field | Aliases | Notes |
|---|---|---|
| `startUrls` | `urls` | `[{"url": ...}]` or strings. Ad Library URLs (`facebook.com/ads/library/?q=...&country=..&ad_type=..&active_status=..`, `view_all_page_id=...`, `id=...`), or a Facebook Page URL, which is searched by the page name. |
| `searchTerms` | `searchTerm`, `search_terms` | A keyword or a list of keywords. |
| `country` | `countryCode`, `scrapePageAds.countryCode` | ISO-2 code or `ALL` (default). |
| `adType` | `ad_type` | `ALL` (default) or `POLITICAL_AND_ISSUE_ADS`. |
| `activeStatus` | `scrapePageAds.activeStatus` | `active`, `inactive` or `all` (default). |
| `resultsLimit` | `count`, `maxItems` | Total ads, 1 to 5,000, default 100. |
| `limitPerSource` | | Ads per URL or search term. |

Send at least one `startUrls` entry or search term.



```bash title="cURL"
curl -X POST "https://api.dataforgaio.com/v1/ads/meta" \
  -H "Authorization: Bearer $DATAFORGAIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "searchTerms": ["trail running shoes"],
    "country": "DE",
    "activeStatus": "active",
    "resultsLimit": 50
  }'
```

```python title="Python"
import os
import requests

res = requests.post(
    "https://api.dataforgaio.com/v1/ads/meta",
    headers={"Authorization": f"Bearer {os.environ['DATAFORGAIO_API_KEY']}"},
    json={"searchTerms": ["trail running shoes"], "country": "DE", "activeStatus": "active", "resultsLimit": 50},
    timeout=120,
)
ads = res.json()
for ad in ads:
    print(ad["adArchiveID"], ad["pageName"], ad["isActive"], ad["snapshot"]["body"]["text"])
print("receipt:", res.headers.get("X-Receipt-Id"))
```



### Output

Items follow the `apify/facebook-ads-scraper` item shape:

| Field | Notes |
|---|---|
| `adArchiveID` / `adArchiveId` | The Ad Library id (both spellings). |
| `pageID` / `pageId`, `pageName` | The advertiser's page. |
| `isActive`, `startDate`, `endDate`, `startDateFormatted`, `endDateFormatted` | Delivery dates as Unix seconds and formatted strings. |
| `publisherPlatform` | `["FACEBOOK", "INSTAGRAM", ...]` |
| `currency`, `spend`, `impressionsWithIndex.range`, `reachEstimate` | Filled where the Ad Library publishes them (EU-delivered and political or issue ads). |
| `snapshot` | `pageName`, `byline`, `body.text`, `title`, `caption`, `linkDescription`, plus `images`, `videos`, `cards`, `ctaText`, which may be empty. |
| `categories` | `["POLITICAL"]` for political and issue ads. |
| `targetedOrReachedCountries`, `inputUrl`, `url` | |
| `receipt_id` | Ours, on every item. |

`adId`, `collationCount` and `collationId` are `null`.

Coverage: every ad delivered in the EU, and political or issue ads anywhere, come from the Ad Library's full records. Other ads come from the first page of public Ad Library results for each source, with fewer fields filled.

## 3. Yelp ads

### Input

| Field | Aliases | Notes |
|---|---|---|
| `searchTerms` | `search_terms`, `searchTerm` | Each term runs in each location. |
| `locations` | `location` | Required with `searchTerms`, e.g. `"Austin, TX"`. |
| `directUrls` | `startUrls` | Yelp search URLs (`yelp.com/search?find_desc=...&find_loc=...`). Business pages aren't accepted. |
| `searchLimit` | | Results per search, 1 to 240, default 10. |

Up to 50 searches (terms × locations, plus direct URLs) per request.

```bash
curl -X POST "https://api.dataforgaio.com/v1/ads/yelp" \
  -H "Authorization: Bearer $DATAFORGAIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"searchTerms": ["plumber"], "locations": ["Austin, TX"], "searchLimit": 20}'
```

### Output

Items follow the common Yelp actor item: `name`, `bizId`, `directUrl`, `address` (`addressLine1` filled; the rest `null`), `neighborhoods`, `phone`, `aggregatedRating`, `reviewCount`, `priceRange`, `categories`, `primaryPhoto`, plus:

| Field | Meaning |
|---|---|
| `isAd`, `sponsored`, `advertiser` | `true` for paid placements. |
| `position` | Order on the results page, ads included. |
| `searchTerm`, `location` | The search that produced the row. |
| `scrapeStartedAt`, `scrapeFinishedAt` | ISO 8601 times for that search. |
| `receipt_id` | Ours. |

`website`, `type`, `cuisine`, `claimed`, `verified`, `images` and `alternateNames` are empty or `null`.

## 4. Pricing and errors

| Route | Price | Cache |
|---|---|---|
| `/v1/ads/meta` | $0.00018 per ad returned ($0.18 per 1,000) | 6 hours |
| `/v1/ads/yelp` | $0.00045 per result returned ($0.45 per 1,000), ads and organic rows alike | 6 hours |

- `max_cost` caps the number of items: `"max_cost": 0.009` on Yelp returns at most 20 results.
- `auto_upgrade`, `max_level` and `max_age` work as on other routes. Yelp usually needs a higher fetch level; the price per result doesn't change with the level.
- The response has no cost field. The charge is on the `receipt_id` (each item, and the `X-Receipt-Id` header) in **Dashboard → Billing**.
- Errors use Apify's body, `{"error": {"type", "message", "receipt_id"}}`, with HTTP 400 `invalid-input` (bad input, or no ads found), 401 `user-or-token-not-found`, 402 `not-enough-usage-to-run-paid-actor`, 429 `rate-limit-exceeded`, 500 `internal-error`. None are billed.

See [Meta Ad Library](https://dataforgaio.com/docs/api/ads-meta.md) and [Yelp Search Ads](https://dataforgaio.com/docs/api/ads-yelp.md) for every field.
