min read

How to Get Latest Linkedin Posts or Activities with an API ? [2024]

This detailed guide will explore the intricacies of utilizing the Piloterr API to retrieve the freshest posts, providing insights into the process and highlighting its potential for informed decision-making and strategic connections.
Written by
Josselin Liebe
Published on
January 19, 2024
Readers rating

In the fast-paced world of professional networking, staying updated with the latest activities/posts on LinkedIn can be a crucial aspect for many businesses and individuals. As a developer, leveraging Piloterr's API to access these activities not only keeps you informed but also opens up a plethora of opportunities for data analysis, trend monitoring, and targeted networking. In this comprehensive guide, we'll dive into how to harness the Piloterr API to fetch the most recent activities.

The script we're sharing with you describes a method for retrieving LinkedIn activities matching specific keywords or hashtags, using the APIs provided by Piloterr.

How to run the code?

  1. Copy the code
  2. Create a new file
  3. Replace the API token with your own
  4. Replace QUERY with your sector, a business topic or any other subject you wish to analyze
  5. Run the script with py
import requests

QUERY = 'Formation'

def get_linkedin_post_details(known_url: str):
    api_url = ""
    headers = {
        "x-api-key": PILOTERR_API_KEY
    params = {
        "query": known_url
    response = requests.get(
    if response.status_code == 200:
        return response.json()
        return "Error: Unable to fetch data"

def get_linkedin_post_url_from_google(query: str):
    google_api_url = ""
    headers = {
        "x-api-key": PILOTERR_API_KEY
    data = {
        "query": query
    response =

    if response.status_code == 200:
        search_results = response.json()['organic_results']

        # Extract LinkedIn URL from search results
        for result in search_results:
            if '' in result['link']:
        return "LinkedIn URL not found in search results"
        return "Error: Unable to perform search"

# Example usage
posts = []
search_query = f" inurl:posts after:2023-01-01 besoin AROUND(5) {QUERY}"
linkedin_url = get_linkedin_post_url_from_google(search_query)

print(f"Count of LinkedIn posts found: {len(posts)}. Fetching details...")

parsed_posts = []

for p in posts:
    get_post_details = get_linkedin_post_details(p)


Here's a description of how the script works

1. Extracting LinkedIn Posts Using Google Search

The script uses a search query with specific parameters to find LinkedIn posts via Google Search. This is achieved using the Piloterr API for Google search.

It employs search operators like site:, inurl:, after:, and AROUND() to refine the search to specific LinkedIn posts containing the desired keywords within a certain date range.

2. Collecting Post Details from LinkedIn

Once the URLs of LinkedIn posts are obtained from Google Search results, the script uses another Piloterr API : Linkedin Post Info to fetch detailed information about each post.

This information can include the content of the post, author details, number of comments, likes, etc.

3. Script Execution:

  1. The script initializes an empty list posts to store the URLs of LinkedIn posts.
  2. It then forms a search query incorporating the desired keywords and search parameters.
  3. After obtaining the URLs, the script fetches details for each post and stores them in parsed_posts.


Count of LinkedIn posts found: 9. Fetching details...
[{'id': '7043937317610287104', 'url': '', 'text': "I strongly believe that employees’ know-how is the company's most valuable asset.\n\nUnlike onsite workers, remote workers can't just tap on a teammate's shoulder to ask a question\n\nThey need a different way to communicate and acquire knowledge.\n\nThe modern distributed workforce works with asynchronous video: \n\n✨ They record their questions
 in a video\xa0\n✨ Their teammate record their comment in the same video.\n✨ This video is now accessible to others.\n\nImagine all employees doing this ---\n\n-- It’s a great way to capture informal knowledge and build a company video knowledge hub.", 'author'
: {'url': '', 'full_name': 'Najette Fellache 🔆', 'image_url': '', 'profile_type': 'person'}, 'hashtags': [], 'image_url': '', 'like_count': 125, 
'comments_count': 4, 'date_published': '2023-03-21T13:32:06.530Z', 'total_engagement': 129, 'mentioned_profiles': []}, {...}, ...]


The article explains how using specific keywords to search and analyze LinkedIn activities can be a powerful tool. This method helps in tracking trends, analyzing data, and improving networking. It keeps users up-to-date in their industry and supports strategic growth in the digital world.

Piloterr web scraping api
Scrape linkedin post
Discover Piloterr, the all-in-one scraping API. Sign up now and get 1000 free requests per month.⚡

Take a look at our blog posts

Interviews, tips, guides, industry best practices and news.
10 Best Practices For A Successful Data Strategy
min read

10 Best Practices For A Successful Data Strategy

Learn the essentials of data management, including the creation of guidelines, identification...
Read post
How to Get Latest Linkedin Posts or Activities with an API ? [2024]
min read

How to Get Latest Linkedin Posts or Activities with an API ? [2024]

How to find the latest linkedin posts related to a topic
Read post
5 Scraping Tools on Leboncoin in 2024 [No Code and Dev]
min read

5 Scraping Tools on Leboncoin in 2024 [No Code and Dev]

Reviews the top five scraping tools suitable for Leboncoin
Read post