> ## Documentation Index
> Fetch the complete documentation index at: https://dev.moonpay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate API clients

> Generate type-safe API clients from the OpenAPI specification.

The MoonPay Developer Platform API is defined using an OpenAPI 3.1 specification. You can use this spec to generate typed clients for any language.

## Full specification

The OpenAPI 3.1 specification is served at **[https://api.moonpay.com/platform/openapi.json](https://api.moonpay.com/platform/openapi.json)**. Use this URL in your codegen config or download the file for offline use.

## Usage

### TypeScript / JavaScript

Use `@hey-api/openapi-ts` to generate TypeScript types:

```bash theme={null}
npm install -D @hey-api/openapi-ts
```

```ts openapi-ts.config.ts theme={null}
import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
  input: "https://api.moonpay.com/platform/openapi.json",
  output: {
    path: "./src/gen",
  },
  plugins: [
    {
      name: "@hey-api/typescript",
      enums: false,
    },
  ],
});
```

```bash theme={null}
npx openapi-ts
```

### Dart / Flutter

Use the [OpenAPI Generator CLI](https://openapi-generator.tech/docs/installation/) with its [Dart client generator](https://openapi-generator.tech/docs/generators/dart/).

Before you start, install Node.js with npm, Java 11 or later, and the Dart or Flutter SDK. Run the following commands from your app's root directory. Generating the client does not require API credentials.

<Steps>
  <Step title="Install the generator">
    ```bash theme={null}
    # Local terminal
    npm install --global @openapitools/openapi-generator-cli
    ```
  </Step>

  <Step title="Generate the client package">
    ```bash theme={null}
    # Local terminal
    openapi-generator-cli generate \
      -i https://api.moonpay.com/platform/openapi.json \
      -g dart \
      -o ./generated/moonpay_api \
      --additional-properties=pubName=moonpay_api
    ```

    This creates a Dart package named `moonpay_api` in `generated/moonpay_api`, including API methods, models, and its own `pubspec.yaml`.
  </Step>

  <Step title="Add the generated package to your app">
    Add this [path dependency](https://dart.dev/tools/pub/dependencies#path-packages) to the `dependencies` section of your app's `pubspec.yaml`:

    ```yaml theme={null}
    # App's pubspec.yaml
    dependencies:
      moonpay_api:
        path: generated/moonpay_api
    ```

    Install the package and its dependencies:

    ```bash theme={null}
    # Local terminal, Flutter app
    flutter pub get
    ```

    For a Dart app, run `dart pub get` instead. See the generated `generated/moonpay_api/README.md` for imports, API methods, and authentication configuration.
  </Step>
</Steps>

### Other Languages

Use the [OpenAPI Generator](https://openapi-generator.tech/) CLI to generate clients for 50+ languages:

```bash theme={null}
# Install
npm install @openapitools/openapi-generator-cli -g

# Generate (examples)
openapi-generator-cli generate -i https://api.moonpay.com/platform/openapi.json -g kotlin -o ./gen
openapi-generator-cli generate -i https://api.moonpay.com/platform/openapi.json -g swift5 -o ./gen
openapi-generator-cli generate -i https://api.moonpay.com/platform/openapi.json -g python -o ./gen
openapi-generator-cli generate -i https://api.moonpay.com/platform/openapi.json -g go -o ./gen
```

See the [full list of generators](https://openapi-generator.tech/docs/generators).
