Docs
ENFR
Dashboard
Resources

Client libraries

Generate a typed client for your language, or explore the API with Postman.

Monerail has no official SDK yet. The API is plain HTTPS and JSON, so any HTTP client works: every endpoint of the API reference has examples in curl, Node.js, Python, PHP, Go, Java, Ruby and C#.

For a typed client, generate one from the OpenAPI 3.1 file: https://docs.monerail.com/openapi.json.

Generate a client

OpenAPI Generator needs Java 11 or later (or Docker). With npm:

bash
npm install --save-dev @openapitools/openapi-generator-cli
npx openapi-generator-cli version-manager set 7.9.0

Then, for your language:

bash
SPEC=https://docs.monerail.com/openapi.json

# TypeScript (fetch)
npx openapi-generator-cli generate -i $SPEC -g typescript-fetch -o monerail-ts \
  --additional-properties=npmName=monerail-client,supportsES6=true

# Python
npx openapi-generator-cli generate -i $SPEC -g python -o monerail-python \
  --additional-properties=packageName=monerail

# PHP
npx openapi-generator-cli generate -i $SPEC -g php -o monerail-php \
  --additional-properties=invokerPackage=Monerail

# Go
npx openapi-generator-cli generate -i $SPEC -g go -o monerail-go \
  --additional-properties=packageName=monerail

# Java (java.net.http)
npx openapi-generator-cli generate -i $SPEC -g java --library native -o monerail-java \
  --additional-properties=groupId=com.example,artifactId=monerail-client,invokerPackage=com.example.monerail,apiPackage=com.example.monerail.api,modelPackage=com.example.monerail.model

# Ruby
npx openapi-generator-cli generate -i $SPEC -g ruby -o monerail-ruby \
  --additional-properties=gemName=monerail

# C# (.NET 8)
npx openapi-generator-cli generate -i $SPEC -g csharp -o monerail-csharp \
  --additional-properties=packageName=Monerail,targetFramework=net8.0

Without npm, use Docker: docker run --rm -v "$PWD:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i https://docs.monerail.com/openapi.json -g python -o /local/monerail-python.

Use the generated client

The client takes the base URL https://api.monerail.com and your key as a bearer token. Operations are grouped by resource, and POST operations take an optional idempotency key.

import { CollectionsApi, Configuration } from './monerail-client';

const collections = new CollectionsApi(
  new Configuration({ basePath: 'https://api.monerail.com', accessToken: process.env.MONERAIL_KEY }),
);

const collection = await collections.createCollection({
  idempotencyKey: 'order-42',
  createCollectionRequest: {
    amount: 5000,
    currency: 'XAF',
    phone: '237670000999',
    operator: 'MTN',
    customer: { name: 'Awa Ndiaye' },
  },
});
console.log(collection.id, collection.status);

Keep in mind:

  • Generated clients validate responses against the schemas. We add fields without notice (Versioning): regenerate from time to time, and prefer settings that ignore unknown fields.
  • Errors come back as exceptions carrying the HTTP status and the JSON error. Branch on error.code.
  • Pin the generator version (7.9.0 above) so a regeneration does not change your code by surprise.

Postman

Download the Postman collection (format v2.1) and import it in Postman (Import, then choose the file).

  • Set the collection variable apiKey to a test key (mr_test_…). baseUrl is already https://api.monerail.com.
  • Requests use bearer authentication from the collection. Each has an example body and a saved example response.
  • Requests that move money send Idempotency-Key: {{$guid}}, a new value at each send. To retry the exact same operation safely, replace it with a fixed value.