> ## Documentation Index
> Fetch the complete documentation index at: https://fdocs.info/llms.txt
> Use this file to discover all available pages before exploring further.

# How to fully automate LinkedIn company searches, at any scale?

Are you looking to integrate LinkedIn company search results into your workflow without manual effort? In this guide, I’ll show you how to leverage our API to automate company searches from LinkedIn Sales Navigator—without requiring a LinkedIn account, cookies, or browser extensions. Simply define your search criteria and let the API do the rest.

## Code Demonstration

Let’s say you want to build a list of companies that meet the following criteria:

* **Company Size**: Between 1,001–10,000 employees.
* **Headquarters**: United States.
* **Hiring on LinkedIn**: No.
* **For more filters**: Please check out this [page](/tutorial/understanding-company-search-filters)

Here’s how you can achieve this step-by-step using Python.

<Steps>
  <Step title="Initiate the Search">
    ```python theme={null}
    import requests

    API_KEY = 'your_api_key_here'
    SEARCH_URL = "https://web-scraping-api2.p.rapidapi.com/search-companies"

    def search_companies():
        payload = {
            "company_headcounts": ["1001-5000", "5001-10000"],
            "headquarters_location": [103644278],  # United States
            "hiring_on_linkedin": "false",
            "limit": 100
        }
        headers = {
            "x-rapidapi-key": API_KEY,
            "Content-Type": "application/json"
        }

        response = requests.post(SEARCH_URL, json=payload, headers=headers)
        return response.json().get('request_id')
    ```
  </Step>

  <Step title="Monitor Search Progress">
    ```python theme={null}
    STATUS_URL = "https://web-scraping-api2.p.rapidapi.com/check-search-companies-status"

    def check_search_status(request_id):
        querystring = {"request_id": request_id}
        headers = {
            "x-rapidapi-key": API_KEY
        }

        response = requests.get(STATUS_URL, headers=headers, params=querystring)
        return response.json()['status'] # pending ==> processing ==> done
    ```
  </Step>

  <Step title="Retrieve Search Results">
    ```python theme={null}
    RESULTS_URL = "https://web-scraping-api2.p.rapidapi.com/get-search-companies-results"

    def get_search_results(request_id):
        headers = {
            "x-rapidapi-key": API_KEY
        }

        all_results = []
        page = 1

        while True:
            querystring = {"request_id": request_id, "page": page}
            response = requests.get(RESULTS_URL, headers=headers, params=querystring)
            data = response.json()

            if data.get("data"):
                all_results.extend(data["data"])
                page += 1
            else:
                break

        return all_results
    ```
  </Step>

  <Step title="Full Workflow">
    ```python theme={null}
    import time

    def main():
        request_id = search_companies()
        if not request_id:
            print("Error initiating search.")
            return

        while True:
            status = check_search_status(request_id)
            print("Search Status:", status)
            if status == "done":
                results = get_search_results(request_id)
                print(f"Total Results Fetched: {len(results)}")
                print("Search Results:", results)
                break
            time.sleep(60)  # wait for 1 minute before checking again

    if __name__ == "__main__":
        main()
    ```
  </Step>
</Steps>

## Prerequisites

Before running the code, ensure you have the following:

1. A **PRO** plan to access the search endpoint.
2. Python installed on your machine.
3. Install the required Python library using:

```bash theme={null}
pip install requests
```

## Pricing

The API usage cost is broken into three stages:

1. **Search initiation**: 25 credits per request.
2. **Search status checks**: Free of charge.
3. **Result fetching**: 1 credits per company.

For example, if your search returns 100 companies, the total credit cost would be:

25 credits + (1 × 100) = **125 credits**.

This guide demonstrates how you can use the API to automate LinkedIn company searches efficiently and integrate them seamlessly into your workflow. Start leveraging this solution to scale your business insights effortlessly.
