> ## Documentation Index
> Fetch the complete documentation index at: https://developer.moneyone.in/llms.txt
> Use this file to discover all available pages before exploring further.

# User Analytics API

> Retrieve user financial data and analytics from PFM service

## Overview

The User Analytics API retrieves comprehensive financial analytics and insights for a specific user based on their financial data. This API provides personalized financial metrics, spending patterns, investment analysis, and other PFM insights that can be displayed in your application interface.

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://api-uat.pfm.equal.in/pfm/user/analytics?fiType=ETF' \
  --header 'Content-Type: application/json' \
  --header 'authorization: eyJh...' \
  --data ''
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api-uat.pfm.equal.in/pfm/user/analytics?fiType=ETF', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'authorization': 'eyJh...'
    }
  });

  const data = await response.json();
  console.log('Analytics Data:', data);
  ```

  ```python Python theme={null}
  import requests

  url = "https://api-uat.pfm.equal.in/pfm/user/analytics"
  headers = {
      "Content-Type": "application/json",
      "authorization": "eyJh..."
  }
  params = {
      "fiType": "ETF"
  }

  response = requests.get(url, headers=headers, params=params)
  print(response.json())
  ```
</CodeGroup>

## Authentication

This API requires Bearer token authentication:

| Header          | Type   | Required | Description                                         |
| --------------- | ------ | -------- | --------------------------------------------------- |
| `authorization` | string | Yes      | Bearer token obtained from the SDK Init API session |
| `content-type`  | string | Yes      | Must be set to `application/json`                   |

## Query Parameters

| Parameter | Type   | Required | Description                                                                                                                                         |
| --------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `fiType`  | string | No       | Filter analytics by Financial Information type. Valid values are `DEPOSIT`, `MUTUAL_FUNDS`, `EQUITIES`, `TERM_DEPOSIT`, `RECURRING_DEPOSIT`, `ETF`. |

## Response

### Success Response (200 OK)

When the analytics data is successfully retrieved, the API returns comprehensive financial insights.

**Complete Response Examples**: For detailed response structures across all analytics types (ETF, Mutual Funds, Equities, Deposits, Term Deposits, Recurring Deposits), access our comprehensive response folder:

👉 **[View All Analytics Sample Response](https://drive.google.com/drive/folders/1PlodnsftfrEKebdGz-vIEv9RwhuVUqvd?usp=drive_link)**

**Basic Response Structure:**

```json theme={null}
{
  "status": "SUCCESS",
  "data": {
    // Analytics data specific to the requested fiType
    // Complete examples available in the drive folder above
  }
}
```

| Field    | Type   | Description                                                            |
| -------- | ------ | ---------------------------------------------------------------------- |
| `status` | string | Status of the API call. Will be `SUCCESS` for successful requests.     |
| `data`   | object | Analytics data containing financial insights and metrics for the user. |

### Error Responses (400 Bad Request / 404 Not Found)

When the request fails due to authentication or data issues, the API returns specific error responses:

<CodeGroup>
  ```json Invalid Session Token theme={null}
  {
    "status": "FAILED",
    "message": "Error in processing request, please retry after sometime",
    "status_code": "invalid_session_token"
  }
  ```

  ```json No Analytics Available theme={null}
  {
    "status": "FAILED",
    "message": "No analytics present for the user",
    "status_code": "no_analytics"
  }
  ```

  ```json Invalid FI Type theme={null}
  {
    "status": "FAILED",
    "message": "Invalid FI Type",
    "status_code": "invalid_fitype"
  }
  ```
</CodeGroup>

| Field         | Type   | Description                                                   |
| ------------- | ------ | ------------------------------------------------------------- |
| `status`      | string | Status of the API call. Will be `FAILED` for failed requests. |
| `message`     | string | Human-readable error message explaining what went wrong.      |
| `status_code` | string | Machine-readable error code for programmatic error handling.  |

## Error Handling

| Error Code              | HTTP Status     | Description                                                  | Resolution                                                                           |
| ----------------------- | --------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `invalid_session_token` | 400 Bad Request | The provided session token is invalid, expired, or malformed | Obtain a new session token using the SDK Init API                                    |
| `no_analytics`          | 404 Not Found   | No financial analytics data is available for the user        | Ensure the user has connected their financial accounts and data is available         |
| `invalid_fitype`        | 400 Bad Request | The provided `fiType` parameter value is not supported       | Use a valid FI type from the supported list (DEPOSIT, MUTUAL\_FUNDS, EQUITIES, etc.) |

## Supported FI Types

The `fiType` parameter accepts the following values:

| FI Type             | Description                        |
| ------------------- | ---------------------------------- |
| `DEPOSIT`           | Bank deposits and savings accounts |
| `MUTUAL_FUNDS`      | Mutual Fund investments            |
| `EQUITIES`          | Equity investments and stocks      |
| `TERM_DEPOSIT`      | Fixed/Term deposits                |
| `RECURRING_DEPOSIT` | Recurring deposit accounts         |
| `ETF`               | Exchange Traded Funds              |

## Next Steps

After successfully retrieving analytics data:

1. **Parse the Response**: Extract the analytics data and breakdown information for display in your application
2. **Handle Different FI Types**: Use the breakdown array to show category-wise analytics
3. **Implement Caching**: Consider caching analytics data to reduce API calls and improve performance
4. **Error Handling**: Implement proper error handling for token expiry and retry logic

## Security Considerations

* **Token Security**: Handle session tokens securely and avoid logging them
* **HTTPS Only**: Always use HTTPS when calling this API
* **Token Refresh**: Implement proper token refresh logic when tokens expire
* **Rate Limiting**: Be mindful of API rate limits and implement appropriate throttling
* **Encryption Support**: This API supports encryption. When encryption is enabled for your integration, both request and response payloads will be encrypted. See [API Encryption Guide](/pfm/api-encryption-overview) for details.
