# pollNetwork

This method polls your monitored network to retrieve captured connection events and receive new ones — accepted requests, new connections, and incoming connection requests.

This method polls your monitored network to retrieve captured connection events and receive new ones across the account's connection graph.

> Before polling, enable network monitoring once with [`syncNetwork`](/sdks/sync-network).

```typescript
try {
  const { data, errors } = await linkedapi.pollNetwork({
    since: "2024-01-01T00:00:00Z",   // Optional: only events after this timestamp
    type: "connectionAccepted"        // Optional: filter by a single event type
  });

  // The list of possible execution errors is below
  if (errors && errors.length > 0) {
    console.warn('Workflow completed with execution errors:');
    errors.forEach(error => {
      console.warn(` - Type: ${error.type}, Message: ${error.message}`);
    });
  }

  if (data) {
    console.log(`Retrieved ${data.events.length} events`);

    data.events.forEach(event => {
      console.log(`[${event.type}] ${event.personUrl} (${event.detectedAt})`);
    });
  }
} catch (e) {
  // A list of all critical errors can be found here:
  // https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
  if (e instanceof LinkedApiError) {
    console.error(`Critical Error - Type: ${e.type}, Message: ${e.message}`);
  } else {
    console.error('An unexpected, non-API error occurred:', e);
  }
}
```

```python
from linkedapi import NetworkPollRequest, LinkedApiError

try:
    result = linkedapi.poll_network(
        NetworkPollRequest(
            since="2024-01-01T00:00:00Z",  # Optional: only events after this timestamp
            type="connectionAccepted",       # Optional: filter by a single event type
        )
    )
    data = result.data
    errors = result.errors

    # The list of possible execution errors is below
    if errors:
        print("Workflow completed with execution errors:")
        for error in errors:
            print(f" - Type: {error.type}, Message: {error.message}")

    if data:
        print(f"Retrieved {len(data.events)} events")

        for event in data.events:
            print(f"[{event.type}] {event.person_url} ({event.detected_at})")
except LinkedApiError as e:
    # A list of all critical errors can be found here:
    # https://linkedapi.io/sdks/handling-results-and-errors/#handling-critical-errors
    print(f"Critical Error - Type: {e.type}, Message: {e.message}")
except Exception as error:
    print("An unexpected, non-API error occurred:", error)
```

## Params

All fields are optional:

- `since` – timestamp indicating the starting point for retrieving events. If not provided, all captured events are returned.
- `type` – filter by a single event type; omit for all:
  - `connectionRequestReceived` – someone sent you a connection request.
  - `connectionAccepted` – a new connection that matches a request you sent.
  - `connectionAdded` – a new connection not attributable to a request you sent.

## Data

- `events` – array of connection events, ordered newest first.
  - `id` – unique identifier for the event.
  - `type` – one of `connectionRequestReceived`, `connectionAccepted`, or `connectionAdded`.
  - `personUrl` – LinkedIn URL of the other person.
  - `detectedAt` – timestamp when Linked API observed the event.

---

**Recommended flow for integrations:**

1. Leave `since` empty on the first request to retrieve everything captured so far.
2. For subsequent requests, pass the **timestamp of the most recent event** you received as `since` to fetch only newer events.
3. Continue polling with an advancing `since`. Whenever new events arrive, update `since` to the latest `detectedAt`.

Events are retained for **90 days** — poll (or receive webhooks) often enough to consume them within that window, as older events are pruned and will no longer be returned.

For push-based delivery instead of polling, subscribe to the network [webhook events](/sdks/webhooks).
