# Store Ad Meta Ads Library In-depth Delivery Analysis API

## API Information

- **API Name**: Get Store Ad In-depth Delivery Analysis
- **Request Method**: POST
- **API Endpoint**: `/open-api/v1/data`
- **API Path**: `/v3/api/open/ppspy/pp-stores/analysis/delivery`
- **API Description**: Retrieve in-depth delivery analysis data for a specified store in the Meta Ads Library, including ad delivery distribution by day of week (Monday to Sunday) and by time period, to help analyze the store's ad delivery strategy and timing patterns
- **Pricing**: `Free`

**Request Headers:**

- Content-Type: application/json
- Accept: application/json

## Request Parameters

### Request Structure

| Parameter | Type   | Description                        | Example                                              | Required | Default |
| --------- | ------ | ---------------------------------- | ---------------------------------------------------- | -------- | ------- |
| key       | string | User's external API request key    | "your_api_key_here"                                  | Yes      |         |
| uri       | string | API path                           | "/v3/api/open/ppspy/pp-stores/analysis/delivery"     | Yes      |         |
| params    | object | API input parameter object         | See parameter list                                   | Yes      |         |

### Request Body Parameters (params object)

| Parameter | Type   | Required | Description                                                                                                                                               |
| --------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id        | String | Yes      | Store unique identifier ID, a 13-character string (e.g., `c2d5b2547218a`), corresponds to the `store_id` field in the store ranking list API response   |

### Request Example

```bash
curl -X POST "https://www.pipispy.com/open-api/v1/data" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "key": "your_api_key_here",
    "uri": "/v3/api/open/ppspy/pp-stores/analysis/delivery",
    "params": {
        "id": "c2d5b2547218a"
    }
  }'
```

## Response Parameters

### Response Body Structure

```json
{
  "code": 200,
  "message": "success",
  "data": {
    "daily": {},
    "time": {},
    "is_logged_in": false
  },
  "version": "v1",
  "timestamp": null,
  "sign": null,
  "remaining_credits": 9980,
  "consumed_credits": 0,
  "success": true,
  "fail": false
}
```

### Response Field Description

| Field     | Type    | Description                              |
| --------- | ------- | ---------------------------------------- |
| code      | Integer | Response status code, 200 means success  |
| message   | String  | Response message                         |
| data      | Object  | Response data                            |
| version   | String  | API version                              |
| timestamp | String  | Response timestamp                       |
| sign      | String  | Response signature                       |
| remaining_credits | Long    | Current remaining available credits after this request |
| consumed_credits  | Long    | Credits consumed by this request                       |
| success   | Boolean | Whether the request was successful       |
| fail      | Boolean | Whether the request failed               |

### In-depth Delivery Analysis Data Fields (data.data)

| Field        | Type    | Description                                                                                                                   |
| ------------ | ------- | ----------------------------------------------------------------------------------------------------------------------------- |
| daily        | Object  | Ad delivery analysis data by day of week, showing the store's ad delivery count and percentage for each day (Sunday to Saturday) |
| time         | Object  | Ad delivery analysis data by time period, showing the store's ad delivery count and percentage for different time periods in a day |
| is_logged_in | Boolean | Whether the user is logged in, used to identify data permission status                                                        |

### By Day of Week Statistics Fields (daily)

| Field  | Type   | Description                      |
| ------ | ------ | -------------------------------- |
| week_0 | Object | Sunday ad delivery data          |
| week_1 | Object | Monday ad delivery data          |
| week_2 | Object | Tuesday ad delivery data         |
| week_3 | Object | Wednesday ad delivery data       |
| week_4 | Object | Thursday ad delivery data        |
| week_5 | Object | Friday ad delivery data          |
| week_6 | Object | Saturday ad delivery data        |

Each week data object (WeekData) contains the following fields:

| Field      | Type   | Description                                                                                                         |
| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------- |
| ad_count   | Long   | Number of ads delivered on that day of the week                                                                     |
| percentage | Double | Percentage of ads delivered on that day of the week (0.0-1.0), represents the proportion of ads delivered on that day to total ads |

### By Time Period Statistics Fields (time)

| Field  | Type   | Description                                         |
| ------ | ------ | --------------------------------------------------- |
| time_1 | Object | 06:00-09:00 time period ad delivery data (morning)  |
| time_2 | Object | 09:00-12:00 time period ad delivery data (mid-morning) |
| time_3 | Object | 12:00-15:00 time period ad delivery data (noon)     |
| time_4 | Object | 15:00-18:00 time period ad delivery data (afternoon)|
| time_5 | Object | 18:00-21:00 time period ad delivery data (evening)  |
| time_6 | Object | 21:00-23:00 time period ad delivery data (night)    |
| time_7 | Object | 23:00-06:00 time period ad delivery data (late night)|

Each time period data object (TimeData) contains the following fields:

| Field      | Type   | Description                                                                                                                  |
| ---------- | ------ | ---------------------------------------------------------------------------------------------------------------------------- |
| ad_count   | Long   | Number of ads delivered during that time period                                                                              |
| percentage | Double | Percentage of ads delivered during that time period (0.0-1.0), represents the proportion of ads delivered during that time period to total ads |

## Response Example

```json
{
  "code": 200,
  "message": "success",
  "data": {
    "daily": {
      "week_0": {
        "ad_count": 125,
        "percentage": 0.142
      },
      "week_1": {
        "ad_count": 138,
        "percentage": 0.157
      },
      "week_2": {
        "ad_count": 145,
        "percentage": 0.165
      },
      "week_3": {
        "ad_count": 132,
        "percentage": 0.15
      },
      "week_4": {
        "ad_count": 128,
        "percentage": 0.146
      },
      "week_5": {
        "ad_count": 95,
        "percentage": 0.108
      },
      "week_6": {
        "ad_count": 117,
        "percentage": 0.133
      }
    },
    "time": {
      "time_1": {
        "ad_count": 85,
        "percentage": 0.097
      },
      "time_2": {
        "ad_count": 156,
        "percentage": 0.178
      },
      "time_3": {
        "ad_count": 142,
        "percentage": 0.162
      },
      "time_4": {
        "ad_count": 138,
        "percentage": 0.157
      },
      "time_5": {
        "ad_count": 165,
        "percentage": 0.188
      },
      "time_6": {
        "ad_count": 98,
        "percentage": 0.112
      },
      "time_7": {
        "ad_count": 96,
        "percentage": 0.109
      }
    },
    "is_logged_in": false
  },
  "version": "v1",
  "timestamp": null,
  "sign": null,
  "remaining_credits": 9980,
  "consumed_credits": 0,
  "success": true,
  "fail": false
}
```

## Error Code Description

| Error Code | Description               |
| ---------- | ------------------------- |
| 200        | Success                   |
| 400        | Invalid request parameters|
| 401        | Unauthorized              |
| 403        | Insufficient permissions  |
| 500        | Internal server error     |
