Card API

Generate customizable card SVGs with glyphs

GET /api/v1/card/svg Available
GET /api/v1/card/png Available

Playground

Test the Card API in real-time by editing the URL below. The card will update automatically as you type.

Quick Presets:

Description

The Card API generates card SVGs with embedded glyphs. Cards have standard dimensions (51.5mm × 81mm by default) and include colorization by default. This endpoint is perfect for creating printable cards with custom glyph content.

Default Values

  • colorized: true
  • cardWidth: 51.5mm
  • cardHeight: 81mm

Parameters

ParameterTypeRequiredDescriptionExample
duodstringGlyph identifier (0-9, A-B)0, 5, A
heightnumberHeight value for the glyph100
bordernumberBorder width5
thiccnessnumberThickness of glyph elements10
barJSON arrayFraction array for bar elements[1,2]
colorstringPrimary color (CSS color)blue, #FF0000
fillJSON arrayFill colors array["red", "blue"]
viewBoxstringSVG viewBox attribute0 0 100 100
colorizedbooleanEnable colorization (default: true)true, false
svgWstringSVG width attribute200
svgHstringSVG height attribute200
borderColorstringBorder color (CSS color)black, #000000
backgroundColorstringBackground color (CSS color)white, #FFFFFF

Response

Headers

Content-Type: image/svg+xml
Cache-Control: public, max-age=31536000, immutable

Body

Valid SVG markup representing the generated card with embedded glyph

Examples

Basic Card

GET /api/v1/card/svg?duod=0
Basic card

Card with Specific Glyph

GET /api/v1/card/svg?duod=5
Card with glyph 5

Card with Custom Color

GET /api/v1/card/svg?duod=A&color=red
Red card

Card without Colorization

GET /api/v1/card/svg?duod=7&colorized=false
Non-colorized card

Card with Complex Parameters

GET /api/v1/card/svg?duod=B&height=120&border=3&thiccness=12&color=blue&backgroundColor=lightgray
Complex card

Card Dimensions

By default, cards are sized to standard playing card dimensions:

  • Width: 51.5mm (poker card width)
  • Height: 81mm (poker card height)
  • Aspect Ratio: ~1.57:1

These dimensions make the cards suitable for printing and physical use.

Usage in HTML

Cards can be embedded directly in HTML:

<img src="/api/v1/card/svg?duod=5&color=blue" alt="Card" />

For responsive design, you can control the display size with CSS:

img.card {
  width: 100%;
  max-width: 200px;
  height: auto;
}

Print Considerations

Cards are designed with print production in mind:

  • Vector format: SVG scales perfectly for high-resolution printing
  • Standard dimensions: Compatible with card printing services
  • Color support: Full color customization for branding
  • Consistent sizing: All cards maintain the same dimensions

Error Handling

The API handles invalid parameters gracefully:

  • Invalid JSON in bar or fill parameters will be ignored
  • Invalid colors will fall back to default values
  • Invalid numeric values will be ignored
  • Unknown parameters are ignored
  • Invalid colorized values default to true

PNG Endpoint

Note: PNG endpoints are now available and fully functional!

PNG endpoints accept all the same parameters as SVG endpoints, plus additional PNG-specific options:

  • scale - Scale factor for higher resolution (e.g., scale=2 for 2x resolution)
  • pngWidth - Target width in pixels
  • pngHeight - Target height in pixels
  • pngBackground - Background color (supports transparent, white, #FF0000, etc.)

PNG endpoints are perfect for:

  • Social media sharing
  • Email newsletters
  • Applications that don't support SVG
  • Thumbnail generation
  • High-resolution printing

PNG Example

GET /api/v1/card/png?duod=5&scale=2&pngBackground=white