DEV Community

Cover image for LinkedIn Email Finder API
@Jonath-z
@Jonath-z

Posted on

LinkedIn Email Finder API

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

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.

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.

II.1. Create Proxycurl account

To create create an account let's go to Proxycurl registration page and complete the form.

create account page screenshot

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

II.2. Generate Proxycurl API key

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

generate Proxyurl api key screenshot

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.

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

npm init
Enter fullscreen mode Exit fullscreen mode

Next we must install two dependencies:

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
Enter fullscreen mode Exit fullscreen mode

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

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

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

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 :

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;
Enter fullscreen mode Exit fullscreen mode

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 :

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));
Enter fullscreen mode Exit fullscreen mode

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

node index
Enter fullscreen mode Exit fullscreen mode

Image description

IV. Fetch LinkedIn email from proxy server.

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));
Enter fullscreen mode Exit fullscreen mode

This is how the response looks like:

{
  "emails": ["random@gmail.com", "random2@yahoo.com"]
}
Enter fullscreen mode Exit fullscreen mode

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.

  • Find the full code here

Top comments (0)