linkedin-jobs-api

repository·master·Indexed 43 days ago

https://github.com/vishwagauravin/linkedin-jobs-api

A lightweight Node.js library for scraping and querying public LinkedIn job postings. Version 1.0.7 provides the `query()` method to filter jobs by keyword, location, salary, and experience level, and includes built-in pagination, rate limiting with exponential backoff, and an internal cache with a 1-hour TTL.

Tokens
1.4K
Snippets
4
Records
7
Agent score
6%

What's inside linkedin-jobs-api

  1. Use the linkedIn.query() method

    master

    To search for jobs, import the package and call linkedIn.query(queryOptions). This method returns a Promise that resolves to an array of Job objects.

    const linkedIn = require('linkedin-jobs-api');
    
    const queryOptions = {
      keyword: 'software engineer',
      location: 'India',
      dateSincePosted: 'past Week',
      jobType: 'full time',
      remoteFilter: 'remote',
      salary: '100000',
      experienceLevel: 'entry level',
      limit: '10',
      page: "0",
      has_verification: false,
      under_10_applicants: false,
    };
    
    linkedIn.query(queryOptions).then(response => {
    	console.log(response); // An array of Job objects
    });
  2. Reference queryOptions parameters for query()

    master

    The query() method accepts a queryOptions object. Below are the available parameters and their expected values:

    ParameterTypeDefaultDescription
    keywordstring""The text to search (e.g., Software Developer)
    locationstring""The name of the city (e.g., Los Angeles)
    dateSincePostedstring""Max range of jobs: past month, past week, 24hr
    jobTypestring""Position type: full time, part time, contract, temporary, volunteer, internship
    remoteFilterstring""Telecommuting filter: on site, remote, hybrid
    salarystring""Minimum Salary: 40000, 60000, 80000, 100000, 120000
    experienceLevelstring""internship, entry level, associate, senior, director, executive
    limitstring""Number of jobs returned (e.g., '1', '10', '100')
    sortBystring""Sort order: recent, relevant
    pagestring`
  3. Search for LinkedIn jobs using query()

    master

    The primary way to use this API is by calling the query() method. You pass a queryObject containing your search criteria, and the function returns a Promise that resolves to an array of job objects. The API handles pagination, rate limiting (with exponential backoff), and internal caching automatically.

    const { query } = require('linkedin-jobs-api');
    
    const jobs = await query({
      keyword: 'Software Engineer',
      location: 'New York',
      limit: 10,
      remoteFilter: 'remote'
    });
    
    console.log(jobs);
  4. Manage the internal job cache

    master

    The API uses an internal JobCache with a 1-hour TTL (Time To Live) to prevent redundant network requests for the same query. You can interact with the cache using the following exported utilities:

    • clearCache(): Clears all currently cached job results.
    • getCacheSize(): Returns the number of items currently in the cache.
    • JobCache: The class definition used for the internal cache.
    const { clearCache, getCacheSize } = require('linkedin-jobs-api');
    
    console.log(getCacheSize());
    clearCache();
  5. Understand the Job object structure

    master

    Each job returned by the query() method follows this schema:

    {
      "position": "Job Title",
      "company": "Company Name",
      "location": "City, State/Country",
      "date": "ISO Date String",
      "salary": "Salary info or 'Not specified'",
      "jobUrl": "URL to the job posting",
      "companyLogo": "URL to the company logo",
      "agoTime": "Relative time string (e.g., '2 days ago')"
    }
  6. Configure query parameters for job searching

    master

    The query() method accepts an object with the following properties to filter LinkedIn job results:

    ParameterTypeDescription
    keywordstringSearch term (e.g., 'Developer'). Spaces are converted to +.
    locationstringGeographic location (e.g., 'London').
    dateSincePostedstringTime range: 'past month', 'past week', or '24hr'.
    jobTypestringType of employment: 'full time', 'part time', 'contract', 'temporary', 'volunteer', or 'internship'.
    remoteFilterstringWork setting: 'on-site', 'remote', or 'hybrid'.
    salarynumberMinimum salary threshold (e.g., 40000, 60000, 80000, 100000, 120000).
    experienceLevelstringSeniority: 'internship', 'entry level', 'associate', 'senior', 'director', or 'executive'.
    sortBystringSort order: 'recent' or 'relevant'.
    limitnumberMaximum number of jobs to return.
    pagenumberThe page index to start from (0-indexed).
    has_verificationbooleanWhether to filter for verified jobs.
    under_10_applicantsbooleanWhether to filter for jobs with fewer than 10 applicants.
    hoststringThe LinkedIn host (defaults to www.linkedin.com).