Skip to content

This is a simple API for generating signatures with Google Fonts API and OpenType.js.

License

Notifications You must be signed in to change notification settings

onurravli/signature-api

Repository files navigation

Signature API

This is a simple API for generating signatures with Google Fonts API and OpenType.js.

Live Demo

Prerequisites

  • Node.js
  • pnpm (or npm, ofc)
  • Google Fonts API Key

Installation

  1. Clone the repository
git clone https://github.com/onurravli/signature-api.git
  1. Install dependencies:
pnpm install
  1. Copy .env.example to .env and set your Google Fonts API key:
GOOGLE_FONTS_API_KEY=your_api_key_here

API Endpoints

Generate Signature

Generate a signature in SVG or PNG format.

Endpoint: POST /api/v1/signature

Request Body Parameters:

Parameter Type Required Default Description
name string Yes - The text to convert into signature
font string Yes - Google Font family name
color string Yes - Color in any valid CSS format (hex, rgb, etc.)
fontSize number No 72 Font size in pixels
fontWeight number or string Yes - Font weight (e.g., 400, 700, "regular", "bold")
padding number No 20 Padding around the signature in pixels
apiKey string No - Google Fonts API key (optional if set in .env)
response string No - Response format: "svg", "png", or both if empty

Example Request:

{
  "name": "John Doe",
  "font": "Dancing Script",
  "color": "#000000",
  "fontSize": 72,
  "fontWeight": 400,
  "padding": 20,
  "response": "svg"
}

Example Response:

For SVG response:

{
  "svg": "<svg>...</svg>"
}

For PNG response:

{
  "png": "data:image/png;base64,..."
}

For default response (both formats):

{
  "svg": "<svg>...</svg>",
  "png": "data:image/png;base64,...",
  "width": 300,
  "height": 150,
  "name": "John Doe",
  "font": "Dancing Script",
  "color": "#000000",
  "fontSize": 72,
  "fontWeight": 400,
  "padding": 20
}

Screenshot

Error Handling

The API returns appropriate HTTP status codes and error messages:

  • 200 OK: Request successful
  • 500 Internal Server Error: Server-side error with error message in response

Error Response Format:

{
  "error": "Error message description"
}

Development

  1. Start the development server:
pnpm dev
  1. Build for production:
pnpm build
  1. Start production server:
pnpm start

License

MIT License. See LICENSE.md for more details.

About

This is a simple API for generating signatures with Google Fonts API and OpenType.js.

Resources

License

Stars

Watchers

Forks