Markdown to HTML Conversion API
The Markdown to HTML Conversion API allows users to transform Markdown content into beautifully styled HTML. This API is designed to help users easily publish AI-generated Markdown content on various media platforms such as WeChat Official Accounts, Bilibili, Baidu Baijiahao, Toutiao, and more.
API Protocol
End Point
POSThttps://huntwiz.com/v1/markdown-to-html
params
parameter | type | description | default |
---|---|---|---|
markdown* | string | Markdown content to be converted | |
style | string | Predefined style template to use | default |
Code Example
curl -X POST 'https://huntwiz.com/v1/markdown-to-html'--header 'Authorization: Bearer {api_key}'--header 'Content-Type: application/json'--data-raw '{"markdown": "# Hello World\n\nThis is a **bold** text.","style": "wechat"}'
Note: The
markdown
parameter should contain valid Markdown content. Thestyle
parameter allows you to choose from predefined templates optimized for different platforms.
Response Format
The API will return a JSON object containing the converted HTML:
{"status": "success","html": "<h1>Hello World</h1>\n<p>This is a <strong>bold</strong> text.</p>","metadata": {"usage": {"credits": 1,"remark": "api used for /v1/markdown-to-html"},"content": {"originalLength": 35,"convertedLength": 62,"styleUsed": "default"}}}
Billing
Billing is based on the length of the input Markdown content:
- Each API call deducts 1 Credit for every 1000 characters in the input Markdown
- A minimum of 1 Credit is deducted per call, even for inputs shorter than 1000 characters
Notes:
- Credits are deducted based on the input Markdown length, regardless of the complexity of the conversion.
- The system checks if the account has sufficient Credits before starting the conversion. If Credits are insufficient, the API will return an error without performing the conversion.
- You can view the number of Credits consumed for this request in the metadata of the API response.
Error Handling
In case of an error, the API will return a JSON object containing error details:
{"status": "error","error": {"code": "invalid_markdown","message": "The provided Markdown content is invalid or empty"}}
Common error codes include:
invalid_markdown
: The provided Markdown content is invalid or emptyinvalid_style
: The specified style template doesn't existinsufficient_credits
: The account doesn't have enough Credits for this conversionrate_limit_exceeded
: API call frequency limit exceeded
Limitations
- API is limited to 60 requests per minute
- Maximum input Markdown length is 100,000 characters
- Supported style templates: 'default', 'wechat', 'bilibili', 'baijiahao', 'toutiao'
- The API does not support custom CSS injection for security reasons
- Images referenced in the Markdown are not hosted or modified by this API
Predefined Style Templates
The API offers the following predefined style templates:
default
: A clean, responsive design suitable for general web publishingwechat
: Optimized for WeChat Official Accounts, with appropriate font sizes and spacingbilibili
: Styled to match Bilibili's article format, including custom blockquote stylesbaijiahao
: Tailored for Baidu Baijiahao, with optimized headings and link colorstoutiao
: Designed to fit Toutiao's article style, including appropriate image sizing
To use a specific template, include the style
parameter in your API call.
Usage Suggestions
- Always validate your Markdown content before sending it to the API to ensure it's well-formed.
- Choose the appropriate style template based on your target publishing platform for the best results.
- If your Markdown contains images, ensure they are hosted on a reliable CDN for consistent rendering across platforms.
- For the best performance, consider batching multiple small Markdown conversions into a single API call when possible.
If you have any questions or need further assistance, please feel free to contact our technical support team.