-
Notifications
You must be signed in to change notification settings - Fork 8
random
/random/ endpoint in SWAGGER-UI
curl -X 'GET' \ 'http://peviitorqa.go.ro/api/v0/random/' \ -H 'accept: application/json'
-
Method:
GET -
Endpoint name:
/random - Request Parameters: None
- Response Format: application/json; charset=utf-8
{
"response": {
"numFound": "<number>",
"start": "<number>",
"numFoundExact": true,
"docs": [
{
"job_link": [
"<string>"
],
"job_title": [
"<string>"
],
"company": [
"<string>"
],
"company_str": "<string>",
"hiringOrganization.name": [
"<string>"
],
"country": [
"<string>"
],
"city": [
"<string>"
],
"remote": [
"<string>"
],
"id": "<UUID>"
}
]
}
}-
numFound: Total number of job postings available in the SOLR index. -
start: The offset for the randomly selected job. -
numFoundExact: Boolean flag indicating if the count is exact. -
docs: Contains job details. -
job_link: URL to apply for the job. -
job_title: The title of the job. -
company: The company offering the job. -
company_str: The string representation of the company name. -
hiringOrganization.name: Alternative field for the company name. -
country: Its value is alwaysRomânia. -
city: The city where the job is located. -
remote: Specifies if the job isremote,hybrid, oron-site. -
id: Unique identifier for the job posting.
-
200 OK– Request successful, returns list of companies and job counts if applicable. -
400 Bad Request– Invalid request parameters or missing required fields. -
401 Unauthorized– Authentication is required or invalid credentials. -
403 Forbidden– Access denied due to insufficient permissions. -
404 Not Found– The requested endpoint or resource does not exist. -
405 Method Not Allowed– OnlyGETrequests are supported. -
500 Internal Server Error– An unexpected error occurred on the server. -
502 Bad Gateway– The primary and fallback servers are both unreachable. -
503 Service Unavailable– The SOLR server is down or unreachable. -
507 Insufficient Storage– SOLR or API server runs out of space/memory.{ "error": "<message>", "code": "<number>" }
- Fetches job data from the SOLR search index (
jobscore). - If there are no jobs available, returns
{"message": "There are no jobs to display"}. - Selects a random job from the available dataset using SOLR’s
startparameter.
- Queries SOLR search index (
jobscore) for job data. - Uses numFound from the initial query to determine the total number of jobs.
- Selects a random job using the start parameter in a follow-up request.
- Queries all job listings using
q=*:*androws=0to count total jobs. - If no jobs are found, returns a
"There are no jobs to display"message. - Randomly selects a job using
start=<random_number>. - If SOLR is unavailable, a
503 Service Unavailableerror is returned.
-
CORS policy: Open to all (
Access-Control-Allow-Origin: *). - Authentication & Authorization: Not implemented in current version.
- Rate Limits: Not specified but should be considered for production.
- SOLR Search Server – Required to fetch job data.
-
PHP
file_get_contentsfunction – Fetches SOLR API response.
-
SOLR Downtime: If SOLR is unavailable, API returns a
503error. -
Empty Dataset: If no jobs exist, API returns
"There are no jobs to display". -
Non-negative counts:
numFoundandstartwill always be a non-negative integer. - Non-empty string: All fields must be non-empty.
- Performance Issues: Large datasets may cause response delays due to SOLR queries.
- Random Job Selection: Some jobs may be retrieved more frequently due to SOLR’s underlying data distribution.
-
To do: Secure SOLR with
security.json. - To do: Protect SOLR by IP whitelist.
The objective of this project is to develop an API endpoint that retrieves a random job from a SOLR index. This endpoint will be used to provide users with a random job listing, enhancing user engagement and exploration of job opportunities.
-
Functionality:
- The endpoint should retrieve a single random job from the SOLR index.
- The job should be selected randomly from all available jobs in the index.
-
Error Handling:
- The endpoint should handle errors gracefully, providing meaningful error messages to users.
- Specific error handling should include scenarios where no jobs are available in the index or when technical issues prevent job retrieval.
-
User Experience:
- The endpoint should respond quickly to ensure a seamless user experience.
- The response should include all relevant details about the job, such as job title, description, and company name.
-
Data Integrity:
- Ensure that the retrieved job data is accurate and up-to-date.
- The endpoint should not return jobs that have been removed or are no longer active.
-
Security:
- Implement appropriate security measures to protect user data and prevent unauthorized access to the SOLR index.
-
Scalability:
- The endpoint should be designed to handle a high volume of requests without impacting performance.
- The endpoint successfully retrieves a random job from the SOLR index.
- Error messages are clear and informative for users.
- The endpoint responds within an acceptable time frame.
- Retrieved job data is accurate and relevant.
- The SOLR index is properly configured and populated with job data.
- Necessary infrastructure and resources are available to support the endpoint.
-
Risk: Technical issues with the SOLR index could prevent job retrieval.
- Mitigation: Regularly monitor the SOLR index for errors and perform maintenance as needed.
-
Risk: High traffic could impact performance.
- Mitigation: Implement load balancing and optimize server resources to handle increased traffic.