# retrieveConnections

This method allows you to retrieve your connections applying various filtering criteria.

```typescript
try {
  const workflow = await linkedapi.retrieveConnections.execute({
    filter: {
      firstName: "John",
      position: "Engineer",
      locations: ["San Francisco", "New York"]
    },
    limit: 100
  });

  const { data, errors } = await linkedapi.retrieveConnections.result(workflow.workflowId);

  // 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}`);
    });
  }

  // The structure of the 'data' object is below
  if (data) {
    console.log('Retrieved connections:', data.length);
    data.forEach(connection => {
      console.log(`${connection.name} - ${connection.headline}`);
      console.log(`Location: ${connection.location}`);
      console.log(`Profile: ${connection.publicUrl}`);
    });
  }
} 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 RetrieveConnectionsParams, LinkedApiError

try:
    workflow = linkedapi.retrieve_connections.execute(
        RetrieveConnectionsParams(
            filter={
                "first_name": "John",
                "position": "Engineer",
                "locations": ["San Francisco", "New York"],
            },
            limit=100,
        )
    )

    result = linkedapi.retrieve_connections.result(workflow.workflow_id)
    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}")

    # The structure of the 'data' object is below
    if data:
        print("Retrieved connections:", len(data))
        for connection in data:
            print(f"{connection.name} - {connection.headline}")
            print(f"Location: {connection.location}")
            print(f"Profile: {connection.public_url}")
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

- `limit` (optional) – number of connections to return. Defaults to **10**, with a maximum value of **1000**.
- `filter` (optional) – object that specifies filtering criteria for people. When multiple filter fields are specified, they are combined using `AND` logic.
  - `firstName` (optional) – first name of person.
  - `lastName` (optional) – last name of person.
  - `position` (optional) – job position of person.
  - `locations` (optional) – array of free-form strings representing locations. Matches if person is located in any of the listed locations.
  - `industries` (optional) – array of enums representing industries. Matches if person works in any of the listed industries. Takes specific values available in the LinkedIn interface.
  - `currentCompanies` (optional) – array of company names. Matches if person currently works at any of the listed companies.
  - `previousCompanies` (optional) – array of company names. Matches if person previously worked at any of the listed companies.
  - `schools` (optional) – array of institution names. Matches if person currently attends or previously attended any of the listed institutions.

## Data

Array of connections. Each connection contains:

- `name` – full name of the person.
- `publicUrl` –  [public](/faq/what-are-hashed-url-and-public-url) LinkedIn URL of the person.
- `headline` – headline of the person.
- `location` – free-form string indicating the person's location.

## Errors

- `retrievingNotAllowed` – LinkedIn has blocked performing the retrieval due to exceeding limits or other restrictions.
