Code.gov API

Government / API Key Intermediate HTTPS
Varies by plan (check documentation)

Overview

Code.gov is the U.S. Federal Government's platform for discovering and sharing open-source software built by federal agencies. Using an API key, you can search across hundreds of government repositories to find reusable code projects. It is useful for developers researching government tech initiatives or looking for publicly available federal code.

💡

Beginner Tip

Request a free API key from code.gov and include it in the Authorization header as a Bearer token to authenticate your requests.

Available Data

Code.gov data via REST API
JSON-formatted response data
Requires API key authentication

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Code.gov",
    "description": "The primary platform for Open Source and code sharing for the U.S. Federal Government",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

total Total number of repositories matching the search criteria.
repos List of repository objects returned for the current query.
name Name of the open-source repository.
agency Federal agency that owns or published the repository.
repositoryURL URL to the public source code repository (e.g., GitHub).

Implementation Example

const url = "https://code.gov/";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

401 Unauthorized API key is missing or has not been approved yet.
Ensure you have submitted your API key request at code.gov and received approval before making requests.
404 Not Found The endpoint path or repository ID does not exist.
Check the Code.gov API documentation for the correct endpoint paths and available resource IDs.
Empty results array Search query does not match any indexed repositories.
Try broader search terms or browse the code.gov website to verify repository names before querying.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 5/20
🔒 Security 15/15
🛠 Developer XP 12/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth API Key
HTTPS REQUIRED
CORS UNKNOWN
Category Government
Difficulty Intermediate
Verified: 2026-04-07

Similar APIs

View All →