Skip to content

hackertrail/scoutapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CompanySearchField

The CompanySearchField class provides a search input field with a dropdown that populates with company suggestions based on the user's input. When a company is selected from the dropdown, the class allows you to register callback functions that will be executed with the selected company's information.

API key

To use the services provided by TheCompanyAPI, follow these steps to obtain your API key:

  1. Visit TheCompanyAPI Website
  2. On the homepage, click the 'Get API Key' button.
  3. Select the plan that suits your needs. Note that some plans may require payment.
  4. Follow the prompts to enter your payment information and complete the purchase if your chosen plan requires it.
  5. Your API key will be emailed to you after selecting your plan and completing any necessary payments.

Usage

  1. Include the required JavaScript file in your HTML file:
    <script src="https://app.thecompanyapi.io/js/companyapi.min.js" ></script>
  2. Create an HTML element for the search input field:
    <input type="text" id="searchInput" placeholder="Search for a company">
  3. Create an instance of the CompanySearchField class, passing the API key and the ID of the search input field:
    let searchField = new CompanySearchField("YOUR_API_KEY", "searchInput");
    It will create a search input and a dropdown according to the user input
    Search Bar Image
  4. Register a callback function to handle the selected company information:
    searchField.onCompanySelected(function(companyObject) {
      // Handle the selected company information
      console.log("Selected company:", companyObject);
    });

Selected Company Object

When a company is selected from the dropdown, the registered callback function receives an object with the following properties:

  • company_name: The name of the selected company.
  • description: A brief description of the selected company.
  • size: The company's size, e.g., "mnc" (multinational corporation), "startup", etc.
  • industries: An array of industries the company operates in.
  • linkedin_link: The URL of the company's LinkedIn page.
  • company_id: A unique identifier for the company.
  • company_keyword: The search keyword used to find the company.
  • image_id: The ID of the company's logo image (may not be present).
  • location: The company's headquarters location (may not be present).

Example:

{
  company_name: 'Accenture',
  description: 'Accenture is a professional services company, providing services and solutions in strategy, consulting, digital, technology and operations.',
  size: 'mnc',
  industries: ['Consulting', 'Information Technology'],
  linkedin_link: 'https://www.linkedin.com/company/accenture/',
  company_id: '578c9a1f-cfc0-41ea-87f0-c6167190a48c',
  company_keyword: 'accenture',
  image_id: 'bayumbfcn7b4h7xk08cc',
  location: 'Dublin'
}

Note: The properties present in the object may vary depending on the data available for the selected company.

Constructor

var CompanySearchField = function(apiKey, domId) {
  // ...
}
  • apiKey (string): The API key required for making requests.
  • domId (string): The ID of the search input field element in the DOM.

Public Methods

onCompanySelected(callback)

Register a callback function to be executed when a company is selected from the dropdown.

searchField.onCompanySelected(function(companyObject) {
  // Your callback function
  console.log("Selected company:", companyObject);
});
  • callback (function): The function to be called when a company is selected. It receives the selected company's information as an object.

Dependencies

  • The CompanySearchField class uses the custom ajax function for making HTTP requests to our backend API.

Known Issues

The CompanyAPI.io is still in development, there are a number of known issues and they are listed in the GitHub issues tracker

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors