LinkedIn Email Finder API
Published: 2023-12-12 20:40:47

There are many reasons why you would want to find someone's email address online.
May be you want to reach out, to secure a sale or even propose a partnership.

For This article we are going to find a LinkedIn user's email using **Personal look up endpoint** of **Contact API** provided by Proxycurl.

> Note: Contact API is not intended for front-end use. To avoid `cors` policy, in this article we are going to use a middleman proxy server.

## Content

- [Prerequisite](#title1)
- [Get a Proxycurl API key](#title2)
  - [Create Proxycurl account](#subtitle2_1)
  - [Generate Proxycurl API key](#subtitle2_2)
- [Proxy server with node.js](#proxy)
- [Fetch LinkedIn email from proxy server](#title4)
- [Conclusion](#conclusion)

<a name="title1"></a>

## I. Prerequisite

To follow this article you need to be familiar with javascript ,`Node js` and `express`.
Plus, you must have a Proxycurl account to get an `API key`.

<a name="title2"></a>

## II. Get a Proxycurl API key

To get a proxycurl API key we need first to create an account ,that is free, in addition Proxycurl will provide 10 free credits that can be used for testing.

<a name="subtitle2_1"></a>

### II.1. Create Proxycurl account

To create create an account let's go to [Proxycurl registration page](https://nubela.co/proxycurl/auth/register) and complete the form.

![create account page screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvu71woyj9h02mxlmltw.png)

After completing the form click on continue, then confirm the email address.

<a name="subtitle2_2"></a>

### II.2. Generate Proxycurl API key

After the registration process is well done, login, then click **generate Key**

![generate Proxyurl api key screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rf7j0plc8g0dnm2ugtk0.png)

<a name="title3"></a>

## III. Proxy server with node.js

Proxy servers act as middlemen, communicating your needs and requests without providing your information to the internet. Proxies can also allow you to bypass certain security blocks and allow you to access information that might otherwise be blocked. This is made possible through use a proxy server that does not reveal your personal IP address.
Find more about proxy server in node js [here](https://blog.logrocket.com/how-a-proxy-server-works-in-node-js/).

Now let's go ahead and create our server.
First, we must initialize our project to generate our `package.json` file:

```javascript
npm init
```

Next we must install two dependencies:

- `express`
- [`http-proxy-middleware`](https://www.npmjs.com/package/http-proxy-middleware)

After, let's create a `index.js` and `emailFinder.proxy.js` file, our project structure looks like:

```
Project
|
|--- nodes_modules
|--- emailFinder.proxy.js
|--- index.js
|--- package-lock.json
|--- package.json
```

In `index.js` let's write the following code:

```javascript
const express = require("express");
const app = express();

const PORT = 4040;
app.listen(PORT, () => console.log("Proxy is running on PORT " + PORT));
```

Here we are initializing our server with `express` , setting the port on `4040`.

To get the email from LinkedIn using Proxycurl's `Contact API` we need :

- The API endpoint : `https://nubela.co/proxycurl/api/contact-api/personal-email`
- The API key that we generated
- The LinkedIn profile url we want to have the email address

That noted, in `emailFinder.proxy.js` let's write the following code as well :

```javascript
const Router = require("express");
const { createProxyMiddleware } = require("http-proxy-middleware");
const router = Router();

const endpoint = "https://nubela.co/proxycurl/api/contact-api/personal-email"; // API endpoint
const api_key = "{api_key}"; // proxycurl api_key

const params = new URLSearchParams({
  linkedin_profile_url: "https://www.linkedin.com/in/jonathan-z-0a40ab209", // linkedIn profile url that we're gonna find the email
});

router.get(
  "/",
  createProxyMiddleware({
    target: endpoint + "?" + params,
    changeOrigin: true,
    onProxyReq: (proxyReq, req, res) => {
      proxyReq.setHeader("Authorization", `Bearer ${api_key}`);
    },
  })
);

module.exports = router;
```

Finally , to run our server we need first to import the `emailFinder.proxy.js` in `index.js` and use it as a middleware.

The code in `index.js` may look like :

```javascript
const express = require("express");
const emailFinderProxy = require("./emailFinder.proxy");
const app = express();

app.use("/find/email", emailFinderProxy);

const PORT = 4040;
app.listen(PORT, () => console.log("Proxy is running on PORT " + PORT));
```

Here we are setting the endpoint that we are going to use in order to fetch the LinkedIn email.

Now the proxy server is ready, let's run it typing in terminal the following command

```javascript
node index
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obh3aj8eqz8ernn7tqm1.png)

<a name="title4"></a>

## IV. Fetch LinkedIn email from proxy server.

```javascript
const enpoint = "http://localhost:4040/find/email";

fetch(enpoint, {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    accept: "application/json",
  },
})
  .then((res) => res.json())
  .then((data) => console.log(data));
```

This is how the response looks like:

```json
{
  "emails": ["random@gmail.com", "random2@yahoo.com"]
}
```

<a name="conclusion"></a>

### Conclusion

Now we can find an email address from LinkedIn with only the LinkedIn profile url.

- For more details about Proxycurl's services click [here](https://nubela.co/proxycurl/docs).

- Find the full code [here](https://github.com/Jonath-z/linkedIn-email-finder)