seregazhuk/headhunter-api

PHP library to interact with hh.ru API

Installs: 11 533

Dependents: 0

Suggesters: 0

Security: 0

Stars: 26

Watchers: 8

Forks: 12

Open Issues: 1

Type:package

0.3.1 2017-09-28 11:44 UTC

README

Code Climate Test Coverage Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads

Provides a friendly API interface for HeadHunter (hh.ru) service.

Official API docs available here.

Dependencies

Requires PHP 5.6 or above.

Installation

The recommended way to install this library is via Composer. New to Composer?

composer require seregazhuk/headhunter-api

Quick Start

// You may need to amend this path to locate composer's autoloader
require('vendor/autoload.php');
use seregazhuk\HeadHunterApi\Api;

/**
 * Token is optional. Your need token only
 * for resources that require authentication
 */
$api = Api::create('YOUR_TOKEN');
$userInfo = $api->me->info();

You can create an instance without token, and later change it.

$api = Api::create();
$api->setToken('YOUR_TOKEN');

API Resources

Vacancies

View vacancy by id (official docs):

$vacancy = $api->vacancies->view($id);

Get similar vacancies for the current one (official docs):

$similarVacancies = $api->vacancies->similar($id);

Get black listed vacancies (official docs):

$blacklisted = $api->vacancies->blacklisted();

Get list of favorited vacancies (official docs):

$vacancies = $api->vacancies->favorited();

// with pagination
$vacancies = $api->vacancies->favorited(['page' => 2]);

Search (official docs):

$vacancies = $api->vacancies->search($params);

Vacancy statistics (official docs):

$stats = $api->vacancies->statistics($vacancyId);

Employer's active vacancies (official docs):

$vacancies = $api->vacancies->active();

// you can specify a manager, by default uses current manager
$vacancies = $api->vacancies->active($managerId);
// with pagination
$vacancies = $api->vacancies->active($managerId, ['page'=>2]);

Employer's archived vacancies (official docs):

$archived = $api->vacancies->archived();
// with pagination
$archived = $api->vacancies->archived(['page'=>2]);

Employer's hidden vacancies (official docs):

$hidden = $api->vacancies->hidden();
// with pagination
$hidden = $api->vacancies->hidden(['page'=>2]);

Hide a vacancy (official docs):

$api->vacancies->hide($vacancyId);

Restore a vacancy (official docs):

$api->vacancies->restore($vacancyId);

Employers

View employee by id (official docs):

$employee = $api->employers->view($id);

Search (official docs):

$employers = $api->employers->search($params);

Employer Managers

Reference types and the rights of the manager (official docs):

$reference_type = $api->employers->getManagerTypes();
$reference_type = $api->employers->getManagerTypes($employerId);

When used without parameters your employer id will be automatically resolved from your profile

Get employer managers (official docs):

$managers = $api->employers->getManagers();
$managers = $api->employers->getManagers($employerId);
$managerWhoHasVacancies = $api->employers->getManagersWhoHasVacancies();
$managerWhoHasVacancies = $api->employers->getManagersWhoHasVacancies($employerId);

When used without parameters your employer id will be automatically resolved from your profile

Get manager information (official docs):

$managers = $api->employers->getManager($managerId);
$managers = $api->employers->getManager($managerId, $employerId);

When used without parameters your employer id will be automatically resolved from your profile

Artifacts:

Get your photos (official docs):

$photos = $api->artifacts->photos();

Get your portfolio (official docs):

$portfolio = $api->artifacts->portfolio();

Delete photo by id (official docs):

$api->artifacts->deletePhoto($photoId);

Edit photo attributes (official docs):

$api->artifacts->editPhoto($photoId, $attributes);

Upload photo (official docs):

$api->artifacts->uploadPhoto('photo.jpg', 'my picture description');

Upload portfolio (official docs):

$api->artifacts->uploadPortfolio('portfolio.jpg', 'my portfolio description');

User:

Get current user info (official docs):

$info = $api->me->info();

Update name(last, first, middle). All parameters are required (official docs):

$api->me->editName($lastName, $firstName, $middleName);

Update flag 'is_in_search' (official docs):

$isInSearch = true; // or false;
$api->me->setIsInSearch($isInSearch);

Manager preferences by managerId. You can get your manager id from user object, returned from $api->me->info(). When used without parameters your manager id will be automatically resolved from your profile (official docs).

$me = $api->me->info();
$managerId = $me['manager']['id'];
$preferences = $api->manager->preferences($managerId);

// automatically get manager id from your profile
$preferences = $api->manager->preferences($managerId);

Applicant comments

Get all comments about applicant (official docs):

$comments = $api->comments->view($applicantId);

Create a comment (official docs). You need an applicant id, to create a comment. Applicant id can be received from resume:

$resumeInfo = $api->resume->view($resumeId);
$applicantCommentsUrl = $resumeInfo['owner']['comments']['url']; // https://api.hh.ru/applicant_comments/2743747
// You need to parse id from this url

// Create a comment, that is visible for coworkers
$result = $api->comments($applicantId, 'my comment');

// Create a comment, that is visible only for you
$result = $api->createPrivate($applicantId, 'my comment');

Edit comment (official docs):

// Edit a comment, that is visible for coworkers
$api->comments->edit($applicantId, $commentId, 'new comment text')

// Edit a comment, that is visible only for you
$result = $api->editPrivate($applicantId, $commentId, 'new comment text');

Delete a comment (official docs):

$api->comments->delete($applicantId, $commentId);

Industries

Get all industries (official docs):

$industries = $api->industries->all();

Employee Negotiations

Get all negotiations (official docs):

$negotiations = $api->negotiations->all();

Get only active negotiations (official docs):

$negotiations = $api->negotiations->active();

View the list of messages.

  • For employee: get messages of negotiation (official docs):
  • For employer: view the list of messages in the response/invitation (official docs):
$api->negotiations->messages($negotiationId);
// with pagination
$api->negotiations->messages($negotiationId, ['page'=>2]);

Sending new message.

$api->negotiations->message($negotiationId, $messageText);

Git list of responses/invitation for (official docs):

$responses = $api->negotiations->invited($vacancyId);

There are several types of invitations. For each of them you can pass a pagination array as a second argument:

Response

$responses = $api->negotiations->invitedResponses($vacancyId);
// with pagination
$responses = $api->negotiations->invitedResponses($vacancyId, ['page'=>2]);

Consider

$toConsider = $api->negotiations->invitedConsider($vacancyId);

Phone interview

$phoneInterviews = $api->negotiations->invitedPhoneInterviews($vacancyId);

Assessments

$assessments = $api->negotiations->invitedAssessments($vacancyId);

Interviews

$interviews = $api->negotiations->invitedInterviews($vacancyId);

Offers

$offers = $api->negotiations->invitedOffers($vacancyId);

Hired

$hired = $api->negotiations->invitedHired($vacancyId);

Discard by employer

$discard = $api->negotiations->invitedDiscardByEmployer($vacancyId);

View the response/invitation by id. NegotiationId can be taken from key url in the invited call response. (official docs):

$response = $api->negotiations->view($negotiationId);

Regions

Get all regions (official docs):

$regions = $api->regions->all();

Resumes

Get my resumes (official docs):

$resumes = $api->resumes->mine();

View resume (official docs):

$views = $api->resumes->view($resumeId);

Edit resume (official docs):

$api->resumes->edit($resumeId, ['first_name' => 'New name']);

Create a new resume (official docs):

$attributes = ['first_name' => 'New name'];
$result = $api->resumes->create($attributes);

Views history (official docs):

$views = $api->resumes->views($resumeId);

// with pagination

$views = $api->resumes->views($resumeId, ['page'=>2]);

Negotiations history (official docs):

$negotiations = $api->resumes->negotiations($resumeId);
// with pagination
$negotiations = $api->resumes->negotiations($resumeId, ['page' => 2]);

Update resume publish date (official docs):

$api->resumes->publish($resumeId);

Get resume conditions (official docs):

$conditions = $api->resumes->conditions($resumeId);

Remove resume (official docs):

$api->resumes->delete($resumeId);

Get current status (if it is blocked or ready to publish) (official docs):

$status = $api->resumes->status($resumeId);

Get jobs recommendations for resume (official docs):

$jobs = $api->resumes->jobs($resumeId)

// with pagination
$jobs = $api->resumes->jobs($resumeId, ['page' => 2])

Resume visibility

official docs

Get resume black/white list:

$blackList = $api->resumes->getBlackList($resumeId);
// ...
$whiteList = $api->resumes->getWhiteList($resumeId);

Add a company to black/white list:

$api->resumes->addToBlackList($resumeId, $companyId);
// ...
$api->resumes->addToWhiteList($resumeId, $companyId);

Remove a company from black/white list:

$api->resumes->removeFromBlackList($resumeId, $companyId);
// ...
$api->resumes->removeFromWhiteList($resumeId, $companyId);

Clear black/white list:

$api->resumes->clearBlackList($resumeId);
// ...
$api->resumes->clearWhiteList($resumeId);

Search in black/white list:

$companies = $api->resumes->searchInBlackList($resumeId, 'some-key-word');
//...
$companies = $api->resumes->searchInWhiteList($resumeId, 'some-key-word');

Search in black/white list:

Saved searches:

List searches (official docs):

$searches = $api->savedSearches->all();

Get one search (official docs):

$searches = $api->savedSearches->view($searchId);

Specializations

Get all specializations (official docs):

$specializations = $api->specializations->all();

Dictionaries

Get list of entities that are used in API (official docs):

$dictionaries = $api->dictionaries->all();

Suggests

Educational institutions (official docs):

$suggests = $api->suggests->educational_institutions($text);

Companies (official docs):

$suggests = $api->suggests->companies($text);

Specialization (official docs):

$suggests = $api->suggests->fieldsOfStudy($text);

Key skills (official docs):

$suggests = $api->suggests->skillSet($text);

Position (official docs):

$suggests = $api->suggests->positions($text);

Region (official docs):

$suggests = $api->suggests->areas($text);

Tips for vacancy search key words (official docs):

$suggests = $api->suggests->vacancySearchKeyword($text);

Metro

Obtaining all metro stations of all cities (official docs):

$stations = $api->metro->all();

List of metro stations and lines in a specific city (official docs):

$stations = $api->metro->forCity($cityId);

Languages

Obtaining available languages (official docs):

$languages = $api->languages->all();

Faculties

Get list of faculties of the educational institutions (official docs). Uses institutionId that can be obtained from the suggestions for educational institutions.

$faculties = $api->faculties->forInstitution($institutionId);

Custom requests (official docs):

Locale

You can set a locale for your requests, the results will be returned in the selected locale. RU is set by default (official docs):

$api->setLocale('EN');

// chain methods
$api->setLocale('EN')
    ->me
    ->info();

Host

Get data from different websites of the HeadHunter group. (official docs):

$api->setHost('hh.kz');

// chain methods
$api->setHost('hh.kz')
    ->me
    ->info();