Skip to main content

Working with WeConnect's APIs

The Basics

Introducing a new set of APIs to interact with LinkedIn directly from external sources, which enables developers to integrate WeConnect functionality into their apps. Using the APIs, developers can:

  • Add LinkedIn account
  • Send connect requests
  • Send messages
  • Visit other LinkedIn profiles
  • Endorse skills to Linkedin users
  • Like LinkedIn profiles
  • Follow LinkedIn profiles
  • Withdraw connect request

Firstly a user account need to be created in WeConnect to use the APIs

WeConnect exposes two types of APIs

  • HTTP based REST APIs for executing actions on LinkedIn and
  • Websocket based API to get realtime updates related to submitted actions

The REST APIs use JWT token based approach to authenticate users. Hence for accessing protected endpoints, Authorization header need to be set with token Bearer <jwt_token> as its value. The <jwt_token> will be provided as response once the user submits the correct credentials.

Websocket API is build on top of Pusher. The Websocket API is solely meant for getting realtime updates related to a submitted action, say status of connect request on LinkedIn. Immediately after authentication, authenticated users must subscribe to a private channel in order to get realtime updates related to their submitted actions. The channel name will be formatted like private-status-updates-<user_id> (<user_id> will be there in login API response ). Pusher integration can be done using library for Android or iOS.

To explain about the APIs further, lets take a probable scenario. Let's say user wants to add a LinkedIn account and execute a connect request in LinkedIn using that account with WeConnect API. For that they need to:

  1. Login with their user credentials using /api/beta/login API. Use <jwt_token> returned by this API for accessing other protected endpoints.
  2. Connect to private-status-updates-<user_id> channel using <user_id> returned by login API once logged-in
  3. Add a LinkedIn account under the logged-in user with /api/beta/ln/add API. The updates related to LinkedIn account add process will be broadcasted over private-status-updates-<user_id> channel.
  4. Once the account is added , execute connect action using /api/beta/ln/send API. The API will return a unique id, which will act an identifier for the submitted action. All updates related to the action will be sent over websocket channel in realtime, with this unique id.
  5. In case user needs to know the status after a period of time, we also provide an HTTP REST API api/beta/ln/request/{id}, which will return status of the request along with additional details.

APIs used in this scenario are explained in details below.

Login with user credentials

POST `https://api-us-1.we-connect.io/api/beta/login`

Example request:

POST /api/beta/login HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"email": "[email protected]",
"password": "newpass"
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"success": {
"id": 75,
"email": "[email protected]",
"active_account": "[email protected]",
"fullname": "John Doe",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjIyYWMzY2UzYTM5NThlYWI0MGU2MDFiOTM2MjI3Y2JkZTg3ZDZkNGZlNTNmMWNmN2NiYmQ5NTk3OGE1MDY1YjdhMzE5OTAyZDc1YWM4N2ZmIn0.eyJhdWQiOiIzIiwianRpIjoiMjJhYzNjZTNhMzk1OGVhYjQwZTYwMWI5MzYyMjdjYmRlODdkNmQ0ZmU1M2YxY2Y3Y2JiZDk1OTc4YTUwNjViN2EzMTk5MDJkNzVhYzg3ZmYiLCJpYXQiOjE3MDk1MzM0NzAsIm5iZiI6MTcwOTUzMzQ3MCwiZXhwIjoxNzQxMDY5NDcwLCJzdWIiOiI3NSIsInNjb3BlcyI6W119.g0mmVns2uPbThjzX7Z5zYASSnLoMPcpxf4d7jkhkdwsWAqUa9HjWl6ej8anVtznHda66H92kaeh2pXf6Ccg5RoLUVq2ayCXXO04ps4SS4o_86A_o3hCpcP2xiSvLseg_A_3IN49hRo0YebW0jozMCLM_ghuthZoXh4jHoOAAHNzSlaVPWI6uCW_7U73f8VTNaVY7t3wM4HbkCEsZ8Y9Q2ibGML67j4Ux874AUXFjpDJ818EzPkJmjrU-sR2VhSCk-trjcKwXfM1-cmzhfpQq0K2PpIDTP0jNY_8iRO0NJkN0vZx4ScND-HFt3SnjBrm-jnkxrPxwnH7BM2p29Gq3zNuPnknIk9VByo4yuHZ-ZDR6_1w6n80CXiFa1XVSfnW9HeWbWwTAd9GuF7P2z95oNVFH6DisUwJAChn2wCfnPu8XOdgD_UOzFxtD048wOFNSolPd6qWWMF-WsTbabgF9-E_aZJS8Le3dt2wNTueHBYSuO8aSiF2bM-TXodZPrEZvsqIKrLttOHp73jyDmf6s87WyhMzfo_q957dr6zESSu1xqhdAtifhEHi-NZT0m7noy3yrKcC2xmiCWXbXmfcUqVAAxR254z5vbXcKFSCBYpXqOisGUnhr7lPB-W1LlpBQEfaDGR-518TN7eRlhce3b7ueLUtCslKo9V-ePasPQsg"
}
}

Add a LinkedIn account

POST `https://api-us-1.we-connect.io/api/beta/ln/add`

Example request:

POST beta/ln/add HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"email": "[email protected]",
"password": "my_ln_pw",
"timezone": "GMT",
"start": "10:00 PM",
"end": "6:00 AM",
"own_ip": false,
"location": "us",
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"success": {
"account_id": 708,
"account_email": "[email protected]"
}
}

Send a LinkedIn request

The same API endpoint should be used for executing all supported LinkedIn actions. The parameters associated with the request change according to the type of action, as described in example requests below:

POST `https://api-us-1.we-connect.io/api/beta/ln/send`

Example request for:

  1. Connect
POST /api/beta/ln/send HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"account_id":708,
"linkedin": "george-orwell",
"type": "connect",
"message":"Hi , I would like to connect with you"
}
  1. Message
POST /api/beta/ln/send HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"account_id":708,
"linkedin": "george-orwell",
"type": "message",
"message":"Hi George"
}
  1. Withdraw
POST /api/beta/ln/send HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"account_id":708,
"linkedin": "george-orwell",
"type": "withdraw"
}
  1. Visit
POST /api/beta/ln/send HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"account_id":708,
"linkedin": "george-orwell",
"type": "visit"
}
  1. Endorse
POST /api/beta/ln/send HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"account_id":708,
"linkedin": "george-orwell",
"type": "endorse"
}
  1. Like
POST /api/beta/ln/send HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"account_id":708,
"linkedin": "george-orwell",
"type": "like"
}
  1. Follow
POST /api/beta/ln/send HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"account_id":708,
"linkedin": "george-orwell",
"type": "follow"
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"status": "success",
"request_id": "08e50e33-6d98-400a-a135-e55650706cfe"
}

Query LinkedIn request status

POST `https://api-us-1.we-connect.io/api/beta/ln/request/<request_id>

Example request:

GET /api/beta/ln/request/08e50e33-6d98-400a-a135-e55650706cfe HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"status": "success",
"request_id": "08e50e33-6d98-400a-a135-e55650706cfe",
"request_type": "connect",
"request_object": {
"account_id": 708,
"linkedin": "george-orwell",
"type": "connect"
},
"request_status": "Completed_Success"
}

Note : For message type requests, the response will also include replied key , which indicates whether reply received for the message sent. Also, an event will be sent to web-socket channel to notify about reply. Thread and its reply can be fetched using /api/beta/ln/messages and /api/beta/ln/thread APIs.

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"status": "success",
"request_id": "08e50e33-6d98-400a-a135-e55650706cfe",
"request_type": "connect",
"request_object": {
"account_id": 708,
"linkedin": "george-orwell",
"type": "message"
},
"replied":false,
"request_status": "Completed_Success"
}

Fetch message threads

GET `https://api-us-1.we-connect.io/api/beta/ln/messages

Example request:

GET /api/beta/ln//messages HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"meta": {
"page": 1,
"pages": 1,
"perpage": 10,
"total": 1
},
"data": [
{
"img": "https://api-us-1.we-connect.io/api/profile/picture/112810",
"name": "Hermoine",
"job": "Minister of Magic",
"thread": "2-YTllN2NlMjItN2FlNi00YTIzLTljMTQtNTM1NDdmOTBiNGM1XzAxMA==",
"last_message": "Accio!",
"read": true,
"time": "4 days ago",
"time_stamp": "2024-03-07 13:24:16",
"thread_type": "linkedin",
}
]
}

Fetch specific message thread

POST `https://api-us-1.we-connect.io/api/beta/ln/thread

Example request:

POST  /api/beta/ln/thread HTTP/1.1
Host: api-us-1.we-connect.io
Content-Type: application/json

{
"thread":"2-YTllN2NlMjItN2FlNi00YTIzLTljMTQtNTM1NDdmOTBiNGM1XzAxMA=="
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
"profiles": [
{
"img": "https://stagingapi.we-connect.io/api/profile/picture/112810",
"name": "John Doe",
"first_name": "John",
"middle_name": "",
"last_name": "Doe",
"summary": "A highly resourceful person.",
"job": "Software Engineer",
"company": "WeConnect",
"location": "Illinois, United States",
"linkedin": "john-doe",
"profile_type": "linkedin",
"website": "",
"twitter": "",
"address": "",
"phone": "",
"present_company": "WeConnect",
"title": "IT Manager",
"thread": "2-YTllN2NlMjItN2FlNi00YTIzLTljMTQtNTM1NDdmOTBiNGM1XzAxMA==",
"read": true,
"thread_type": "linkedin"
}
],
"messages": [
{
"type": "in",
"name": "John Doe",
"content": "Hello !",
"time": "4 days ago",
"timestamp": 1709817856,
"date_time": "2024-03-07 13:24:16"
},
{
"type": "out",
"name": "Jane Doe",
"content": "Hi",
"time": "5 days ago",
"timestamp": 1709812569,
"date_time": "2024-03-07 11:56:09"
}
]
}