Overview

Born from the Federal Source Code Policy, Code.gov is on a mission to become the primary platform where America shares its code.

The Code.gov API is a public GET API. Data from the API will be delivered in JSON format. All of our data is provided to us by our partner agencies and is fully available to the public.

The Code.gov front-end is found in the code-gov-front-end repository. This React app is modular, configurable and customizable.

Back to top

Getting Started

The Code.gov API is a GET API. With this API, you will be able to explore the software projects that federal agencies have published in accordance with the Federal Source Code Policy.

Versioning

Because REST does not provide any specific versioning guidelines, The Code.gov API is versioned using URI versioning with an alias to the current version. This allows for a straightforward approach with a hard-settable version to prevent breaking client integrations, as well as allowing bleeding-edge applications to keep the same URI.

  • /v2
    • The current default: https://api.code.gov/v2/
    • Aliased to: https://api.code.gov/

Endpoints

There are two basic endpoints:

  • /repos: this endpoint will let you query all federal repositories that have been indexed by us.
  • /terms: this endpoint will let you query all terms we have indexed as part of our data harvesting process. These terms will help you in your search efforts.

And four more specific endpoints:

  • /agencies: this endpoint will let you query all federal agencies that have been indexed.
  • /languages: lists the repositories’ tagged languages and the count of repositories using the language.
  • /open-tasks: will display open tasks which have code.gov tag on issues.
  • /status.json: will display current status of agencies repositories.
  • /version: lists the current version of the API with a link to the repository.

Additional Notes

The rate limit for the API is currently 5,000 calls/day and 5 calls per 5 seconds. As we move forward and understand the impact of usage of the API, we will adjust the limits accordingly as well as allow for individual users with specific needs to have customized rate limits appropriate to their use.

Example URL

The URLs provided below are for initial browsing of API data. This DEMO_KEY will not work after a certain number of attempts. Users can request a personal key from the signup form below. The personal key will have more data access capabilities. The example links below are for demo only; actual API calls should use the x-api-key header as described in the API Key section.

Output

The output data will be in JSON format.

API Clients

We have a couple of API clients on our roadmap.

Javascript

API Key

To begin using this API, you will need to register for an API Key. You can sign up for an API key below. After registration, you will need to provide this API key in the x-api-key HTTP header with every API request.

Loading signup form...
HTTP Header Name Description
x-api-key API key from api.data.gov. For sample purposes, you can use DEMO_KEY as an API key.

Back to top

OpenAPI Specification File

You can view the full details of this API in the OpenAPI Specification file available here: Open API specification file for the Code.gov API

Back to top

API Calls

Before you can actually try the docs, you need to obtain an API key. You can do so here. Once you obtain your API key, you can go to our Swagger documentation and use it by clicking on the Authorize button located at the top right of the Swagger documentation.

Remember to change the Schema to HTTPS. If this is not changed, you will receive an error when submitting the test request.

Back to top

Contact Us

Let us know your questions or feedback in the project issue tracker.

Back to top