jopilot-api
Version:
A JavaScript library to interact with the JoPilot API, allowing job search integration into applications.
54 lines (46 loc) • 1.24 kB
text/typescript
import axios, { AxiosInstance } from 'axios';
interface JobSearchRequest {
title: string;
companyName?: string;
city?: string;
state?: string;
country?: string;
isRemote?: boolean;
size: number;
}
interface GeographicLocation {
lat: number;
lon: number;
}
interface JobLocation {
city: string;
country: string;
state: string;
loc: GeographicLocation;
}
interface Job {
name: string;
companyName: string;
location: JobLocation;
feed: string;
id: string;
created: string;
}
interface JobSearchResult {
jobs: Job[];
}
class JobSearchService {
private static axiosInstance: AxiosInstance = axios.create({
baseURL: 'https://api.jopilot.net',
});
static async searchJobsAsync(request: JobSearchRequest): Promise<JobSearchResult> {
try {
const response = await this.axiosInstance.post<JobSearchResult>('/api/v1/search', request);
return response.data;
} catch (error) {
console.error('Error searching jobs:', error);
throw new Error('There was an error connecting to the job search service.');
}
}
}
export { JobSearchService, JobSearchRequest, JobSearchResult, Job, JobLocation, GeographicLocation };