Skip to content

A simple API service for retrieving GitHub user achievements information. Built with Cloudflare Workers. / 一个简单的 API 服务,用于获取 GitHub 用户的成就信息。基于 Cloudflare Workers 构建。

License

Notifications You must be signed in to change notification settings

wangrunlin/github-achievements-api

Repository files navigation

GitHub Achievements API

Pull Shark Achievement

License GitHub package.json version GitHub last commit Test Status Node Version TypeScript code style: prettier PRs Welcome GitHub stars GitHub forks GitHub issues Visitors Ko-fi

English | 简体中文

A simple API service for retrieving GitHub user achievements information. Built with Cloudflare Workers.

Live Demo

Deploy to Cloudflare Workers

Deploy to Cloudflare Workers

Features

  • Fetch GitHub user achievement list
  • Support for achievement tier statistics
  • Provide raw and weighted achievement counts
  • Automatic result caching (1 hour) for better performance
  • Deployed on Cloudflare Workers for low-latency global access

API Usage

Base Endpoint

GET https://<your-worker>.workers.dev/<github_username>

Example Request

GET https://<your-worker>.workers.dev/wangrunlin

Response Format

{
  "total": {
    "raw": 5, // Raw achievement count (without tiers)
    "weighted": 8 // Weighted achievement count (with tiers)
  },
  "achievements": [
    {
      "type": "pair-extraordinaire",
      "tier": 3,
      "image": "https://some.cdn.com/path/to/pair-extraordinaire.png"
    },
    {
      "type": "pull-shark",
      "tier": 2,
      "image": "https://some.cdn.com/path/to/pull-shark.png"
    },
    {
      "type": "quickdraw",
      "tier": 1,
      "image": "https://some.cdn.com/path/to/quickdraw.png"
    }
    // ...
  ]
}

API Documentation

Rate Limiting

This API inherits GitHub's rate limiting. Please be mindful of GitHub's rate limits when making requests.

Caching

  • Responses are cached for 1 hour to improve performance
  • Cache is automatically invalidated when new achievements are earned
  • Cache can be bypassed by adding ?nocache=true to the request

Error Responses

Status Code Description
404 User not found
429 Rate limit exceeded
500 Internal server error

Example error response:

{
  "error": "Failed to fetch GitHub achievements: Not Found"
}

Roadmap

  • Add support for achievement descriptions
  • Add support for achievement dates
  • Add support for achievement images
  • Add API key authentication
  • Add more detailed statistics
  • Add support for organization achievements
  • Add webhook notifications for new achievements

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

Ko-fi

Other sponsorship options

Who's using GitHub Achievements API?

Are you using this API? Let us know and we'll add your logo here!

Local Development

Prerequisites

  • Node.js 18+
  • pnpm

Install Dependencies

pnpm install

Run Locally

pnpm dev

Run Tests

pnpm test

Deployment

This project uses GitHub Actions to automatically deploy to Cloudflare Workers:

  • Commits to non-main branches create preview deployments
  • Commits to main branch deploy to production

Setup GitHub Secrets

To enable automatic deployments, you need to add the following secrets to your GitHub repository:

  1. Go to your repository on GitHub
  2. Navigate to Settings > Secrets and variables > Actions
  3. Add the following secrets:
    • CF_API_TOKEN: Your Cloudflare API token with Workers permissions

How to get Cloudflare credentials

  1. Cloudflare API Token:
    • Go to the Cloudflare dashboard
    • Navigate to My Profile > API Tokens
    • Create a new token with "Edit Workers" permissions

Tech Stack

  • TypeScript
  • Cloudflare Workers
  • Vitest (Testing Framework)
  • Wrangler (Development & Deployment Tool)

License

MIT

Contributing

Issues and Pull Requests are welcome!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Author

Leo Wang

Available Achievements

Here are all the achievements currently available on GitHub:

View more details about GitHub Achievements

Achievement Name Description Max Tiers
Starstruck Created a repository that has 16 stars 4
Quickdraw Closed an issue/PR within 5 minutes of opening 1
Pair Extraordinaire Coauthored in merged pull request 3
Pull Shark Opened a pull request that has been merged 3
Galaxy Brain Answered a discussion with an accepted answer 4
YOLO Merged a pull request without code review 1
Arctic Code Vault Contributed code to repositories in the 2020 GitHub Archive Program 1
Public Sponsor Sponsored an open source contributor through GitHub Sponsors 1
Mars 2020 Contributor Contributed code to repositories used in the Mars 2020 Mission 1

Acknowledgments

Thanks to these awesome projects and resources:

About

A simple API service for retrieving GitHub user achievements information. Built with Cloudflare Workers. / 一个简单的 API 服务,用于获取 GitHub 用户的成就信息。基于 Cloudflare Workers 构建。

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •