Skip to content

Jobs API

Integration with Jobs plugin for player job management and statistics.

List All Jobs

Get information about all available jobs.

Endpoint: GET /api/jobs

Authentication: Required (JWT)

Success Response (200):

json
{
  "success": true,
  "jobs": [
    {
      "id": "miner",
      "name": "Miner",
      "description": "Mine ores and blocks",
      "maxLevel": 100,
      "income": {
        "STONE": 0.1,
        "COAL_ORE": 0.5,
        "DIAMOND_ORE": 5.0
      },
      "experience": {
        "STONE": 1,
        "COAL_ORE": 5,
        "DIAMOND_ORE": 50
      },
      "members": 25
    }
  ]
}

Example:

bash
curl http://localhost:8080/api/jobs \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Get Job Details for Player

View a player's job information and statistics.

Endpoint: GET /api/jobs/details?username=Player123

Authentication: Required (JWT)

Query Parameters:

  • username - Minecraft username (optional, defaults to authenticated user)

Success Response (200):

json
{
  "success": true,
  "username": "Player123",
  "jobs": [
    {
      "jobName": "Miner",
      "level": 35,
      "experience": 12500,
      "experienceToNext": 2500,
      "totalEarned": 50000.0,
      "joinedAt": "2024-01-01T10:00:00Z"
    },
    {
      "jobName": "Builder",
      "level": 20,
      "experience": 5000,
      "experienceToNext": 1500,
      "totalEarned": 25000.0,
      "joinedAt": "2024-01-10T15:30:00Z"
    }
  ],
  "activeJobs": 2,
  "maxJobs": 3
}

Example:

bash
curl "http://localhost:8080/api/jobs/details?username=Player123" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Join a Job

Join a specific job.

Endpoint: POST /api/jobs/join

Authentication: Required (JWT)

Request Body:

json
{
  "jobName": "Miner"
}

Success Response (200):

json
{
  "success": true,
  "message": "Successfully joined Miner",
  "jobName": "Miner",
  "startLevel": 1
}

Example:

bash
curl -X POST http://localhost:8080/api/jobs/join \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jobName": "Miner"}'

Error Responses:

  • 400 - Invalid job name or already in job
  • 403 - Maximum jobs limit reached
  • 404 - Job not found

Leave a Job

Leave a specific job.

Endpoint: POST /api/jobs/leave

Authentication: Required (JWT)

Request Body:

json
{
  "jobName": "Miner"
}

Success Response (200):

json
{
  "success": true,
  "message": "Successfully left Miner",
  "jobName": "Miner"
}

Example:

bash
curl -X POST http://localhost:8080/api/jobs/leave \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jobName": "Miner"}'

Error Responses:

  • 400 - Not in this job
  • 404 - Job not found

Code Examples

TypeScript

typescript
interface Job {
  id: string;
  name: string;
  description: string;
  maxLevel: number;
  members: number;
}

interface PlayerJob {
  jobName: string;
  level: number;
  experience: number;
  experienceToNext: number;
  totalEarned: number;
}

class JobsAPI {
  constructor(private baseUrl: string, private token: string) {}
  
  async getAllJobs(): Promise<Job[]> {
    const response = await fetch(`${this.baseUrl}/api/jobs`, {
      headers: { 'Authorization': `Bearer ${this.token}` }
    });
    const data = await response.json();
    return data.jobs;
  }
  
  async getPlayerJobs(username?: string): Promise<PlayerJob[]> {
    const url = username 
      ? `${this.baseUrl}/api/jobs/details?username=${username}`
      : `${this.baseUrl}/api/jobs/details`;
      
    const response = await fetch(url, {
      headers: { 'Authorization': `Bearer ${this.token}` }
    });
    const data = await response.json();
    return data.jobs;
  }
  
  async joinJob(jobName: string) {
    const response = await fetch(`${this.baseUrl}/api/jobs/join`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.token}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ jobName })
    });
    return await response.json();
  }
  
  async leaveJob(jobName: string) {
    const response = await fetch(`${this.baseUrl}/api/jobs/leave`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${this.token}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({ jobName })
    });
    return await response.json();
  }
}

Python

python
class JobsAPI:
    def __init__(self, base_url, token):
        self.base_url = base_url
        self.headers = {'Authorization': f'Bearer {token}'}
    
    def get_all_jobs(self):
        response = requests.get(
            f'{self.base_url}/api/jobs',
            headers=self.headers
        )
        return response.json()
    
    def get_player_jobs(self, username=None):
        params = {'username': username} if username else {}
        response = requests.get(
            f'{self.base_url}/api/jobs/details',
            headers=self.headers,
            params=params
        )
        return response.json()
    
    def join_job(self, job_name):
        response = requests.post(
            f'{self.base_url}/api/jobs/join',
            headers={**self.headers, 'Content-Type': 'application/json'},
            json={'jobName': job_name}
        )
        return response.json()
    
    def leave_job(self, job_name):
        response = requests.post(
            f'{self.base_url}/api/jobs/leave',
            headers={**self.headers, 'Content-Type': 'application/json'},
            json={'jobName': job_name}
        )
        return response.json()

Common Job Types

Standard jobs available on most servers:

  • Miner - Mining blocks and ores
  • Woodcutter - Cutting trees
  • Builder - Placing blocks
  • Digger - Breaking blocks
  • Farmer - Farming crops
  • Hunter - Killing animals
  • Crafter - Crafting items
  • Fisherman - Fishing
  • Enchanter - Enchanting items
  • Brewer - Brewing potions

Notes

  • Requires Jobs plugin to be installed
  • Maximum jobs per player configurable (default: 3)
  • Experience and income rates set by server
  • Job levels reset if player leaves and rejoins
  • Some jobs may have level requirements
  • Job bonuses apply automatically when performing actions

Released under the MIT License.