Using the CLI to Send Accessibility Results to axe Developer Hub
Discusses the different ways you can upload your accessibility results to axe Developer Hub using the CLI
The CLI allows you to send your accessibility results to axe Developer Hub. You can:
- Upload results from previous test runs to axe Developer Hub. This option uses the
devhubCLI subcommand and allows you to upload results from analyzing web pages using the web APIs or from previous CLI runs (where you analyzed individual pages or ran spec files and saved the results). - Analyze individual pages and send results to axe Developer Hub directly (without first saving results files).
- Run spec files and send results directly to axe Developer Hub (without first saving results files).
Requirements
To use the CLI with axe Developer Hub, you will need:
- An axe account and a subscription for axe Developer Hub. See Get Started with axe Developer Hub for more information.
- An axe Developer Hub project where you upload results. See Create a New axe Developer Hub Project for information about creating a new project. When you create a project, you specify that the project will use the CLI as its input or data source. You will need these values to upload results:
- Your personal API key (shown in your axe Account under API keys)
- Your project ID (shown in the instructions when you create a new axe Developer Hub project)
- (Optional) If you have tests that use the web APIs, you will need to modify your tests to produce a results file or files. A results file is a
.jsonfile containing the results of your test run, and the procedure for creating results files is different depending on the API you use. For more details, see Creating Results Files. You use thedevhubsubcommand to upload results files.
Sending Results to axe Developer Hub
Normally, the CLI tests websites and produces results only when you use the -s option to save results (which are .json files containing information about accessibility errors in the websites tested). You can send your results to axe Developer Hub by specifying an API key on the command line with the --axe-devhub-api-key command-line option (or by setting the AXE_DEVHUB_API_KEY environment variable) and a project ID with the --axe-devhub-project-id (or by setting the AXE_DEVHUB_PROJECT_ID environment variable).
By default, the CLI also uploads Git information if the directory where you are running the CLI is part of a Git repository. See Git versus Gitless Mode for information about how uploading Git information works.
The CLI will associate the current Git branch and commit history with your accessibility results.
When running the CLI from within a directory inside a Git repository, the results you send to axe Developer Hub will overwrite any previous results from the same commit (determined by its SHA). (Only one set of results can be associated with each commit.) You need to create a new commit every time you run the CLI or forgo reporting Git results by using the --no-git-data option. See Git versus Gitless Mode for more information.
Upload Results
If you've previously run tests and have results files (.json files typically with names such as axe-result-2025-09-03T14 02 32-0700.json), you can upload these results to axe Developer Hub with the devhub subcommand. You can save results by using the -s command-line option when testing pages or running spec files:
axe https://example.com -sWhen analyzing a page or running a spec file, you don't need to save the results first and then upload them. By specifying an API key and project ID, the CLI will upload the results when your page analysis is complete or when your spec file finishes executing. See Analyze Individual Pages and Run Spec Files.
The previous example creates a results file that you can then upload to axe Developer Hub, as shown below:
axe devhub <results-dir(s)-or-file(s)> --axe-devhub-api-key <your-API-key> --axe-devhub-product-id <your-project-ID>You can use . (dot) as the results-dir(s)-or-file(s) to upload all .json results files in the current directory. You can also specify multiple directories or files to upload.
Creating Results Files with the Web APIs
If you are using the web APIs, you will need to modify your API tests to write results files that you can then upload to axe Developer Hub using the devhub subcommand. The following table contains links to information about creating results files, and these APIs use the reporting or logging APIs provided to write results as .json files to disk.
| API | Link Name |
|---|---|
| Node.js | axe DevTools Logger |
| C# | Creating Reporter-Compatible JSON |
| Java | Generate Reports with Java |
| Python | Creating Reporter-Compatible JSON |
| Ruby | Reporting options |
Analyze Individual Pages
You can scan individual web pages and send the results to axe Developer Hub by specifying an API key and the project ID for the project to receive the results:
axe https://google.com --axe-devhub-api-key <your-API-key> --axe-devhub-project-id <your-project-ID>In this example, the CLI runs accessibility tests against Google's site and then sends the results to the axe Developer Hub project referenced by the specified project ID.
You can also list multiple pages on the command line to test:
axe https://example.com/page1.html https://example.com/page2.html --axe-devhub-api-key <your-API-key> --axe-devhub-project-id <your-project-ID>Visit the project on axe Developer Hub to see your results. See Overview of Viewing Accessibility Issues.
Run Spec Files
You can send the results from running your spec files by using the --axe-devhub-api-key and --axe-devhub-project-id command-line options.
axe spec my-spec-file.yml --axe-devhub-api-key <your-API-key> --axe-devhub-project-id <your-project-ID>This example runs the YAML spec file my-spec-file.yml and uploads its accessibility results to axe Developer Hub. See Workflow Specs and Workflows Actions for more information about spec files.
If you need to skip ahead in your spec file by bypassing the testing of pages, you can use the --resume-from <page> command-line option to resume your testing from a specific page in your spec file. See Resume from for more information.
Git versus Gitless Mode
By default, axe Developer Hub associates your accessibility results with the latest Git commit on the current branch when you run the CLI from a directory within a Git repository, letting you easily tie accessibility errors to Git commits. One side effect of this behavior, however, is that whenever you report results to axe Developer Hub, new results overwrite any other runs on the same commit (based on its SHA). Additionally, if you switch to a different branch, any results you send to axe Developer Hub will be associated with the latest commit on that branch.
If the default behavior of axe Developer Hub isn't what you prefer:
- You can use the CLI in a directory outside of a Git repository.
- You can use the
--no-git-datacommand-line option to forgo the reporting of Git information to the server, running in what is called Gitless mode where each time you report results to the server, a new test run is created and identified by time and date of the run rather than the branch and commit as when running in Git mode.
See Your Project's Pages and The Test Runs Page for information about how Git and Gitless results are organized and presented in axe Developer Hub.
Command-Line Options
The CLI accepts these command-line options:
--axe-devhub-api-keyAllows you to set your personal API key, equivalent to theAXE_DEVHUB_API_KEYenvironment variable. Required--axe-devhub-project-idSets the project ID for your axe Developer Hub project, equivalent to theAXE_DEVHUB_PROJECT_IDenvironment variable. Required--axe-devhub-server-urlLets you use a server other than the default (https://axe.deque.com), equivalent to theAXE_DEVHUB_SERVER_URLenvironment variable. Optional--no-git-dataAvoids reporting Git information to the server. See Git versus Gitless Mode for more information. Does not have an equivalent environment variable. Optional
Environment Variables
You can set environment variables to avoid specifying the API key, project ID, or server URL on the command line, which is recommended when using the API key in continuous integration to keep it secret.
Setting AXE_DEVHUB_API_KEY and AXE_DEVHUB_PROJECT_ID will always send results to axe Developer Hub whenever you analyze a page or run a spec file. For instance, if you've set these environment variables and analyze a page with:
axe https://somewebsite.comThe results will be sent to axe Developer Hub. This behavior applies when you use the CLI to analyze a page or run a spec file.
AXE_DEVHUB_API_KEYSpecifies your personal API key, equivalent to the--axe-devhub-api-keycommand-line option.AXE_DEVHUB_PROJECT_IDSpecifies the project ID for your axe Developer Hub project, equivalent to the--axe-devhub-project-idcommand-line option.AXE_DEVHUB_SERVER_URLSpecifies the server URL for axe Developer Hub (default ishttps://axe.deque.com), equivalent to the--axe-devhub-server-urlcommand-line option.
