Wynglet

GitHub Repository Stats

Embed live GitHub repository statistics (stars, forks, watchers, etc.) on your website without authentication.

Overview

The GitHub Stats API allows you to fetch and display current information about any public GitHub repository.

Features:

Getting Started

Fetch Repository Stats

Make a GET request to fetch repository statistics:

GET https://wynglet.your-server.com/github/v1/{user}/{repo}/{field}

URL Parameters:

Available Fields

Examples

Get Star Count:

https://wynglet.your-server.com/github/v1/chimbori/wynglet/stars

Response:

{
  "stars": 42
}

Display in HTML:

<p>
  Wynglet has
  <span id="stars">--</span>
  stars on GitHub
</p>

<script>
fetch('https://wynglet.your-server.com/github/v1/chimbori/wynglet/stars')
  .then(r => r.json())
  .then(data => {
    document.getElementById('stars').textContent = data.stars.toLocaleString();
  });
</script>

CORS

The GitHub Stats endpoint is fully CORS-enabled and can be called directly from any website. No preflight requests are needed.

All requests receive permissive CORS headers:

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: GET, OPTIONS

Caching

Results are cached for 1 hour to minimize requests to GitHub’s API. If you need fresh data before the cache expires, you can:

  1. Wait for the cache to expire (1 hour)
  2. Deploy a new instance with cleared caches
  3. Query multiple times to get the most recent data

Error Handling

If a request fails (invalid repository, network error, etc.), the API returns an error status with details.

Example Error Response:

{
  "error": "Repository not found"
}

Use Cases

Limitations

Configuration

The GitHub stats endpoint requires no special configuration. It uses a local disk cache to minimize GitHub API requests.

github:
  # Cache TTL is fixed at 1 hour for GitHub stats
  cache:
    ttl: 1h
    location: cache/github

Best Practices

Next Steps