A lightweight TypeScript/JavaScript SDK for HeadHunter API.
npm install node-hhru-apior with yarn:
yarn add node-hhru-apiimport { getUserToken, getResume, setHttpConfig } from 'node-hhru-api'
setHttpConfig({
locale: 'RU',
host: 'hh.ru',
userAgent: 'MyApp/1.0 ([email protected])',
})
const userTokenResponse = await getUserToken(
clientId,
clientSecret,
code // received from OAuth redirect
)
const resume = await getResume(userTokenResponse.access_token)
console.log(resume.id)You can import methods in two ways:
- Direct imports (tree-shaking friendly)
- Grouped namespaces (
Common,Applicant,Employer)
import { getUserToken, getResume } from 'node-hhru-api'
const userTokenResponse = await getUserToken(
clientId,
clientSecret,
code // received from OAuth redirect
)
const resume = await getResume(userTokenResponse.access_token)
console.log(resume.id)import { Common, Employer } from 'node-hhru-api'
const userTokenResponse = await Common.getUserToken(
clientId,
clientSecret,
code // received from OAuth redirect
)
const me = await Employer.getCurrentUser(userTokenResponse.access_token)
console.log(me.email)import { getAppToken } from 'node-hhru-api'
const appTokenResponse = await getAppToken(clientId, clientSecret)
console.log(appTokenResponse.access_token)import { getUserToken } from 'node-hhru-api'
const userTokenResponse = await getUserToken(
clientId,
clientSecret,
code, // received from OAuth redirect
redirectUri // optional
)
console.log(userTokenResponse.access_token)
console.log(userTokenResponse.refresh_token)import { refreshUserToken } from 'node-hhru-api'
const refreshed = await refreshUserToken(clientId, clientSecret, refreshToken)
console.log(refreshed.access_token)You can customize HTTP client (headers, locale, etc.):
import { setHttpConfig } from 'node-hhru-api'
setHttpConfig({
locale: 'RU',
host: 'hh.ru',
userAgent: 'MyApp/1.0 ([email protected])',
}) // Use this at the beginning of your codeHH-User-Agent. It should be in the format:
AppName/Version ([email protected])
All response objects are fully typed:
import {
Resume,
CurrentUser,
AppTokenResponse,
UserTokenResponse,
} from 'node-hhru-api'The project includes tests with Vitest:
Before running, make sure to set environment variables:
export HH_CLIENT_ID=your_client_id
export HH_CLIENT_SECRET=your_client_secret
export HH_AUTH_CODE=your_auth_code
export HH_REDIRECT_URI=your_redirect_urinpm run testMIT Β© 2025 Zoomish