Quickstart

Set up the fern folder

Configuring Fern starts with the fern folder, the root directory that contains your API definitions, generators, and your CLI version.

Set up the fern folder

1

Install the Fern CLI

Run the following command to install the CLI tool or update it to the latest version:

$npm install -g fern-api
2

Initialize the Fern Folder

You can initialize your fern folder with either a Fern Definition or OpenAPI specification.

You can always convert a Fern Definition to OpenAPI or OpenAPI to a Fern Definition later on.

Initialize the fern folder using your OpenAPI Specification. Fern can handle both JSON and YML formats for OpenAPI specifications and the --openapi flag accepts either format, so you can use whichever format your API spec is available in.

Run one of the following commands based on your spec’s location:test

$fern init --openapi path/to/openapi.yml \
>--organization <YourOrganization>

--organization <YourOrganization> configures your organization name in fern.config.json. This is required in order to successfully generate your SDK.

This creates a fern folder in your current directory with the OpenAPI Specification. The exact folder structure might look different depending on your initial input files.

$fern/
> ├─ fern.config.json # root-level configuration
> └─ api/ # your API
> ├─ generators.yml # generators you're using
> └─ openapi/
> ├─ openapi.yml # API-level configuration
  1. Initialize the fern folder using the Fern Definition by running the following command:

    $fern init --organization <YourOrganization>

    --organization <YourOrganization> configures your organization name in fern.config.json. This is required in order to successfully generate your SDK.

    This creates a fern folder in your current directory with the Fern Definition.

    $fern/
    > ├─ fern.config.json # root-level configuration
    > ├─ generators.yml # generators you're using
    > └─ definition/
    > ├─ api.yml # API-level configuration
    > └─ imdb.yml # endpoints, types, and errors
    imdb.yml contains an example movies API. If you’re just generating an SDK for test purposes, you can leave this file as it is. To generate an SDK for your own API instead of the example movies API, replace imdb.yml with your own endpoints, types, and errors before proceeding with the rest of this page.
3

Next: Set up your repository structure

Now that you have your fern folder initialized, learn how to organize your repositories for SDK generation.