Athena — mahmoud-consultancy/archive/old-docs/implementation/API_DOCUMENTATION.md

API Documentation - GloryLabs Recruitment Platform

Base URL

Development: http://localhost:8080/api
Production: https://api.glorylabs.nl/api

Authentication

All protected endpoints require a JWT token in the Authorization header:

Authorization: Bearer <jwt_token>

Job Endpoints

1. List All Active Jobs

GET /jobs

Query Parameters: | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | page | integer | 0 | Page number (0-indexed) | | size | integer | 10 | Items per page | | sortBy | string | createdAt | Sort field | | sortDirection | string | DESC | Sort direction (ASC/DESC) |

Response:

{
  "content": [
    {
      "id": 1,
      "title": "Senior Java Developer",
      "company": "Tech Corp",
      "location": "Amsterdam",
      "type": "Full-time",
      "category": "IT",
      "level": "Senior",
      "description": "...",
      "salaryRange": "€70,000 - €90,000",
      "tags": ["Java", "Spring", "Microservices"],
      "publishedAt": "2024-09-21T10:00:00",
      "viewCount": 42,
      "applicationCount": 5
    }
  ],
  "totalElements": 100,
  "totalPages": 10,
  "size": 10,
  "number": 0
}

2. Search Jobs

GET /jobs/search?query={searchTerm}

Query Parameters: | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | query | string | Yes | Search term | | page | integer | No | Page number | | size | integer | No | Items per page |

Example:

GET /jobs/search?query=java%20developer&page=0&size=20

Response: Same structure as List All Jobs


3. Filter Jobs

POST /jobs/filter

Request Body:

{
  "location": "Amsterdam",
  "type": "Full-time",
  "category": "IT",
  "level": "Senior",
  "searchTerm": "java"
}

Query Parameters: | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | page | integer | 0 | Page number | | size | integer | 10 | Items per page |

Response: Same structure as List All Jobs


4. Get Job Details

GET /jobs/{id}

Path Parameters:

  • id - Job ID (integer)

Response:

{
  "id": 1,
  "title": "Senior Java Developer",
  "company": "Tech Corp",
  "location": "Amsterdam",
  "type": "Full-time",
  "category": "IT",
  "level": "Senior",
  "description": "Full job description...",
  "requirements": "- 5+ years Java experience\n- Spring Boot expertise",
  "responsibilities": "- Design and develop APIs\n- Code reviews",
  "benefits": "- Competitive salary\n- Remote work options",
  "salaryRange": "€70,000 - €90,000",
  "tags": ["Java", "Spring", "Microservices"],
  "active": true,
  "publishedAt": "2024-09-21T10:00:00",
  "expiresAt": "2024-10-21T10:00:00",
  "viewCount": 42,
  "applicationCount": 5
}

5. Create Job (Admin Only) 🔒

POST /jobs

Request Body:

{
  "title": "Senior Java Developer",
  "company": "Tech Corp",
  "location": "Amsterdam",
  "type": "Full-time",
  "category": "IT",
  "level": "Senior",
  "description": "We are looking for...",
  "requirements": "Required skills...",
  "responsibilities": "Your responsibilities...",
  "benefits": "We offer...",
  "salaryRange": "€70,000 - €90,000",
  "tags": ["Java", "Spring", "Microservices"],
  "expiresAt": "2024-10-21T10:00:00"
}

Response: Created job object with generated ID


6. Update Job (Admin Only) 🔒

PUT /jobs/{id}

Path Parameters:

  • id - Job ID to update

Request Body: Same as Create Job

Response: Updated job object


7. Delete Job (Admin Only) 🔒

DELETE /jobs/{id}

Path Parameters:

  • id - Job ID to delete

Response: 204 No Content


8. Get Available Filters

GET /jobs/filters

Response:

{
  "locations": ["Amsterdam", "Rotterdam", "Utrecht", "Remote"],
  "categories": ["IT", "Finance", "Marketing", "Sales"],
  "types": ["Full-time", "Part-time", "Contract", "Freelance"],
  "levels": ["Junior", "Mid-level", "Senior", "Lead", "Manager"]
}

9. Get Job Statistics

GET /jobs/statistics

Response:

{
  "totalActiveJobs": 150,
  "jobsLastWeek": 12,
  "jobsLastMonth": 45,
  "recentJobs": [
    {
      "id": 1,
      "title": "Senior Java Developer",
      "company": "Tech Corp",
      "publishedAt": "2024-09-21T10:00:00"
    }
  ]
}

Crawler Endpoints

1. Start Web Crawl (Admin Only) 🔒

POST /crawler/crawl

Request Body:

{
  "url": "https://careers.example.com",
  "crawlType": "DEEP_CRAWL",
  "maxPages": 50,
  "initiatedBy": "admin@glorylabs.nl"
}

Crawl Types:

  • SINGLE_PAGE - Crawl only the specified URL
  • SITEMAP - Crawl based on sitemap
  • DEEP_CRAWL - Deep crawl following links

Response:

{
  "crawlJobId": 123,
  "status": "INITIATED",
  "message": "Crawl job initiated successfully"
}

2. Check Crawl Status

GET /crawler/status/{id}

Path Parameters:

  • id - Crawl job ID

Response:

{
  "id": 123,
  "url": "https://careers.example.com",
  "status": "RUNNING",
  "crawlType": "DEEP_CRAWL",
  "maxPages": 50,
  "pagesProcessed": 12,
  "jobsFound": 8,
  "jobsCreated": 6,
  "createdAt": "2024-09-21T10:00:00",
  "startedAt": "2024-09-21T10:00:05",
  "completedAt": null,
  "errorMessage": null
}

Status Values:

  • PENDING - Job created but not started
  • RUNNING - Currently processing
  • COMPLETED - Successfully finished
  • FAILED - Error occurred

3. Get Crawl History

GET /crawler/history

Query Parameters: | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | page | integer | 0 | Page number | | size | integer | 10 | Items per page |

Response:

{
  "content": [
    {
      "id": 123,
      "url": "https://careers.example.com",
      "status": "COMPLETED",
      "pagesProcessed": 50,
      "jobsCreated": 25,
      "createdAt": "2024-09-21T10:00:00",
      "completedAt": "2024-09-21T10:15:00"
    }
  ],
  "totalElements": 50,
  "totalPages": 5
}

4. Scrape Single Page

POST /crawler/scrape

Request Body:

{
  "url": "https://careers.example.com/job/123",
  "createJob": true,
  "company": "Example Corp",
  "location": "Amsterdam"
}

Response:

{
  "success": true,
  "title": "Senior Developer Position",
  "content": "Scraped content in markdown...",
  "url": "https://careers.example.com/job/123"
}

Application Endpoints (Coming Soon)

Submit Application

POST /applications

Get Application Status

GET /applications/{id}

List Applications (Admin) 🔒

GET /applications

Authentication Endpoints (Coming Soon)

Login

POST /auth/login

Refresh Token

POST /auth/refresh

Logout

POST /auth/logout

Error Responses

All endpoints return consistent error responses:

400 Bad Request

{
  "timestamp": "2024-09-21T10:00:00",
  "status": 400,
  "error": "Bad Request",
  "message": "Invalid input parameters",
  "path": "/api/jobs/search"
}

401 Unauthorized

{
  "timestamp": "2024-09-21T10:00:00",
  "status": 401,
  "error": "Unauthorized",
  "message": "JWT token is expired or invalid",
  "path": "/api/jobs"
}

403 Forbidden

{
  "timestamp": "2024-09-21T10:00:00",
  "status": 403,
  "error": "Forbidden",
  "message": "Insufficient permissions",
  "path": "/api/jobs/123"
}

404 Not Found

{
  "timestamp": "2024-09-21T10:00:00",
  "status": 404,
  "error": "Not Found",
  "message": "Job not found with id: 999",
  "path": "/api/jobs/999"
}

500 Internal Server Error

{
  "timestamp": "2024-09-21T10:00:00",
  "status": 500,
  "error": "Internal Server Error",
  "message": "An unexpected error occurred",
  "path": "/api/jobs"
}

Rate Limiting

API rate limits (when implemented):

  • Anonymous users: 100 requests per hour
  • Authenticated users: 1000 requests per hour
  • Admin users: Unlimited

Rate limit headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1695289200

Pagination

All list endpoints support pagination with these parameters:

  • page - Page number (0-indexed)
  • size - Items per page (max 100)
  • sort - Sort field and direction (e.g., "title,asc")

Pagination response includes:

  • content - Array of items
  • totalElements - Total number of items
  • totalPages - Total number of pages
  • size - Items per page
  • number - Current page number
  • first - Is first page
  • last - Is last page

CORS

CORS is configured for:

  • Development: http://localhost:4200
  • Production: Configure in application.yml

Allowed methods: GET, POST, PUT, DELETE, OPTIONS Allowed headers: All headers Credentials: Allowed


Testing the API

Using cURL

# Get all jobs
curl -X GET http://localhost:8080/api/jobs

# Search jobs
curl -X GET "http://localhost:8080/api/jobs/search?query=java"

# Get job details
curl -X GET http://localhost:8080/api/jobs/1

# Start a crawl (requires auth)
curl -X POST http://localhost:8080/api/crawler/crawl \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{"url":"https://example.com/careers","maxPages":10}'

Using Postman

Import the Postman collection from /docs/postman-collection.json (to be created)

Using Swagger UI

Access Swagger UI at: http://localhost:8080/api/swagger-ui.html (when configured)


Webhooks (Future)

Webhook events will be sent for:

  • New job created
  • Application received
  • Application status changed
  • Crawl job completed

Webhook payload format:

{
  "event": "job.created",
  "timestamp": "2024-09-21T10:00:00",
  "data": {
    "jobId": 123,
    "title": "Senior Developer",
    "company": "Tech Corp"
  }
}

Reacties

Nog geen reacties