101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772 | class SearchEndpoint(BaseModel):
"""
Declarative wrapper around the [Job Search API](https://developer.usajobs.gov/api-reference/get-api-search).
"""
METHOD: str = "GET"
PATH: str = "/api/search"
class Params(BaseModel):
"""Declarative definition of the endpoint's query parameters."""
model_config = ConfigDict(frozen=True, extra="forbid", populate_by_name=True)
keyword: Optional[str] = Field(
None,
alias="Keyword",
description="Issues search to find hits based on a keyword. Optional. Keyword will search for all of the words specified (or synonyms of the word) throughout the job announcement.",
examples=["https://data.usajobs.gov/api/search?Keyword=Software"],
)
position_title: Optional[str] = Field(
None,
alias="PositionTitle",
description="""
Issues search to find hits in the title of the job.
This is the job title - e.g. IT Specialist, Psychologist, etc. The title search will be treated as 'contains' and will select all job announcements where the job title contains the value provided.""",
examples=[
"The following query will return all job announcements with 'psychologist' or a synonym of psychologist in the title: 'https://data.usajobs.gov/api/Search?PositionTitle=Psychologist'",
"The following query will return all job announcements with 'Electrical Engineer'' in the title: 'https://data.usajobs.gov/api/Search?PositionTitle=Electrical%20Engineer'",
],
)
remuneration_min: Optional[int] = Field(
None,
alias="RemunerationMinimumAmount",
description="""
Issues search to find hits with the minimum salary specified.
Jobs are placed in salary buckets: $0-$24,999, $25,000-$49,999, $50,000-$74,999, $75,000-$99,999, $100,000-$124,999, $125,000-$149,999, $150,000-$174,999, $175,000-$199,999 and $200,000 or greater. So a search with a minimum salary of $15,500 will return jobs with a minimum salary in the $0-$24,999 range.""",
examples=[
"https://data.usajobs.gov/api/Search?RemunerationMinimumAmount=15000"
],
ge=0,
)
remuneration_max: Optional[int] = Field(
None,
alias="RemunerationMaximumAmount",
description="""
Issues search to find hits with the maximum salary specified.
Jobs are placed in salary buckets: $0-$24,999, $25,000-$49,999, $50,000-$74,999, $75,000-$99,999, $100,000-$124,999, $125,000-$149,999, $150,000-$174,999, $175,000-$199,999 and $200,000 or greater. So a search with a maximum salary of $72,000 will return jobs with a maximum salary in the $50,000-$74,999 range.
""",
examples=[
"https://data.usajobs.gov/api/Search?RemunerationMinimumAmount=26000&RemunerationMaximumAmount=85000"
],
gt=0,
)
pay_grade_high: Annotated[Optional[str], AfterValidator(isvalid_pay_grade)] = (
Field(
None,
alias="PayGradeHigh",
description="""
Issues search to find hits with the maximum pay grade specified. Must be 01 through 15. This is the ending grade for the job. (Caution: Fed speak ahead but it cannot be helped.) The grade along with series is used by the Federal government to categorize and define jobs.
For more information on what series and grade are, please visit: https://help.usajobs.gov/index.php/What_is_a_series_and_or_grade%3F.
However, grade is also used to define salary. USAJOBS search uses grades for the General Schedule (GS) pay plan ( http://www.opm.gov/policy-data-oversight/pay-leave/salaries-wages).
For jobs that use a different pay plan than the GS schedule, USAJOBS will derive the corresponding grade by using the minimum and maximum salary and the wages for the GS schedule for the Rest of the United States (for 2014, see: http//www.opm.gov/policy-data-oversight/pay-leave/salaries-wages/salary-tables/14Tables/html/RUS.aspx).
For federal employees, especially those who have a GS pay plan, searching by grade is extremely useful since they would already know which grades they are or qualify for. However, for non-GS employees, searching by salary is much simpler.
""",
examples=["https://data.usajobs.gov/api/Search?PayGradeHigh=07"],
)
)
pay_grade_low: Annotated[Optional[str], AfterValidator(isvalid_pay_grade)] = (
Field(
None,
alias="PayGradeLow",
description="Issues search to find hits with the minimum pay grade specified. Must be 01 through 15. This is the beginning grade for the job. See PayGradeHigh for more information.",
examples=[
"https://data.usajobs.gov/api/Search?PayGradeLow=04",
"https://data.usajobs.gov/api/Search?PayGradeLow=07&PayGradeHigh=09",
],
)
)
job_category_codes: List[str] = Field(
default_factory=list,
alias="JobCategoryCode",
description="Issues a search to find hits with the job category series specified.",
examples=["https://data.usajobs.gov/api/Search?JobCategoryCode=0830"],
)
position_schedule_type_codes: List[int] = Field(
default_factory=list,
alias="PositionScheduleTypeCode",
description="Issues a search to find hits for jobs matching the specified job schedule. This field is also known as work schedule.",
examples=["https://data.usajobs.gov/api/Search?PositionSchedule=4"],
)
position_offering_type_codes: List[int] = Field(
default_factory=list,
alias="PositionOfferingTypeCode",
description="Issues a search to find jobs within the specified type. This field is also known as Work Type.",
)
organization: List[str] = Field(
default_factory=list,
alias="Organization",
description="Issues a search to find jobs for the specified agency using the Agency Subelement Code.",
examples=["https://data.usajobs.gov/api/Search?Organization=TR"],
)
location_names: List[str] = Field(
default_factory=list,
alias="LocationName",
description="Issues a search to find hits within the specified location. This is the city or military installation name. LocationName simplifies location based search as the user does not need to know or account for each and every Location Code. LocationName will search for all location codes and ZIP codes that have that specific description.",
examples=[
"https://data.usajobs.gov/api/Search?LocationName=Washington%20DC,%20District%20of%20Columbia",
"https://data.usajobs.gov/api/Search?LocationName=Atlanta,%20Georgia",
],
)
travel_percentage: List[int] = Field(
default_factory=list,
alias="TravelPercentage",
description="Issues a search to find hits for jobs matching the specified travel level.",
examples=[
"https://data.usajobs.gov/api/Search?TravelPercentage=0",
"https://data.usajobs.gov/api/Search?TravelPercentage=7",
],
ge=0,
le=8,
)
relocation: Optional[bool] = Field(
None,
alias="RelocationIndicator",
description="Issues a search to find hits for jobs matching the relocation filter.",
)
security_clearance_required: List[int] = Field(
default_factory=list,
alias="SecurityClearanceRequired",
description="Issues a search to find hits for jobs matching the specified security clearance.",
examples=[
"https://data.usajobs.gov/api/Search?SecurityClearanceRequired=1"
],
ge=0,
le=8,
)
supervisory_status: Optional[str] = Field(
None,
alias="SupervisoryStatus",
description="Issues a search to find hits for jobs matching the specified supervisory status.",
)
days_since_posted: Annotated[
Optional[int],
Field(
alias="DatePosted",
description="Issues a search to find hits for jobs that were posted within the number of days specified.",
strict=True,
ge=0,
le=60,
),
] = None
job_grade_codes: List[str] = Field(
default_factory=list,
alias="JobGradeCode",
description="Issues a search to find hits for jobs matching the grade code specified. This field is also known as Pay Plan.",
)
sort_field: Optional[SortField] = Field(
None,
alias="SortField",
description="Issues a search that will be sorted by the specified field.",
examples=[
"https://data.usajobs.gov/api/Search?PositionTitle=Electrical&SortField=PositionTitle"
],
)
sort_direction: Optional[SortDirection] = Field(
None,
alias="SortDirection",
description="Issues a search that will be sorted by the SortField specified, in the direction specified.",
)
page: Annotated[
Optional[int],
Field(
alias="Page",
description="Issues a search to pull the paged results specified.",
strict=True,
ge=1,
),
] = None
results_per_page: Annotated[
Optional[int],
Field(
alias="ResultsPerPage",
description="Issues a search and returns the page size specified. In this example, 25 jobs will be return for the first page.",
strict=True,
ge=1,
le=500,
),
] = None
who_may_apply: Optional[WhoMayApply] = Field(
None,
alias="WhoMayApply",
description="Issues a search to find hits based on the desired candidate designation. In this case, public will find jobs that U.S. citizens can apply for.",
examples=["https://data.usajobs.gov/api/Search?WhoMayApply=public"],
)
radius: Annotated[
Optional[int],
Field(
alias="Radius",
description="Issues a search when used along with LocationName, will expand the locations, based on the radius specified.",
examples=[
"https://data.usajobs.gov/api/Search?LocationName=Norfolk%20Virginia&Radius=75"
],
strict=True,
gt=0,
),
] = None
fields: Optional[FieldsMinMax] = Field(
None,
alias="Fields",
description="Issues a search that will return the minimum fields or maximum number of fields in the job. Min returns only the job summary.",
examples=[
"https://data.usajobs.gov/api/Search?TravelPercentage=7&Fields=full",
"https://data.usajobs.gov/api/Search?SecurityClearanceRequired=1&Fields=full",
],
)
salary_bucket: List[int] = Field(
default_factory=list,
alias="SalaryBucket",
description="Issues a search that will find hits for salaries matching the grouping specified. Buckets are assigned based on salary ranges.",
)
grade_bucket: List[int] = Field(
default_factory=list,
alias="GradeBucket",
description="Issues a search that will find hits for grades that match the grouping specified.",
)
hiring_paths: List[HiringPath] = Field(
default_factory=list,
alias="HiringPath",
description="Issues a search that will find hits for hiring paths that match the hiring paths specified.",
examples=["https://data.usajobs.gov/api/Search?HiringPath=public"],
)
mission_critical_tags: List[str] = Field(
default_factory=list,
alias="MissionCriticalTags",
description="Issues a search that will find hits for mission critical tags that match the grouping specified.",
examples=[
"https://data.usajobs.gov/api/Search?MissionCriticalTags=STEM&Fields=full"
],
)
position_sensitivity: List[int] = Field(
default_factory=list,
alias="PositionSensitivity",
description="Issues a search that will find hits for jobs matching the position sensitivity and risk specified.",
examples=["https://data.usajobs.gov/api/Search?PositionSensitivity=1"],
ge=1,
le=7,
)
remote_indicator: Optional[bool] = Field(
None,
alias="RemoteIndicator",
description="Issues a search to find hits for jobs matching the remote filter.",
)
@model_validator(mode="after")
def _radius_requires_location(self) -> "SearchEndpoint.Params":
"""Only use radius filters when a locaiton is provided."""
if self.radius is not None and not self.location_names:
raise ValueError("Radius requires at least one LocationName.")
return self
@field_validator("remuneration_max")
@classmethod
def _check_min_le_max(
cls, v: Optional[int], info: ValidationInfo
) -> Optional[int]:
"""Validate that remuneration max is >= remuneration min."""
mn = info.data.get("remuneration_min")
if v is not None and mn is not None and v < mn:
raise ValueError(
"RemunerationMaximumAmount must be >= RemunerationMinimumAmount."
)
return v
def to_params(self) -> Dict[str, str]:
"""Return the serialized query-parameter dictionary."""
return _dump_by_alias(self)
# Response shapes
# ---
class JobCategory(BaseModel):
"""Represents a job series classification associated with a posting."""
code: Optional[str] = Field(default=None, alias="Code")
name: Optional[str] = Field(default=None, alias="Name")
class JobGrade(BaseModel):
"""Represents the job grade (e.g. GS) tied to the posting."""
code: Optional[str] = Field(default=None, alias="Code")
current_grade: Optional[str] = Field(default=None, alias="CurrentGrade")
class PositionSchedule(BaseModel):
"""Represents the work schedule for the position."""
code: Optional[str] = Field(default=None, alias="Code")
name: Optional[str] = Field(default=None, alias="Name")
class PositionOfferingType(BaseModel):
"""Represents the appointment type (e.g. permanent, term)."""
code: Optional[str] = Field(default=None, alias="Code")
name: Optional[str] = Field(default=None, alias="Name")
class PositionRemuneration(BaseModel):
"""Represents a salary range entry for the position."""
minimum: Optional[float] = Field(default=None, alias="MinimumRange")
maximum: Optional[float] = Field(default=None, alias="MaximumRange")
rate_interval_code: Optional[str] = Field(
default=None, alias="RateIntervalCode"
)
description: Optional[str] = Field(default=None, alias="Description")
@field_validator("minimum", "maximum", mode="before")
@classmethod
def _normalize_amount(cls, value: Any) -> Optional[float]:
"""Normalize remuneration amounts to floats."""
if value in (None, ""):
return None
if isinstance(value, (int, float)):
return float(value)
if isinstance(value, str):
cleaned = value.replace(",", "").replace("$", "").strip()
if not cleaned:
return None
try:
return float(cleaned)
except ValueError:
return None
return None
class JobLocation(BaseModel):
"""Represents a structured job location entry."""
name: Optional[str] = Field(default=None, alias="LocationName")
code: Optional[str] = Field(default=None, alias="LocationCode")
country_code: Optional[str] = Field(default=None, alias="CountryCode")
state_code: Optional[str] = Field(default=None, alias="CountrySubDivisionCode")
city_name: Optional[str] = Field(default=None, alias="CityName")
latitude: Optional[float] = Field(default=None, alias="Latitude")
longitude: Optional[float] = Field(default=None, alias="Longitude")
@field_validator("latitude", "longitude", mode="before")
@classmethod
def _normalize_coordinate(cls, value: Any) -> Optional[float]:
"""Normalize coordinate values to floats."""
if value in (None, ""):
return None
try:
return float(value)
except (TypeError, ValueError):
return None
class WhoMayApplyInfo(BaseModel):
"""Represents the structured WhoMayApply block."""
name: Optional[str] = Field(default=None, alias="Name")
code: Optional[str] = Field(default=None, alias="Code")
class PositionFormatDesc(BaseModel):
"""Represents a quick summary of the job opportunity announcement."""
content: Optional[str] = Field(default=None, alias="Content")
label: Optional[str] = Field(default=None, alias="Label")
label_desc: Optional[str] = Field(default=None, alias="LabelDescription")
class UserAreaDetails(BaseModel):
"""Represents metadata stored under the UserArea.Details field."""
duties: Optional[str] = Field(
default=None,
alias="MajorDuties",
description="Description of the duties of the job.",
)
education: Optional[str] = Field(
default=None,
alias="Education",
description="Education required or preferred by applicants.",
)
requirements: Optional[str] = Field(
default=None,
alias="Requirements",
description="Key Requirements of the job opportunity.",
)
evaluations: Optional[str] = Field(
default=None,
alias="Evaluations",
description="Qualification requirements of the job opportunity.",
)
how_apply: Optional[str] = Field(
default=None,
alias="HowToApply",
description="Description of the steps to take to apply for the job opportunity.",
)
what_next: Optional[str] = Field(
default=None,
alias="WhatToExpectNext",
description="Description of what can be expected during the application process.",
)
req_docs: Optional[str] = Field(
default=None,
alias="RequiredDocuments",
description="Required documents when applying for the job opportunity.",
)
benefits: Optional[str] = Field(
default=None,
alias="Benefits being offered as part of the job opportunity.",
description="BenefitsBenefits",
)
benefits_url: Optional[str] = Field(
default=None,
alias="BenefitsUrl",
description="URL to view benefit details being offered.",
)
other_info: Optional[str] = Field(
default=None,
alias="OtherInformation",
description="Additional information about the job opportunity.",
)
key_reqs: List[str] = Field(
default_factory=list,
alias="KeyRequirements",
description="List of requirements for the job opportunity.",
)
job_summary: Optional[str] = Field(
default=None,
alias="JobSummary",
description="Summary of the job opportunity.",
)
who_may_apply: Optional[SearchEndpoint.WhoMayApplyInfo] = Field(
default=None,
alias="WhoMayApply",
description="Object that contains values for name and code of who may apply to the job opportunity.",
)
low_grade: Optional[str] = Field(
default=None,
alias="LowGrade",
description="Lowest potential grade level for the job opportunity.",
)
high_grade: Optional[str] = Field(
default=None,
alias="HighGrade",
description="Highest potential grade level for the job opportunity.",
)
sub_agency: Optional[str] = Field(
default=None,
alias="SubAgencyName",
description="SubAgencyName",
)
org_codes: Optional[str] = Field(
default=None,
alias="OrganizationCodes",
description="Organization codes separated by a slash (/).",
)
class UserArea(BaseModel):
"""Wrapper for additional USAJOBS metadata."""
details: Optional[SearchEndpoint.UserAreaDetails] = Field(
default=None, alias="Details"
)
is_radial_search: Optional[bool] = Field(
default=None,
alias="IsRadialSearch",
description="Was a radial search preformed.",
)
class JOADescriptor(BaseModel):
position_id: Optional[str] = Field(
default=None, alias="PositionID", description="Job Announcement Number"
)
position_title: Optional[str] = Field(
default=None,
alias="PositionTitle",
description="Title of the job offering.",
)
position_uri: Optional[str] = Field(
default=None,
alias="PositionURI",
description="URI to view the job offering.",
)
apply_uri: List[str] = Field(
default_factory=list,
alias="ApplyURI",
description="URI to apply for the job offering.",
)
locations_display: Optional[str] = Field(
default=None, alias="PositionLocationDisplay"
)
locations: List[SearchEndpoint.JobLocation] = Field(
default_factory=list,
alias="PositionLocation",
description="Contains values for location name, country, country subdivision, city, latitude and longitude.",
)
organization_name: Optional[str] = Field(
default=None,
alias="OrganizationName",
description="Name of the organization or agency offering the position.",
)
department_name: Optional[str] = Field(
default=None,
alias="DepartmentName",
description="Name of the department within the organization or agency offering the position.",
)
job_categories: List[SearchEndpoint.JobCategory] = Field(
default_factory=list,
alias="JobCategory",
description="List of job category objects that contain values for name and code.",
)
job_grades: List[SearchEndpoint.JobGrade] = Field(
default_factory=list,
alias="JobGrade",
description="List of job grade objects that contains an code value. This field is also known as Pay Plan.",
)
position_schedules: List[SearchEndpoint.PositionSchedule] = Field(
default_factory=list,
alias="PositionSchedule",
description="List of position schedule objects that contains values for name and code.",
)
position_offerings: List[SearchEndpoint.PositionOfferingType] = Field(
default_factory=list,
alias="PositionOfferingType",
description="List of position offering type objects that contains values for name and code. See PositionOfferingType in paramters above for list of code values.",
)
qualification_summary: Optional[str] = Field(
default=None,
alias="QualificationSummary",
description="Summary of qualifications for the job offering.",
)
position_remuneration: List[SearchEndpoint.PositionRemuneration] = Field(
default_factory=list,
alias="PositionRemuneration",
description="List of position remuneration objects that contains MinimumRange, MaximumRange and RateIntervalCode. Gives the pay range and frequency.",
)
position_start_date: Optional[dt.date] = Field(
default=None,
alias="PositionStartDate",
description="The date the job opportunity will be open to applications.",
)
position_end_date: Optional[dt.date] = Field(
default=None,
alias="PositionEndDate",
description="Last date the job opportunity will be posted",
)
publication_start_date: Optional[dt.date] = Field(
default=None,
alias="PublicationStartDate",
description="Date the job opportunity is posted",
)
application_close_date: Optional[dt.date] = Field(
default=None,
alias="ApplicationCloseDate",
description="Last date applications will be accepted for the job opportunity",
)
position_format_desc: List[SearchEndpoint.PositionFormatDesc] = Field(
default_factory=list,
alias="PositionFormattedDescription",
description="Provides quick summary of job opportunity.",
)
user_area: Optional[SearchEndpoint.UserArea] = Field(
default=None, alias="UserArea"
)
@field_validator(
"position_start_date",
"position_end_date",
"publication_start_date",
"application_close_date",
mode="before",
)
@classmethod
def _normalize_date_fields(
cls, value: None | dt.datetime | dt.date | str
) -> Optional[dt.date]:
"""Coerce date-like inputs to `datetime.date`."""
return _normalize_date(value)
def summary(self) -> Optional[str]:
"""Helper method returning the most descriptive summary for the job."""
if self.user_area and self.user_area.details:
details = self.user_area.details
if self.user_area.details and details.job_summary:
return details.job_summary
return self.qualification_summary
class JOAItem(BaseModel):
"""Represents a job opportunity annoucement object search result item."""
id: int = Field(alias="MatchedObjectId", description="Control Number")
details: SearchEndpoint.JOADescriptor = Field(alias="MatchedObjectDescriptor")
rank: Optional[float] = Field(default=None, alias="RelevanceRank")
class SearchResult(BaseModel):
"""Model of paginated search results."""
result_count: Optional[int] = Field(
default=None,
alias="SearchResultCount",
description="Number of records returned in response object.",
)
result_total: Optional[int] = Field(
default=None,
alias="SearchResultCountAll",
description="Total Number of records that matched search criteria.",
)
items: List[SearchEndpoint.JOAItem] = Field(
default_factory=list,
alias="SearchResultItems",
description="Array of job opportunity announcement objects that matched search criteria.",
)
class Response(BaseModel):
"""Declarative definition of the endpoint's response object."""
language: Optional[str] = Field(
default=None, alias="LanguageCode", description="Response Langauge"
)
params: Optional[SearchEndpoint.Params] = Field(
default=None,
alias="SearchParameters",
description="Query parameters used in search request.",
)
# Results are wrapped under SearchResult
search_result: Optional[SearchEndpoint.SearchResult] = Field(
default=None, alias="SearchResult"
)
def jobs(self) -> List[SearchEndpoint.JOAItem]:
"""Helper method to directly expose search result items from the response object."""
if not self.search_result:
return []
return self.search_result.items
|