Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions advanced/rest-api/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,23 @@ title: Overview

## Trigger Updates

Leverage the REST API to programmatically trigger an update when desired.
The primary use-case will be to trigger updates. We will be adding more and more
functionality to the API overtime. Let us know what else you want to see in
[our community](https://mintlify.com/community)!
Use our REST API to trigger updates programmatically. More API functionality is in development - share feature requests in [our community](https://mintlify.com/community).

## Authentication

You can generate an API key through
[the dashboard](https://dashboard.mintlify.com/settings/integrations). The API key is
associated with the entire org and can be used across multiple deployments.
Generate your API key in [the dashboard](https://dashboard.mintlify.com/settings/integrations). One API key works for all deployments in your org.

<Frame>
<img src="/images/external-api-key.png" />
</Frame>

## Discovery API

The Discovery API allows you to embed an AI chat experience grounded in your docs and continually kept up to date into any application of your choosing.
Responses include citations so you can point your users to the right places they need to get help.
The Discovery API lets you embed AI chat into any app. The chat is powered by your docs and provides cited responses to help users find information.

## Getting Started

To get started, you'll need to generate a Discovery API key in the [dashboard](https://dashboard.mintlify.com/products/chat/widget):
1. Generate a Discovery API key in the [dashboard](https://dashboard.mintlify.com/products/chat/widget):

<Frame>
<img
Expand All @@ -36,10 +30,7 @@ To get started, you'll need to generate a Discovery API key in the [dashboard](h
</Frame>

<Note>
The Discovery API token is a public token that can be referenced in your
frontend code whereas the API key is a server-side token that should be kept
secret.
Discovery API tokens are public and safe for frontend code. API keys are for server-side use only and should remain private.
</Note>

Now that you have an API key, check out our [example](https://github.com/mintlify/discovery-api-example) for how to use
the API for AI chat. You can also see a deployed version of this example at [chat.mintlify.com](https://chat.mintlify.com).
See our [example implementation](https://github.com/mintlify/discovery-api-example) or check out the live demo at [chat.mintlify.com](https://chat.mintlify.com).
25 changes: 10 additions & 15 deletions advanced/subpath/cloudflare.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ description: "Host documentation at a /docs subpath using Cloudflare Workers"

## Create Cloudflare Worker

Navigate to the `Workers & Pages > Create application > Create worker`. You
should be able to presented with the following screen where you can create a new
Cloudlfare worker.
Go to `Workers & Pages > Create application > Create worker` to set up a new Cloudflare worker.

<Frame>
<img alt="Create a Cloudflare worker" src="/images/cloudflare/worker.png" />
</Frame>

### Add custom domain

Once the worker is created, click `Configure worker`. Navigate to the worker
`Settings > Triggers`. Click on `Add Custom Domain` to add your desired domain
into the list - we recommend you add both the version with and without `www.`
prepended to the domain.
After creating the worker:
1. Click `Configure worker`
2. Go to `Settings > Triggers`
3. Click `Add Custom Domain`
4. Add your domain (both with and without `www.`)

<Frame>
<img
Expand All @@ -27,21 +26,18 @@ prepended to the domain.
/>
</Frame>

If you have trouble setting up a custom subdirectory,
[contact our support team](mailto:[email protected]) and we'll walk you through
upgrading your hosting with us.
Need help? [Contact our support team](mailto:[email protected]) for hosting upgrades.

### Edit Worker Script

Click on `Edit Code` and add the following script into the worker's code.
Click `Edit Code` and add this script:

<Frame>
<img alt="Cloudflare edit code" src="/images/cloudflare/edit-code.png" />
</Frame>

<Tip>
Edit `DOCS_URL` by replacing `[SUBDOMAIN]` with your unique subdomain and
`CUSTOM_URL` with your website's base URL.
Replace `[SUBDOMAIN]` with your subdomain and `CUSTOM_URL` with your website's URL in `DOCS_URL`.
</Tip>

```javascript
Expand Down Expand Up @@ -76,5 +72,4 @@ async function handleRequest(request) {
}
```

Click on `Deploy` and wait for the changes to propagate (it can take up to a few
hours).
Deploy and wait for changes to propagate (up to a few hours).
27 changes: 12 additions & 15 deletions api-playground/mdx/configuration.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
title: 'MDX Setup'
description: 'Generate docs pages for your API endpoints using MDX'
description: 'Generate API docs using MDX'
---

Mintlify allows you to define your API endpoints using a combination of `mint.json` configuration, MDX metadata fields, and the `<ParamFields />` component. From the defined endpoints, we generate an API playground, request examples, and response examples.
Define your API endpoints using `mint.json` config, MDX metadata, and the `<ParamFields />` component to generate an API playground with request and response examples.

<Steps>
<Step title="Configure your API">
In your `mint.json` file, define your base URL and auth method:
Add API configuration to your `mint.json`:

```json
{
Expand All @@ -20,7 +20,7 @@ Mintlify allows you to define your API endpoints using a combination of `mint.js
}
```

If you would not like to show an API playground, you don't need to include auth types. Hide the playground with the following field:
To hide the API playground:

```json
{
Expand All @@ -32,12 +32,11 @@ Mintlify allows you to define your API endpoints using a combination of `mint.js
}
```

Find a full list of API configurations [here](/settings/global#api-configurations).
See all API configurations [here](/settings/global#api-configurations).
</Step>

<Step title="Create your endpoint pages">

Each API endpoint page should have a corresponding MDX file. At the top of each file, define:
<Step title="Create endpoint pages">
Create an MDX file for each endpoint with the required metadata:

```md
---
Expand All @@ -46,20 +45,18 @@ Mintlify allows you to define your API endpoints using a combination of `mint.js
---
```

You can specify path parameters by adding the parameter name to the path, wrapped with `{}`:
For path parameters, use `{}`:

```bash
https://api.example.com/v1/endpoint/{userId}
```

<Note>

If you have `baseUrl` configured in [mint.json](/settings/global), you can use relative paths like `/v1/endpoint`.

With `baseUrl` configured in mint.json, you can use relative paths like `/v1/endpoint`
</Note>
</Step>

<Step title="Add your endpoints to your docs">
Add your endpoint pages to the sidebar by adding the paths to the `navigation` field in your `mint.json`. Learn more about structuring your docs [here](/settings/navigation).
<Step title="Add to navigation">
Add endpoint pages to your sidebar in `mint.json`'s `navigation` field. See [navigation docs](/settings/navigation).
</Step>
</Steps>
</Steps>
123 changes: 30 additions & 93 deletions api-playground/openapi/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ description: "Reference OpenAPI endpoints in your docs pages"

## Add an OpenAPI specification file

To describe your endpoints with OpenAPI, make sure you have a valid OpenAPI
document in either JSON or YAML format that follows the
[OpenAPI specification](https://swagger.io/specification/). Your document must
follow OpenAPI specification 3.0+.
Add your OpenAPI document (JSON or YAML) following the [OpenAPI 3.0+ specification](https://swagger.io/specification/).

## Auto-populate API pages

The fastest way to get started with OpenAPI is to add an `openapi` field to a tab or anchor in the `mint.json`. This field can contain either the path to an OpenAPI document in your docs repo, or the URL of a hosted OpenAPI document. Mintlify will automatically generate a page for each OpenAPI operation and place them in the tab/anchor.
The quickest setup: Add an `openapi` field to your `mint.json` under a tab or anchor. Use either a file path or URL to your OpenAPI doc.

**Example with Anchors:**
**Using Anchors:**

```json {5}
{
Expand All @@ -29,9 +26,7 @@ The fastest way to get started with OpenAPI is to add an `openapi` field to a ta
}
```

![](/images/anchors-autogeneration-anchors.png)

**Example with Tabs:**
**Using Tabs:**

```json {6}
{
Expand All @@ -45,108 +40,50 @@ The fastest way to get started with OpenAPI is to add an `openapi` field to a ta
}
```

![](/images/autogeneration-with-tabs.png)

<Tip>To validate your OpenAPI spec, you can use this command: <br/>`mintlify openapi-check <openapiFilenameOrUrl>`</Tip>


When using this option, the metadata for the generated pages will have the following default values:

* `title`: The `summary` field from the OpenAPI operation, if present. Otherwise a title generated from the HTTP method and endpoint.

* `description`: The `description` field from the OpenAPI operation, if present.

* `version`: The `version` value from the anchor or tab, if present.
<Tip>Validate your OpenAPI spec: `mintlify openapi-check <openapiFilenameOrUrl>`</Tip>

There are some scenarios in which the default behavior isn't sufficient. If you need more customizability, you can create an MDX page for your OpenAPI operation, and modify it just like any other MDX page.
Default page metadata will use:
- `title`: OpenAPI operation's `summary` or auto-generated from method/endpoint
- `description`: OpenAPI operation's `description`
- `version`: Anchor/tab's version value

## Create MDX files for API pages
## Custom API Pages

If you want to customize the page metadata, add additional content, omit certain OpenAPI operations, or reorder OpenAPI pages in your navigation, you'll need an MDX page for each operation. Here is [an example MDX OpenAPI page](https://github.com/elevenlabs/elevenlabs-docs/blob/e5e267c97b8d1e4c21db1dcdb8b005eb1dfed7da/api-reference/speech-to-speech.mdx?plain=1#L2) from [Elevenlabs](https://elevenlabs.io/docs/api-reference/speech-to-speech).&#x20;
Need more control? Create MDX pages for your API operations.

![](/images/elevenlabs-mdx-autogeneration-example.png)

### Autogenerate files

For large OpenAPI documents, creating one MDX page for each OpenAPI operation can be a lot of work. To make it easier, we created a local OpenAPI page scraper.

Our Mintlify [scraper](https://www.npmjs.com/package/@mintlify/scraping)
autogenerates MDX files for your OpenAPI endpoints. Use the relative path to the
OpenAPI document in your codebase.

```bash
npx @mintlify/scraping@latest openapi-file <path-to-openapi-file>
```
### Generate MDX Files Automatically

Add the `-o` flag to specify a folder to populate the files into. If a folder is
not specified, the files will populate in the working directory.
For large APIs, use our scraper to generate MDX files:

```bash
npx @mintlify/scraping@latest openapi-file <path-to-openapi-file> -o api-reference
```

Learn more about our scraping package [here](https://www.npmjs.com/package/@mintlify/scraping).

The scraper will output an array of
[Navigation entries](/settings/global#structure) containing your OpenAPI MDX
files. You can either append these entries to your existing Navigation, or
reorder and add the files to your navigation manually.

<Note>
If your OpenAPI document is invalid, the files will not autogenerate.
Invalid OpenAPI docs won't generate files.
</Note>

### Manually specify files

You can always create an MDX page manually, and reference the OpenAPI operation in the page's metadata using the `openapi` field.

<Snippet file="api-playground/openapi.mdx" />

By using the OpenAPI reference, the name, description, parameters, responses,
and the API playground will be automatically generated from the OpenAPI document.

If you have multiple OpenAPI files, include the path to the OpenAPI file to ensure Mintlify finds the correct OpenAPI document. This is not required if you have
only one OpenAPI file - it will automatically detect your OpenAPI file.

<CodeGroup>
```md Example
---
title: "Get users"
openapi: "/path/to/openapi-1.json GET /users"
---
```
### Manual MDX Creation

```md Format
---
title: "title of the page"
openapi: openapi-file-path method path
---
```
</CodeGroup>
Create custom MDX pages by referencing OpenAPI operations in the frontmatter:

<br />
```md
---
title: "Get users"
openapi: "/path/to/openapi.json GET /users"
---
```

<Note>
The method and path must match the method and path specified in the OpenAPI
document exactly. If the endpoint doesn't exist in the OpenAPI file,
the page will be empty.
Method and path must exactly match your OpenAPI document.
</Note>

## Create MDX files for OpenAPI schemas
## OpenAPI Schema Pages

Mintlify also allows you to create individual pages for any OpenAPI schema
defined in an OpenAPI document's `components.schemas` field:
Create pages for schema definitions using:

<CodeGroup>
```md Example
---
openapi-schema: OrderItem
---
```

```md Format
---
openapi-schema: "schema-key"
---
```
</CodeGroup>
```md
---
openapi-schema: "schema-key"
---
```
8 changes: 4 additions & 4 deletions code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ icon: 'code'

### Inline Code

To denote a `word` or `phrase` as code, enclose it in backticks (`).
Use backticks (`) to mark `code` within text.

```
To denote a `word` or `phrase` as code, enclose it in backticks (`).
Use backticks (`) to mark `code` within text.
```

### Code Block

Use [fenced code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks) by enclosing code in three backticks and follow the leading ticks with the programming language of your snippet to get syntax highlighting. Optionally, you can also write the name of your code after the programming language.
Create code blocks using three backticks. Add a language name for syntax highlighting, and optionally a filename.

```java HelloWorld.java
class HelloWorld {
Expand All @@ -36,4 +36,4 @@ class HelloWorld {
```
````

Visit the [Code Block page](/content/components/code) for more detailed docs.
For more details, see the [Code Block page](/content/components/code).
Loading
Loading