The monsoon season in India is a time for rejuvenation, reflection, and ... coding! As the rains refresh the land, why not use this time to build a tool to find your first job? This tutorial will guide you through using a Job Posting API with the Groovy programming language, a powerful and dynamic Java-based language perfect for this task.
Whether you're aiming for a role in India's vibrant tech scene or looking for remote opportunities, this project will equip you with the skills and tools to stand out in the competitive job market.
Why Automate Your Job Search?
For junior software developers transitioning into the professional world, the job search can feel like a daunting monsoon downpour. Sifting through countless job boards, tailoring applications, and staying organized can be overwhelming. Automating this process offers significant advantages:
- Save Time and Effort: Let the Job Posting API do the heavy lifting, freeing you to focus on skill-building and interview preparation.
- Target Your Search: Refine your criteria to receive only the most relevant job postings, ensuring you don't miss out on the perfect opportunity.
- Stay Organized: Keep all relevant job details in one place, easily accessible in your inbox.
- Gain a Competitive Edge: Demonstrate initiative and technical skills by building a custom tool that showcases your abilities to potential employers.
Understanding the Job Posting API
Our job search tool will leverage the power of the Daily International Job Posting API, a comprehensive resource that aggregates real-time job listings from various sources. This API allows us to filter results based on various parameters, such as:
- dateCreated: Find recently posted jobs.
- page: Navigate through paginated results.
- countryCode: Target jobs in specific countries, such as India.
- city: Filter jobs by city.
- occupation: Search for a occupation with many synonyms.
- title: Search for jobs with specific keywords in the title.
- skills: Search for tagged skills.
The API facilitates refined searches via Boolean queries. Use commas for "OR", encoded +
for "AND", and hyphens for "NOT". Keyphrase searches with double quotes, like city="Navi Mumbai"
, enable precise targeting. Combining these operators helps create very specific job searches.
Defining Your Job Search Criteria
Before writing the code, it's essential to define your ideal job profile. Consider your preferred location - are you open to relocation within India, interested in remote work, or do you have specific city preferences? Determine your desired field and tech stack, pinpointing the software development areas that excite you, such as web, mobile, or data science, and the specific technologies you want to work with. By clearly defining your preferences, you can tailor your search to deliver the most relevant and promising opportunities.
For this tutorial, we’ll search for Entry-level software developer jobs in India from the last month:
dateCreated=2025-02
(Jobs from last month)countryCode=in
(Jobs in India)workPlace=onsite,hybrid
(Jobs that are on-site or hybrid)occupation=programmer
(Jobs as programmer incl. all synonyms such as Software Engineer, ...)title=junior,entry,jr
(Jobs jor Junior developers / Entry-level)skills=Java
(Jobs jor Java)
If you want to search for remote jobs you should remove countryCode=in
and set workPlace=remote
.
Setting Up Your Groovy Environment
Groovy, with its seamless integration with Java, is an excellent choice for building our job search agent. To get started, we'll use SDKMAN (Software Development Kit Manager) to install and manage Groovy on your system.
-
Install SDKMAN: Open your terminal and execute the following command:
curl -s "https://get.sdkman.io" | bash
-
Initialize SDKMAN: After installation, refresh your terminal's environment by running:
source "$HOME/.sdkman/bin/sdkman-init.sh"
-
Install Groovy: Now you can install Groovy using SDKMAN. Check the available versions with:
sdk list groovy
Choose a version and install it. For example, to install Groovy 4.0.11, run:
sdk install groovy 4.0.11
-
Set Default Version: Make this version your default Groovy installation:
sdk default groovy 4.0.11
With Groovy set up, we're ready to start building our search tool!
Implementing the Job Search
Now, let's craft the Groovy script that will power our job search. Create a new file named JobSearchAgent.groovy
and add the following code:
// JobSearchAgent.groovy
@Grab(group='org.apache.httpcomponents.client5', module='httpclient5', version='5.4.2')
@Grab(group='jakarta.mail', module='jakarta.mail-api', version='2.1.3')
@Grab(group='com.sun.mail', module='jakarta.mail', version='2.0.1')
import org.apache.hc.client5.http.classic.methods.HttpGet
import org.apache.hc.client5.http.impl.classic.HttpClients
import org.apache.hc.core5.http.io.entity.EntityUtils
import groovy.json.JsonSlurper
import jakarta.mail.*
import jakarta.mail.internet.*
import java.time.LocalDate
import java.time.format.DateTimeFormatter
// API Configuration
def API_URL = "https://daily-international-job-postings.p.rapidapi.com/api/v2/jobs/search";
def API_KEY = "YOUR_API_KEY";
def EMAIL_USER = "your_email@gmail.com";
def EMAIL_PASS = "your_password";
def RECIPIENT_EMAIL = "your_email@gmail.com";
def MAX_PAGES = 2 // NOTE: only 25 requests per month are free
def lastMonth = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("yyyy-MM"))
// Define your search criteria
def queryParams = [
"dateCreated=$lastMonth",
"countryCode=in",
"occupation=programmer",
'title=junior,entry,jr',
"skills=Java",
].join("&")?.replaceAll(/\+/,'%2B')?.replaceAll(/\s+/,'+')
// Function to fetch job postings with pagination
def fetchJobs = { baseParams ->
def allJobs = []
def page = 1
def totalCount = Integer.MAX_VALUE
println "Starting to query API using '${API_URL}?${baseParams}'"
while (allJobs.size() < totalCount && page <= MAX_PAGES) {
try {
def url = new URL("${API_URL}?${baseParams}&page=${page}")
def connection = url.openConnection()
connection.setRequestProperty("x-rapidapi-key", API_KEY)
connection.setRequestProperty("x-rapidapi-host", 'daily-international-job-postings.p.rapidapi.com')
def response = connection.inputStream.text
def jsonSlurper = new JsonSlurper()
def jsonResponse = jsonSlurper.parseText(response)
totalCount = jsonResponse.totalCount
allJobs.addAll(jsonResponse.result)
println " Fetched page ${page} with ${jsonResponse?.result?.size() ?: 0} of ${totalCount} jobs."
page++
} catch (Exception e) {
println "Error fetching page ${page}: ${e.message}"
break
}
}
println "Total jobs fetched: ${allJobs.size()} of ${totalCount} jobs"
return allJobs
}
// Function to format jobs into an HTML email body
def formatJobs = { jobs ->
if (jobs.isEmpty()) {
return "<p>No jobs found.</p>"
}
def html = "<h2>New Job Opportunities</h2>\n"
html += "<table border='1'>\n"
html += " <tr><th>Date Created</th><th>Title</th><th>Company</th><th>Location</th><th>URL</th></tr>\n"
jobs.each { job ->
html += " <tr>"
html += " <td>${job.dateCreated ?: 'N/A'}</td>"
html += " <td>${job.title ?: 'N/A'}</td>"
html += " <td>${job.company ?: 'N/A'}</td>"
html += " <td>${job.city ?: 'N/A'}, ${job.state ?: 'N/A'}</td>"
html += " <td><a href='${job.jsonLD?.url ?: '#'}'>Link</a></td>"
html += " </tr>\n"
}
html += "</table>"
return html
}
// Function to send an email
def sendEmail = { to, subject, content ->
def props = new java.util.Properties()
props.put("mail.smtp.host", "smtp.gmail.com")
props.put("mail.smtp.port", "587")
props.put("mail.smtp.auth", "true")
props.put("mail.smtp.starttls.enable", "true")
Session session = Session.getInstance(props, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(EMAIL_USER, EMAIL_PASS)
}
})
MimeMessage message = new MimeMessage(session)
message.setFrom(new InternetAddress(EMAIL_USER))
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to))
message.setSubject(subject)
message.setContent(content, "text/html; charset=UTF-8")
Transport.send(message)
println "Email sent to: ${to}"
}
// Main script execution
try {
def jobs = fetchJobs(queryParams)
def formattedJobs = formatJobs(jobs)
sendEmail(RECIPIENT_EMAIL, "New Job Opportunities", formattedJobs)
} catch (Exception e) {
println "Error in main script execution: ${e.message}"
}
This script defines several key components:
- API Configuration: Replace
YOUR_API_KEY
,your_email@gmail.com
, andyour_password
with your actual credentials (for Gmail it's a App specific password). - Search Criteria: Customize the
queryParams
to match your desired location, field, and tech stack. fetchJobs
Function: Fetches job data from the API, handling pagination to retrieve all relevant results.formatJobs
Function: Transforms the fetched data into an HTML table for easy readability in an email.sendEmail
Function: Sends an email with the formatted opportunities to your specified address.
Running and Automating the Script
-
Execute the Script: Save the code as
JobSearchAgent.groovy
and run it from your terminal using:groovy JobSearchAgent.groovy
-
Automate with Cron: To automate the script's execution, we'll use
cron
, a time-based job scheduler available on Linux and macOS systems.-
Open your crontab configuration by running:
crontab -e
-
Add a new line to schedule the script to run daily at a specific time. For example, to run it every work day at 5:00 AM, add the following line, replacing the placeholders with your actual paths:
0 5 * * 0-5 /usr/local/bin/groovy /path/to/your/JobSearchAgent.groovy
-
Save and exit the crontab editor. You can verify the scheduled job by running:
crontab -l
-
Now, your Job search agent will automatically run every work day, fetching the latest opportunities and delivering them straight to your inbox!
Taking Your Project Further
This project is just the starting point. Here are some ideas to enhance your search tool:
- Advanced Filtering: Implement more sophisticated filtering based on city, salary, company size, specific technologies, or other criteria important to you.
- Data Analysis: Analyze the fetched data to identify trends in job postings, such as popular skills or locations with high demand.
- Web Interface: Create a user-friendly web interface to visualize the data, allowing for interactive exploration and filtering of jobs.
- Machine Learning: Integrate machine learning models to predict the suitability of jobs based on your profile and preferences.
By continuously improving your job search agent, you not only gain valuable technical skills but also demonstrate your initiative and problem-solving abilities to potential employers.
Conclusion
This monsoon coding season, you've built a powerful tool to streamline your job hunting. By building this automated Job Search Agent, you've demonstrated your technical skill and proactive mindset.
Remember to customize the script to align with your evolving career goal and explore the potential enhancements to further refine its capabilities. This project proves your ability to use technology for growth and sets you up for finding your first tech role.