If you use Fern’s SDK Generator, you can automatically show SDK code snippets in your API Reference. SDK languages appear in a drop-down. By default, cURL snippets will be displayed to users.

To configure SDK snippets, you’ll need to name your SDKs in generators.yml and then reference that name in docs.yml. In the following example, we’ll use your-organization as the package name because it is a common practice. For example, Stripe calls their npm package stripe and Twilio calls their PyPI package twilio.
In order to generate code snippets, Fern needs to read request examples from your API definition. If you’re using a Fern Definition, you can follow these instructions. If you’re using an OpenAPI Specification, you can follow these instructions.
Configure package names in your generators.yml file:
package-name: your-package-name to the output section.repository: your-organization/your-repository to the github section.SDK snippets automatically populated in your Fern Docs is a paid feature included in the SDK Basic plan.
Add the package name for the corresponding SDK to your docs.yml file:
your-package-name must match the your-package-name that you configured in your generators.yml file.https://github.com/.As the final step, trigger your docs generation by running fern generate --docs locally or in CI/CD (i.e., GitHub Actions). The SDK snippets will now appear via a drop-down!
SDK code snippets support several languages. Our development work is driven by customer requests, so please request support for languages not listed here by opening an issue.
To set the default snippet language, use the default-language key at the top indentation level of docs.yml.
If you’d like to bring SDK snippets into your own documentation, you can use the Snippets API. API access requires a SDK Business plan or above.
Merge.dev is an example of a Fern customer that uses the Snippets API to bring Python code samples into their API Reference.
Looking for information on generating API endpoint request and response snippets? See our documentation on Endpoint Request Snippets and Endpoint Response Snippets.