Skip to content

Latest commit

 

History

History
150 lines (89 loc) · 5.1 KB

README.md

File metadata and controls

150 lines (89 loc) · 5.1 KB

LeetCode Stats Card

Show your dynamically generated LeetCode stats on your GitHub profile or your website!

LeetCode and LeetCode CN are both supported.

Playground: Try It Now

LeetCode Stats_example

Features

  • 📈 Clean and simple LeetCode stats, for both us and cn sites
  • 🎨 Multiple themes and fonts - Theme, Font
  • 🪄 Fully customizable using CSS - Custom Stylesheets
  • ⚡️ Fast and global edge network - Cloudflare Workers
  • 🚫 No tracking, controlable cache - Cache
  • 🍀 Open source - MIT License
  • ⚙️ Extended-cards: activity, contest, heatmap

LeetCode Stats Card API Documentation

Introduction

Welcome to the LeetCode Stats Card API documentation. This API allows you to generate and embed customizable stat cards for LeetCode profiles.

Endpoints

Main Data Fetcher:

Workers: https://leet-card-gen.devagn.workers.dev/

https://leet-card-gen.devagn.workers.dev?username=YOUR_LEETCODE_USERNAME

Example: https://leet-card-gen.devagn.workers.dev?username=devagn_maniya

Extras for Card Generator

GET /api/cardgen

Generates a LeetCode stats card image.

Parameters:

  • username (required): LeetCode username
  • theme (required): Card theme (e.g., dark, light)
  • font (required): Font style for the card
  • extension (optional): File extension
  • site (optional): Site identifier

Returns: The stats card image data

GET /api/cardgenDetail

Generates embed code for the LeetCode stats card.

Parameters:

  • username (required): LeetCode username
  • theme (required): Card theme (e.g., dark, light)
  • font (required): Font style for the card
  • extension (optional): File extension
  • site (optional): Site identifier

Returns: JSON object containing embedHtml and markdown

GET /api/preview

Provides a preview of the stats card.

Parameters:

  • username (required): LeetCode username
  • theme (required): Card theme (e.g., dark, light)
  • font (required): Font style for the card
  • extension (optional): File extension
  • site (optional): Site identifier

Returns: The source of the embed code

Examples

Generating a card image:

fetch('https://leet-card-generator.onrender.com/api/cardgen?username=devagn_maniya&theme=dark&font=changa')
    .then(response => response.text())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));

Getting embed code:

fetch('https://leet-card-generator.onrender.com/api/cardgenDetail?username=devagn_maniya&theme=dark&font=changa')
    .then(response => response.json())
    .then(data => {
        console.log('Embed HTML:', data.embedHtml);
        console.log('Markdown:', data.markdown);
    })
    .catch(error => console.error('Error:', error));

Getting a preview:

fetch('https://leet-card-generator.onrender.com/api/preview?username=devagn_maniya&theme=dark&font=changa')
    .then(response => response.text())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));

Error Handling

If required parameters are missing or an error occurs, the API will return a JSON response with an error message:

{
    "error": "Username, theme, and font are required."
}

💻 Tech Stack:

NodeJS GraphQL HTML5 TailwindCSS JavaScript Cloudflare NPM

Credit

Maniya Devagn

JacobLinCool

🔗 Links

Portfolio

Freecodecamp

Leet-Code