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

# Search Companies

> Retrieve a list of LinkedIn companies matching the specified search criteria.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const params = new URLSearchParams({
    search: 'Google',
    location: 'Australia',
    companySize: '11-50,51-200,201-500',
    page: '1',
  });
  fetch(`https://api.harvestapi.io/linkedin/company-search?${params.toString()}`, {
    headers: { 'X-API-Key': '<api-key>' },
  })
    .then((response) => response.json())
    .then((data) => console.log(data));
  ```

  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.harvestapi.io/linkedin/company-search?search=Google&location=Australia&page=1 \
    --header 'X-API-Key: <api-key>'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.harvestapi.io/linkedin/company-search?search=Google&location=Australia&page=1"

  headers = {"X-API-Key": "<api-key>"}

  response = requests.request("GET", url, headers=headers)

  print(response.text)
  ```
</CodeGroup>

## Search by LinkedIn GeoID

For most of the cases, when specifying full location name, the search by the `location` parameter works fine.\
However sometimes search by location may not give you what you expect, as LinkedIn have some other suggested location for your text query.
For example, `NY` returns `New Zealand` instead of `New York`; `UK` returns `Ukraine` instead of `United Kingdom`.
The location search is based on LinkedIn autocomplete feature, you can try it [on the website](https://www.linkedin.com/search/results/people/?geoUrn=%5B%22103644278%22%5D) first.
The scraper will use the first suggestion from the autocomplete popup when you type your location.

The same autocomplete is available via our API. You can look up a location and get LinkedIn GeoID to use for the API endpoint.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const apiKey = '<api-key>';

  fetch(`https://api.harvestapi.io/linkedin/geo-id-search?search=New York`, {
    headers: { 'X-API-Key': apiKey },
  })
    .then((response) => response.json())
    .then((data) => {
      console.log('All matches:', data.elements);
      console.log('Closest match GeoID:', data.entityId);

      // Search for profiles in New York
      const params = new URLSearchParams({
        geoId: data.entityId,
        apiKey,
      });
      fetch(`https://api.harvestapi.io/linkedin/profile-search?${params.toString()}`)
        .then((response) => response.json())
        .then((data) => console.log(data));
    });
  ```

  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.harvestapi.io/linkedin/geo-id-search?search=New%20York \
    --header 'X-API-Key: <api-key>'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.harvestapi.io/linkedin/geo-id-search?search=New York"

  headers = {"X-API-Key": "<api-key>"}

  response = requests.request("GET", url, headers=headers)

  data = response.json()
  print("All matches:", data["elements"])
  print("Closest match GeoID:", data["id"])
  ```
</CodeGroup>


## OpenAPI

````yaml GET /linkedin/company-search
openapi: 3.0.1
info:
  title: HarvestAPI LinkedIn API reference
  description: HarvestAPI LinkedIn API reference
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.harvestapi.io
security:
  - ApiKeyAuthHeader: []
paths:
  /linkedin/company-search:
    get:
      summary: Search LinkedIn companies
      description: >-
        Retrieve a list of LinkedIn companies matching the specified search
        criteria.
      parameters:
        - name: search
          in: query
          description: Keywords to search for in company names.
          schema:
            type: string
        - name: location
          in: query
          description: Filter companies by location.
          schema:
            type: string
        - name: geoId
          in: query
          description: >-
            Filter by location as LinkedIn Geo ID. Overrides the location query
            param. Use the /linkedin/geo-id-search endpoint to find the Geo ID
          schema:
            type: string
        - name: companySize
          in: query
          description: >-
            Filter by company size. One value or multiple comma-separated.
            Supported values: '1-10', '11-50', '51-200', '201-500', '501-1000',
            '1001-5000', '5001-10000', '10001+'
          schema:
            type: string
        - name: industryId
          in: query
          description: >-
            Filter by industry ID. One value or multiple comma-separated
            industry IDs. Full list of IDs: 
            https://github.com/HarvestAPI/linkedin-industry-codes-v2/blob/main/linkedin_industry_code_v2_all_eng.csv
          schema:
            type: string
        - name: page
          in: query
          description: Page number for pagination.
          schema:
            type: integer
            default: 1
      responses:
        '200':
          description: A list of companies matching the search criteria.
          content:
            application/json:
              schema:
                type: object
                properties:
                  elements:
                    type: array
                    items:
                      $ref: '#/components/schemas/CompanyShort'
                  pagination:
                    $ref: '#/components/schemas/Pagination'
                    type: object
                  status:
                    type: string
                    description: Status of the response.
                  error:
                    type: string
                    description: Error message, if any.
                  query:
                    type: object
                    properties:
                      search:
                        type: string
                      location:
                        type: string
                      geoId:
                        type: string
                      companySize:
                        type: string
        '400':
          description: Invalid request parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized access.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CompanyShort:
      required:
        - universalName
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        industries:
          type: string
        location:
          type: object
          properties:
            linkedinText:
              type: string
        followers:
          type: string
        summary:
          type: string
        logo:
          type: string
        linkedinUrl:
          type: string
        universalName:
          type: string
    Pagination:
      type: object
      properties:
        totalPages:
          type: integer
          format: int32
        totalElements:
          type: integer
          format: int32
        pageNumber:
          type: integer
          format: int32
        previousElements:
          type: integer
          format: int32
        pageSize:
          type: integer
          format: int32
        paginationToken:
          type: string
          format: nullable
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  securitySchemes:
    ApiKeyAuthHeader:
      type: apiKey
      in: header
      name: X-API-Key

````