# Get User Activity — Amplitude

> Fetch the event stream for a single user by their numeric Amplitude ID from the Amplitude Dashboard REST API. Each returned event defaults to just event_type and event_time; pass fields to also get e.g. event_properties, user_properties…

- Key: `amplitude-get-user-activity`
- Type: Action (Read-only)
- Version: 0.0.2
- App: Amplitude (`amplitude`) — https://pipedream.com/apps/amplitude.md
- This page (HTML): https://pipedream.com/apps/amplitude/actions/get-user-activity
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/amplitude/actions/get-user-activity/get-user-activity.mjs

## Description

Fetch the event stream for a single user by their numeric Amplitude ID from the Amplitude Dashboard REST API. Each returned event defaults to just event_type and event_time; pass `fields` to also get e.g. `event_properties`, `user_properties`, `uuid`, `session_id`, `amplitude_id`, `device_id` (event objects can carry many properties, so these stay opt-in). Amplitude's API caps each request at 1000 events with no cursor; this tool pages `offset` forward automatically to collect up to `limit` events (set it above 1000, up to 5000, to fetch more than one page). Use **Search Users** first to resolve the Amplitude ID. Example: call with `user=12345678`, `limit=50` -> returns `{events: [{event_type: "Purchase", event_time: "2024-08-05 14:22:10"}, ...], userData: {...}, truncated: false}` (`truncated: true` means more events likely exist beyond what was returned — raise `limit`/`offset` to fetch further). [See the documentation](https://amplitude.com/docs/apis/analytics/dashboard-rest#user-activity).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `user` | `integer` | Yes | The numeric Amplitude ID of the user (the user param). Example: 12345678. Use Search Users to resolve this from an email or User ID. |
| `offset` | `integer` | No | Zero-indexed starting offset into the event stream (the offset param). Min 0. Amplitude documents no upper bound — raise this to page further back into an already-fetched user's history. |
| `direction` | `string` | No | Chronological direction (the direction param). One of earliest, latest. Defaults to latest. |
| `limit` | `integer` | No | Maximum number of events to return in total (the limit param, requested in pages of up to 1000). Min 1, max 5000. Defaults to 1000. Set above 1000 to fetch more than one page; check the response's truncated flag to see if more events exist beyond what was returned. |
| `fields` | `string[]` | No | Field names to return for each event (event_type and event_time are always included). Also available: event_properties, user_properties, uuid, session_id, amplitude_id, device_id. Pass only what you need to keep responses small. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "amplitude",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "amplitude-get-user-activity",
  arguments: {
    user: 10,
    offset: 10,
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "amplitude-get-user-activity",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    amplitude: { authProvisionId: "apn_xxxxxxx" },
    user: 10,
    offset: 10,
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "amplitude-get-user-activity",
    "configured_props": {
      "amplitude": { "authProvisionId": "apn_xxxxxxx" },
      "user": 10,
      "offset": 10
    }
  }'
```

---

- App: https://pipedream.com/apps/amplitude.md · All apps: https://pipedream.com/apps
