Giter Site home page Giter Site logo

foskym / substats Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spencerwooo/substats

0.0 0.0 0.0 4.71 MB

( `д′) how many followers do i have? how many!

Home Page: https://substats.swo.moe

License: MIT License

JavaScript 1.29% TypeScript 98.71%

substats's Introduction

substats

Get started · What's new? · Sponsoring

( `д′) how many followers do i have? how many!

Cloudflare Workers Version 2.0/substats Vercel

Get started

sub · stats /səb ˈ stats/

  • a serverless api for getting the number of followers of you in your favourite services

*Version 2.0 is still in beta, not all features are ported from 1.0. Check below for details 👇

Basic

https://api.swo.moe

You request:

GET /stats/:source/:key

I respond:

{
  source: string,
  key: string,
  failed: true | false,
  count: number | string  // Most often it's a number when source !== 'common'
}

Yep, it's that simple now. ;)

*Note that key needs to be url encoded, remember this if you are requesting the feedly, inoreader, or feedspub routes.

Building badges 🎫

Of course! And as a matter of fact, substats works quite well with shields.io's /dynamic route. All these badges below are dynamically generated with substat's data:

GitHub Telegram 微博 少数派 爱发电 即刻 Steam 知乎 哔哩哔哩 掘金 语雀 QQ音乐

You can easily create your own badge with our badge builder at substats.swo.moe.

Badge builder screenshot

Advanced - the /common route 🍀

What if the source you are trying to use is not supported yet, but it's just a simple GET request? In this case, you can use the route:

GET /stats/common?endpoint=<url>&datapath=<path>

Such as:

GET /stats/common/?endpoint=https://api.genshin.dev/domains/cecilia-garden&datapath=rewards.0.details.2.mora

In this case, the endpoint is an API url:

https://api.genshin.dev/domains/cecilia-garden

The response this URL returns looks like:

{
  "name": "Cecilia Garden",
  "type": "Forgery",
  // ...
  "rewards": [
    {
      "details": [
        { /* ... */ },
        { /* ... */ },
        {
          "mora": 1125,
        },
      ]
    }
  ]
}

Hence, we provide the datapath as rewards.0.details.2.mora. (I specifically chose this data as it contains an array to demonstrate how to reference the value mora inside the array by index.)

Response from the endpoint provided by you is parsed with object-path, and the method for constructing a reference datapath to your value in the response is the same.

Try our /common route API URL builder here: substats.swo.moe/common.

Common route screenshot

Supported sources

  • afdian
  • bilibili
  • coolapk
  • feedly
  • feedspub
  • github
  • inoreader
  • instagram
  • jike
  • mastodon
  • medium
  • neteasemusic
  • qqmusic
  • reddit
  • sspai
  • steamgames
  • steamfriends
  • telegram
  • twitter
  • unsplash
  • weibo
  • wikipediazh
  • zhihu
  • juejin
  • yuque

logo_afdian logo_bilibili logo_coolapk logo_feedly logo_feedspub logo_github logo_inoreader logo_ins logo_jike logo_mastodon logo_medium logo_neteasemusic logo_qqmusic logo_reddit logo_sspai logo_steam logo_tg logo_twitter logo_unsplash logo_weibo logo_wikipedia logo_zhihu logo_juejin logo_yuque

What's new?

Yes, substats is now version v2.0-beta! Most of the updates are under-the-hood apart from API formats.

  • Refactored in TypeScript.
  • Updated to CloudFlare's module workers.
  • Worker is built with esbuild instead of webpack, extra fast!
  • Support for Newsblur has been deprecated (seems nobody uses it).
  • KV storages are now supported, some routes including instagram depends on this for storing cookies (wip).
  • Caching is ported to module workers in 2.0 and supported as always.
  • New documentation and query builder.

If you are looking for the multiple source and query functions in 2.0 - it's still under refactor, as itty-router does not parse multiple query parameters, blocking this feature here. You can still use the 1.0 route while we wait. README and documentation for v1.0 (deprecated).

Contributing

This is a monorepo managed by pnpm. Directory ./worker holds the Cloudflare Worker module, and ./docs is a React site for documentation (powered by Vite and Chakra UI). Check the README.md for both packages for details.

Sponsoring

Open-source is hard! If you happen to like this project and want me to keep going, please consider sponsoring me or providing a single donation! Thanks for all the love and support!

🧸 Please donate - 微信/支付宝 · Patreon · 爱发电

License

MIT

made with ❤️ by spencer woo

substats's People

Contributors

spencerwooo avatar dependabot[bot] avatar zwithz avatar yiukuenchu avatar chawyehsu avatar foskym avatar idealclover avatar diygod avatar kidonng avatar oldpanda avatar tenkeyseven avatar hardwaylinka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.