npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pdl-react-autocomplete

v1.2.5

Published

A react component for the People Data Labs Autocomplete API

Downloads

164

Readme

This library allows users to search the PDL Autocomplete API for valid Search API query values within a specific field along with the number of available records for each suggestion, receive autocompetion suggestions in a drop down of options, and then select a suggestion to be passed into a callback function.

For example, a user queries the 'company' field with the text of 'goog' as a search term, and the autocomplete component will show a dropdown of options that most closely match this search, such as 'google'. The user either clicks or uses their keyboard to select 'google', and 'google' gets passed as the argument to a callback function has been passed down to this component as a prop.

Table of Contents

🔧 Installation

  1. Pull the package from the npm repository:
yarn add pdl-react-autocomplete

or

npm i pdl-react-autocomplete
  1. Sign up for a free PDL API key

🚀 Usage

First, import the component library:

import Autocomplete from 'pdl-react-autocomplete';

Then, use the library like any other React component:

  return (
    <div className="App">
      <Autocomplete
        field={'company'}
        size={5}
        onTermSelected={(term) => console.log('onSelectedTerm', term)}
        apiKey={'insertKeyHere'}
      />
    </div>
  );

📘 Documentation

The Autocomplete API endpoint is documented here: https://docs.peopledatalabs.com/docs/autocomplete-api

Props

  1. field (required)

    • The field input parameter specifies which type of field to run autocomplete for. The fields supported by the Autocomplete API map to a subset of the Person Schema fields.

      • The list of all valid arguments is:
        1. company
        2. country
        3. industry
        4. location
        5. major
        6. region
        7. role
        8. school
        9. sub_role
        10. skill
        11. title
        12. website
    • Each field argument value for the Autocomplete API maps to a specific subset of Person Schema fields. To see the exact mappings, visit the Autocomplete API Input Parameters documentation

  2. onTermSelected (required)

    • Callback function to be executed on the text of the input, but only as a result of selecting an autocompletion suggestion by mouse click or the 'enter' key.
  3. API Key (required)

    • PDL API Key required to avoid a 401 error.
  4. size

    • Number of results returned for autocompletion. Must be between 1 and 100. Set to 10 by default.

Styling

Refer to the styles in this css file and override the styling of an existing class by creating a new code block with the same class name, but with the '!important' tag.

.pdl-suggestion {
    width: 100%;
    padding: .5rem;
    justify-content: space-between;
}

/* your styling override */
.pdl-suggestion {
    background-color: red !important;
}

🔒 Security Disclaimer

This library should be used as an internal tool or as a proof of concept as it fires off requests to the PDL Autocomplete API from the client. This is due to the nature of being a react component and API Keys being all encompassing at PDL. We highly suggest referencing the component's code base for spinning up your own version but accessing the PDL Autocomplete API via a proxy server and not using this in a public production environment.