get_activities_by_adaccount
Track Facebook ad account changes by retrieving activity logs. Identify who modified budgets, campaigns, targeting, and audiences, with timestamps and details.
Instructions
Retrieves activities for a Facebook ad account.
This function accesses the Facebook Graph API to retrieve information about key updates to an ad account and ad objects associated with it. By default, this API returns one week's data. Information returned includes major account status changes, updates made to budget, campaign, targeting, audiences and more.
Args: act_id (str): The ID of the ad account, prefixed with 'act_', e.g., 'act_1234567890'. fields (Optional[List[str]]): A list of specific fields to retrieve. If None, all available fields will be returned. Available fields include: - 'actor_id': ID of the user who made the change - 'actor_name': Name of the user who made the change - 'application_id': ID of the application used to make the change - 'application_name': Name of the application used to make the change - 'changed_data': Details about what was changed in JSON format - 'date_time_in_timezone': The timestamp in the account's timezone - 'event_time': The timestamp of when the event occurred - 'event_type': The specific type of change that was made (numeric code) - 'extra_data': Additional data related to the change in JSON format - 'object_id': ID of the object that was changed (ad, campaign, etc.) - 'object_name': Name of the object that was changed - 'object_type': Type of object being modified, values include: 'AD', 'ADSET', 'CAMPAIGN', 'ACCOUNT', 'IMAGE', 'REPORT', etc. - 'translated_event_type': Human-readable description of the change made, examples include: 'ad created', 'campaign budget updated', 'targeting updated', 'ad status changed', etc. limit (Optional[int]): Maximum number of activities to return per page. Default behavior returns a server-determined number of results. after (Optional[str]): Pagination cursor for the next page of results. Obtained from the 'paging.cursors.after' field in the previous response. before (Optional[str]): Pagination cursor for the previous page of results. Obtained from the 'paging.cursors.before' field in the previous response. time_range (Optional[Dict[str, str]]): A custom time range with 'since' and 'until' dates in 'YYYY-MM-DD' format. Example: {'since': '2023-01-01', 'until': '2023-01-31'} This parameter overrides the since/until parameters if both are provided. since (Optional[str]): Start date in YYYY-MM-DD format. Defines the beginning of the time range for returned activities. Ignored if 'time_range' is provided. until (Optional[str]): End date in YYYY-MM-DD format. Defines the end of the time range for returned activities. Ignored if 'time_range' is provided.
Returns: Dict: A dictionary containing the requested activities. The main results are in the 'data' list, and pagination info is in the 'paging' object. Each activity object contains information about who made the change, what was changed, when it occurred, and the specific details of the change.
Example: ```python # Get recent activities for an ad account with default one week of data activities = get_activities_by_adaccount( act_id="act_123456789", fields=["event_time", "actor_name", "object_type", "translated_event_type"] )
# Get all activities from a specific date range
dated_activities = get_activities_by_adaccount(
act_id="act_123456789",
time_range={"since": "2023-01-01", "until": "2023-01-31"},
fields=["event_time", "actor_name", "object_type", "translated_event_type", "extra_data"]
)
# Paginate through activity results
paginated_activities = get_activities_by_adaccount(
act_id="act_123456789",
limit=50,
fields=["event_time", "actor_name", "object_type", "translated_event_type"]
)
# Get the next page using the cursor from the previous response
next_page_cursor = paginated_activities.get("paging", {}).get("cursors", {}).get("after")
if next_page_cursor:
next_page = get_activities_by_adaccount(
act_id="act_123456789",
fields=["event_time", "actor_name", "object_type", "translated_event_type"],
after=next_page_cursor
)
```
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | No | ||
| limit | No | ||
| since | No | ||
| until | No | ||
| act_id | Yes | ||
| before | No | ||
| fields | No | ||
| time_range | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |