get_ads_by_adaccount
Retrieve ads from a specific Facebook ad account with filtering, pagination, and custom field selection. Query by account ID, status, date range, and more to get the ad data you need.
Instructions
Retrieves ads from a specific Facebook ad account.
This function allows querying all ads belonging to a specific ad account with various filtering options, pagination, and field selection.
Args: act_id (str): The ID of the ad account to retrieve ads from, prefixed with 'act_', e.g., 'act_1234567890'. fields (Optional[List[str]]): A list of specific fields to retrieve for each ad. If None, a default set of fields will be returned. Common fields include: - 'id': The ad's ID - 'name': The ad's name - 'adset_id': The ID of the ad set this ad belongs to - 'campaign_id': The ID of the campaign this ad belongs to - 'creative': The ad creative details - 'status': The current status of the ad - 'effective_status': The effective status including review status - 'bid_amount': The bid amount for this ad - 'configured_status': The configured status - 'created_time': When the ad was created - 'updated_time': When the ad was last updated - 'targeting': Targeting criteria - 'conversion_specs': Conversion specs - 'recommendations': Recommendations for improving the ad - 'preview_shareable_link': Link for previewing the ad filtering (Optional[List[dict]]): A list of filter objects to apply to the data. Each object should have 'field', 'operator', and 'value' keys. limit (Optional[int]): Maximum number of ads to return per page. Default is 25. after (Optional[str]): Pagination cursor for the next page. From response['paging']['cursors']['after']. before (Optional[str]): Pagination cursor for the previous page. From response['paging']['cursors']['before']. date_preset (Optional[str]): A predefined relative date range for selecting ads. Options include 'today', 'yesterday', 'this_week', etc. time_range (Optional[Dict[str, str]]): A custom time range with 'since' and 'until' dates in 'YYYY-MM-DD' format. updated_since (Optional[int]): Return ads that have been updated since this Unix timestamp. effective_status (Optional[List[str]]): Filter ads by their effective status. Options include: 'ACTIVE', 'PAUSED', 'DELETED', 'PENDING_REVIEW', 'DISAPPROVED', 'PREAPPROVED', 'PENDING_BILLING_INFO', 'CAMPAIGN_PAUSED', 'ARCHIVED', 'ADSET_PAUSED', 'IN_PROCESS', 'WITH_ISSUES'.
Returns: Dict: A dictionary containing the requested ads. The main results are in the 'data' list, and pagination info is in the 'paging' object.
Example: ```python # Get active ads from an ad account ads = get_ads_by_adaccount( act_id="act_123456789", fields=["name", "adset_id", "campaign_id", "effective_status", "created_time"], effective_status=["ACTIVE"], limit=50 )
# Fetch the next page if available using the pagination cursor
next_page_cursor = ads.get("paging", {}).get("cursors", {}).get("after")
if next_page_cursor:
next_page = get_ads_by_adaccount(
act_id="act_123456789",
fields=["name", "adset_id", "campaign_id", "effective_status", "created_time"],
effective_status=["ACTIVE"],
limit=50,
after=next_page_cursor
)
```
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | No | ||
| limit | No | ||
| act_id | Yes | ||
| before | No | ||
| fields | No | ||
| filtering | No | ||
| time_range | No | ||
| date_preset | No | ||
| updated_since | No | ||
| effective_status | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |