I am trying to use google cloud talent API to pull jobs given a title and location but it is not giving me any search results. I have set up the project ID and tenant ID correctly.
Here is the script I am using:
from google.cloud import talent_v4beta1
def search_jobs(project_id, tenant_id, job_title="nurse", location="49008", radius_miles=50):
client = talent_v4beta1.JobServiceClient()
parent = f"projects/{project_id}/tenants/{tenant_id}"
request_metadata = {"user_id": "user123", "session_id": "session123", "domain": "www.example.com"}
job_query = {"query": job_title,
"location_filters": [{
"address": location,
"distance_in_miles": radius_miles
}]}
request = {"parent": parent, "request_metadata": request_metadata, "job_query": job_query}
response = client.search_jobs(request)
print(response.matching_jobs)
for result in response.matching_jobs:
print(f"Job title: {result.job.title}")
print(f"Job description: {result.job.description}")
print(f"Job location: {result.job.addresses}")
# Example usage
project_id = "x" # Replace with your project ID
tenant_id = "x" # Replace with your tenant ID
search_jobs(project_id, tenant_id)
When I run this code I am not getting any search results and it seems to be because the radius_miles is too small for any jobs to be present. I have gone through the documentation and tried to set the radius_miles manually but it does not seem to work still. When I print out the response here is what I get:
SearchJobsPager<location_filters {
location_type: POSTAL_CODE
postal_address {
region_code: "US"
postal_code: "49008"
administrative_area: "MI"
locality: "Kalamazoo"
address_lines: "Kalamazoo, MI 49008, USA"
}
lat_lng {
latitude: 42.2609411
longitude: -85.612648
}
radius_miles: 0.00161218820789593
}
My hypothesis is that it is not returning any results due to the small radius_miles parameter but I am not sure how to set this. Any assistance would be amazing!