Download API Definitions From SwaggerHub

SwaggerHub lets you download the API definition of any API or domain in the YAML or JSON format.

Download from SwaggerHub Editor

  1. Open the API in the SwaggerHub editor.

  2. If the API has several versions, select the version you want to download.

    Selecting an API version
  3. From the Export menu, select Download API, and then select the desired format – YAML or JSON.

    Downloading an API definition as YAML or JSON

There are options to download either a resolved or an unresolved definition. This makes a difference if your definition includes external $ref links, such as links to domains.

  • Unresolved means external links will not be resolved, and the resulting file will contain the $ref links as they appear in the editor.

  • Resolved means external links will resolved, that is, the contents of external files will be included in the resulting definition.

Download via a URL

Public APIs

A quick way to download API definitions from SwaggerHub is to replace app with api in the address bar, as shown below.

Remove that part if the URL ends with a  permalink  to a tag or operation, such as  #/pets
Downloading an API definition from the address bar

In SwaggerHub On-Premise, add /v1 after the host name instead:

Downloading an API definition from the address bar

The download URL has the following format:{owner}/{api}/{version}         # SwaggerHub SaaS
http(s)://{swaggerhub-host}/v1/apis/{owner}/{api}/{version}     # SwaggerHub On-Premise

You can also use tools like cURL to download definitions from SwaggerHub:


This downloads the API definition as JSON. If you want YAML, either append /swagger.yaml at the end, or use the Accept: application/yaml header:

curl -H "Accept: application/yaml"

Resolved YAML/JSON

This information applies to SwaggerHub SaaS, SwaggerHub On-Premise 1.25.0 and later.

To get a resolved API definition, append ?resolved=true to the download URL.

Resolved YAML:{owner}/{api}/{version}/swagger.yaml?resolved=true

Resolved JSON:{owner}/{api}/{version}?resolved=true

In SwaggerHub On-Premise:


Private APIs

If the API definition is private, add the Authorization: API_KEY header containing your SwaggerHub API key:

curl -H "Authorization: API_KEY"{owner}/{api}/{version}

Maven and Gradle plugins

SwaggerHub has plugins for Maven and Gradle that allow you to download API definitions as part of your CI/CD pipeline.

See Also

Publication date: