Skip to content

Generate an SDK from the CryptoSwift OpenAPI spec

Generate backend SDKs from the CryptoSwift OpenAPI specification.

Use the CryptoSwift OpenAPI specification to generate backend SDKs for your integration. OpenAPI Generator supports a wide range of languages and frameworks, so the TypeScript and Python commands below are examples rather than the only supported targets. Keep generated clients server-side because authenticated CryptoSwift requests require X-Api-Key.

OpenAPI source

https://api.cryptoswift.eu/api-json

Prerequisite

The OpenAPI Generator CLI requires Java. Install Java before running the generator and verify it is available:

java -version

See the OpenAPI Generator documentation for installation options, supported generators, and language-specific configuration.

Language support

OpenAPI Generator supports many API client targets, including TypeScript, JavaScript, Python, Java, Go, Kotlin, C#, PHP, Ruby, Rust, Swift, Scala, Bash, PowerShell, and many framework-specific variants. For the full and current list, use the generator docs instead of copying the language matrix into your project docs.

Generate a TypeScript SDK

Command:

npx @openapitools/openapi-generator-cli generate -i https://api.cryptoswift.eu/api-json -g typescript-fetch -o cryptoswift-typescript

Generate a Python SDK

Command:

openapi-generator-cli generate -i https://api.cryptoswift.eu/api-json -g python -o cryptoswift-python

To generate another language, replace the -g value with the generator name from the OpenAPI Generator docs.

Configure the base URL

The CryptoSwift OpenAPI spec includes both environments:

  • Production: https://api.cryptoswift.eu
  • Test: https://api-dev.cryptoswift.eu

Generated clients may default to the first server in the OpenAPI spec, which is production. Do not rely on that default. Configure the generated client's base URL at runtime and default your application to the test API first:

import { Configuration, TransactionsApi } from "./cryptoswift-typescript";

const apiKey = process.env.CRYPTOSWIFT_API_KEY;

if (!apiKey) {
  throw new Error("CRYPTOSWIFT_API_KEY is required");
}

const api = new TransactionsApi(
  new Configuration({
    basePath: "https://api-dev.cryptoswift.eu",
    headers: {
      "X-Api-Key": apiKey,
    },
  })
);

async function main() {
  const transaction = await api.createTransaction({
    createTransactionDto: {
      asset: "BTC",
      amount: "0.01",
      blockchainInfo: {
        blockchain: "Bitcoin",
        transactionHash: "example-test-transaction-hash",
        origin: "example-test-origin-wallet-address",
        destination: "example-test-destination-wallet-address",
        destinationType: "CUSTODIAL",
      },
      vaspInfo: {
        beneficiaryVaspName: "Example Test VASP",
      },
      originator: {
        type: "NATURAL",
        name: "Example Originator",
        accountNumber: "example-originator-account",
      },
      beneficiary: {
        type: "NATURAL",
        name: "Example Beneficiary",
        accountNumber: "example-beneficiary-account",
      },
    },
  });

  console.log({
    id: transaction.id,
    status: transaction.status,
  });
}

main().catch((error) => {
  console.error("CryptoSwift API error:", error);
  process.exit(1);
});

Keep this code in a backend process. Do not expose CRYPTOSWIFT_API_KEY or authenticated SDK calls to browser code.

The exact configuration property depends on the generated language and library. Common names are basePath, baseUrl, baseURL, or host. Keep this value outside generated code so you can test against https://api-dev.cryptoswift.eu and later run against https://api.cryptoswift.eu without regenerating the SDK.

Security notes

  • Use SDKs server-side only.
  • Never expose X-Api-Key in frontend code.
  • Load credentials from environment variables.
  • Use test API before production.
  • Do not commit .env files that contain real credentials.

After-generation checklist

  • Configure base URL.
  • Add API key auth.
  • Run integration tests against the test API.
  • Switch to production base URL and production key only through explicit deployment configuration.
  • Implement outgoing transactions.
  • Implement incoming transaction handling.
  • Implement webhook receiver.
  • Implement wallet verification.
  • Handle errors.
  • Add retries and idempotency.

Related docs