# Where do I get federal agency and contracting office codes? From the SAM.gov Federal Hierarchy: it lists every department (CGAC code), sub-tier agency (FPDS code) and contracting office with their codes. The official Federal Hierarchy API serves it with a SAM.gov key; this API's /agencies returns the 232 departments and sub-tiers with their codes and counts, and agency_code filters bids and awards. Office codes (DoDAAC for defense offices) identify who buys.Checked on 2026-11-15.Official source: [SAM.gov Federal Hierarchy API](https://open.gsa.gov/api/fh-public-api/) | Agencies and sub-tiers here | 232 | | --- | --- | | Department code | CGAC, 3 digits | | Sub-tier code | FPDS, 4 characters | | Official source | SAM.gov Federal Hierarchy | ## The answer in detail Names are unreliable for filtering: the same agency appears as 'Dept of the Navy', 'Department of the Navy' and 'NAVY'. Codes are stable, so store them. A department code like 097 (Department of Defense) is the CGAC; sub-tiers such as 1700 (Department of the Navy) are FPDS codes.Office codes (DoDAAC for defense offices) identify who buys. They are the strongest key for matching a new solicitation to the office's earlier awards.Agency pages here show open notices and award counts per agency, built from the same codes. ## How the options compare | Option | Price | Access and limits | Coverage and history | Best for | Checked | | --- | --- | --- | --- | --- | --- | | [SAM.gov APIs (official)](https://open.gsa.gov/api/entity-api/) | Free | 10 requests a day with no SAM.gov role, 1,000 with a role or a non-federal system account; keys expire every 90 days | The live, authoritative record: entities, opportunities, exclusions, contract awards, hierarchy, subawards | Anyone who needs the official record itself, at low volume | 2026-11-12 | | [GovCon API (govconapi.com)](https://govconapi.com/pricing) | Developer $19/mo, Pro $39/mo; 14-day trial | 1,000 requests an hour (50 a minute burst); trial 50 a day | 12,265,150 contracts and 758,552 opportunities from FY2025; 904,090 entities, monthly | Developers who want the lowest entry price and FY2025+ history | 2026-11-15 | | [samgovapi.io](https://samgovapi.io/pricing) | Free (100 credits a month, no card); Developer $49/mo, Pro $149/mo, Scale $499/mo | 20 to 180 requests a minute by plan, no daily cap; REST, MCP and keyless MCP search | 881,370 entities (1 Nov 2026 extract), 74,420 notices, 169,191 exclusions, 114,954 awards since 1 Oct 2026 | Developers and AI agents who want entities, bids and exclusions joined in one API | 2026-11-15 | ## Where samgovapi.io is the weaker choice - Contracting offices are not listed as their own endpoint yet; office codes appear on notices and awards. ## Try it List agencies with their codes, then filter open bids by one. ``` curl "https://samgovapi.io/api/v1/agencies" \ -H "Authorization: Bearer $SAMGOVAPI_API_KEY" curl "https://samgovapi.io/api/v1/opportunities?agency_code=097&open=true&limit=25" \ -H "Authorization: Bearer $SAMGOVAPI_API_KEY" ``` ## Questions What is a DoDAAC?The Department of Defense Activity Address Code, a 6-character code that identifies a defense office.Does the Federal Hierarchy need a key?Yes, the official API uses a SAM.gov API key. ## Related - [Agencies](https://samgovapi.io/agencies) - [Federal Hierarchy API](https://samgovapi.io/federal-hierarchy-api) - [API docs](https://samgovapi.io/docs) - [Pricing](https://samgovapi.io/pricing) - [Answers](https://samgovapi.io/answers)Updated 2026-11-15. Sources checked 2026-11-15.Independent. Not affiliated with, endorsed by or sponsored by GSA, SAM.gov or any U.S. government agency. Registering in SAM.gov is free at sam.gov.

---

HTML version: https://samgovapi.io/answers/federal-agency-codes-api . Markdown: https://samgovapi.io/answers/federal-agency-codes-api.md

Independent. Not affiliated with, endorsed by or sponsored by GSA, SAM.gov or any U.S. government agency. Registering in SAM.gov is free at sam.gov.

Get a free API key: https://samgovapi.io/sign-up?ref=ai-claudebot
