Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spencerwooo/substats
( `д′) how many followers do i have? how many!
https://github.com/spencerwooo/substats
api api-service badge cloudflare cloudflare-workers rss subscriber
Last synced: 6 days ago
JSON representation
( `д′) how many followers do i have? how many!
- Host: GitHub
- URL: https://github.com/spencerwooo/substats
- Owner: spencerwooo
- License: mit
- Created: 2020-03-14T18:01:08.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-06T12:41:05.000Z (9 months ago)
- Last Synced: 2024-04-13T14:04:09.387Z (8 months ago)
- Topics: api, api-service, badge, cloudflare, cloudflare-workers, rss, subscriber
- Language: TypeScript
- Homepage: https://substats.swo.moe
- Size: 4.55 MB
- Stars: 795
- Watchers: 7
- Forks: 55
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome - spencerwooo/substats - ( `д′) how many followers do i have? how many! (TypeScript)
README
## 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:
```http
GET /stats/:source/:key
```I respond:
```typescript
{
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`](https://shields.io)'s `/dynamic` route. All these badges below are dynamically generated with substat's data:
[![GitHub](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fgithub%2Fspencerwooo&query=count&color=181717&label=GitHub&labelColor=282c34&logo=github&suffix=+follows&cacheSeconds=3600)](https://github.com/spencerwooo)
[![Telegram](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Ftelegram%2FrealSpencerWoo&query=count&color=2CA5E0&label=Telegram&labelColor=282c34&logo=telegram&suffix=+members&cacheSeconds=3600)](https://t.me/realSpencerWoo)
[![微博](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fweibo%2F6265807914&query=count&color=040000&label=%E5%BE%AE%E5%8D%9A&labelColor=e71f19&logo=sina-weibo&suffix=+%E5%85%B3%E6%B3%A8&cacheSeconds=3600)](https://weibo.com/6265807914)
[![少数派](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fsspai%2Fspencerwoo&query=count&color=d71a1b&label=%E5%B0%91%E6%95%B0%E6%B4%BE&labelColor=282c34&suffix=+%E5%85%B3%E6%B3%A8&cacheSeconds=3600)](https://sspai.com/u/spencerwoo)
[![爱发电](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fafdian%2Fspencerwoo&query=count&color=282c34&label=%E7%88%B1%E5%8F%91%E7%94%B5&labelColor=946ce6&suffix=+%E5%8F%91%E7%94%B5%E4%BA%BA%E6%AC%A1+%2F+%E6%9C%88&cacheSeconds=3600)](https://afdian.net/@spencerwoo)
[![即刻](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fjike%2F4DDA0425-FB41-4188-89E4-952CA15E3C5E&query=count&color=fbae00&label=%E5%8D%B3%E5%88%BB&labelColor=282c34&suffix=+%E5%85%B3%E6%B3%A8&cacheSeconds=3600)](https://m.okjike.com/users/4DDA0425-FB41-4188-89E4-952CA15E3C5E)
[![Steam](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fsteamgames%2F76561198336249957&query=count&color=0b1a37&label=Steam&labelColor=134375&logo=steam&suffix=+games&cacheSeconds=3600)](https://steamcommunity.com/profiles/76561198336249957)
[![知乎](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fzhihu%2Fbi-xiao-tian-99&query=count&color=282c34&label=%E7%9F%A5%E4%B9%8E&labelColor=0084ff&logo=zhihu&logoColor=ffffff&suffix=+%E5%85%B3%E6%B3%A8&cacheSeconds=3600)](https://www.zhihu.com/people/bi-xiao-tian-99)
[![哔哩哔哩](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fbilibili%2F401742377&query=count&color=282c34&label=%E5%93%94%E5%93%A9%E5%93%94%E5%93%A9&labelColor=FE7398&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAD7ElEQVR4nO2dW9WrMBCFK6ESkFAJSKiESqgEHCABCZWAhEpAAhL2ecik5dDc%2FpXLBDLfWnlqy0xmJ5BMQnq5CIIgCIIgCIIgCIIgCEIBAHQAemYfrgCunD6wAKAHsEKxALgx+bCQD8%2FS9tmgVqeDr1lLigDgZvDhXso+K9TyTBQRwRJ8AHjntl0Flh5QRAQK%2FmKxPeayWx2OXpBNBKiHvi34b7T2MC4pAvW6twR%2FRwkRKPizBN8CgEcuESj4Lwm+BwBjahEk+H8EwJRKhOaCDzW8e1JLfkUUH1NgmR3XmHffHR1l+72BSs8d7w8U+JDAnZERQMcV+CtUi7dNqFqibB4J7vtrq7xKCuAasbTMXCL4T+5aVk6+2xHUrWdhruAR6HIJcOeu2UHI8zyAe2ytWfEdWz9PVvQ8YAmIQ5dDAB9LFsMVAv8oMO2zAGrC5WNIarRiAuKR9jYEd9pY08aa6uUzIHGRdkgKd8pY0yc1WjEBAqypDYoAG0QAZkQAZkQAZkQAZk4vANQenjsSzS3I%2FwcSbXU5jQBUkRtdf4Rar90v8kSv3+I3ffCCSpk8I%2Fw+lgDkdI%2Fv2rEp2CaiWm1AsDQLlDAD+dlFXLMeAaCSeLZdaSFE5VUQNot38cKuEeBgAsSuG0flVZBmEanbXfNQAsS0fgBYIn2fIu3%2FBBMHEyBmDXlFfA8IzeHb+Ems4WAChKykrVA9ZfsQTL57jXzRg4A5wC%2FA8N4ADiZAZwm2XjW75Qh2KOTfA0p4kygPw28OJcCVgn3nDnYo2EwEYRgGH0qAMyICMCMCMCMCMCMCMCMCMCMCfP3qwHDOQ4AAUekTk8FaBRihJnZdYbvtCGC7LvmkM63GjVDINPFrQgCq5ETXfmMzI90FXzPvfqt7x4rEu%2FZaEcCUxFvgz2zO+BUn6UkoaEEAsptiMSX5e8FoRYCN7cVgb4Vq7U%2FH50Pq4JNP7Qiw8UFnJwcK+tXy+Wj6PLEvPgHSHv5UgwA1IQIwwyFAyLJin9RoxYgAzAQIkPwNmf26busC+OIx5TDqo5nDT+F%2FSS%2F9CYzwb+No49zNy2evkYv0LywGGAXUvp6eSneycqOic0w20k7CNgKE7jJunSGLACTCxF27ylmQc98T5MQUH49swd+I0HPXslLKnT0N+wnkrTKi9JZL%2FL9i1SorMmdeQ4TQQ7OFMxIMzGD45w8nUL1im7efENZLJpgPSw0pfz0cdt4U3230Td%2FTvx2R6d2FrHhEWLkq5PELOMsRPHCPnAZGv1xJteL7jbJiaW3sB2nDvPC%2FosSYvjRQz4cJ6n7KO3rYQL7M+L6nVtfDVRAEQRAEQRAEQRAEIZ5%2FSAXmdfXaoQsAAAAASUVORK5CYII%3D&suffix=+%E5%85%B3%E6%B3%A8&cacheSeconds=3600)](https://space.bilibili.com/401742377)
[![掘金](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fjuejin%2F1838039172387262&query=count&color=282c34&label=%E6%8E%98%E9%87%91&labelColor=1e80ff&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAzNiAyOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNy41ODc1IDYuNzcyNjhMMjEuODIzMiAzLjQwNTA1TDE3LjU4NzUgMC4wMDc0ODIzN0wxNy41ODM3IDBMMTMuMzU1NSAzLjM5NzU3TDE3LjU4MzcgNi43Njg5NEwxNy41ODc1IDYuNzcyNjhaTTE3LjU4NjMgMTcuMzk1NUgxNy41OUwyOC41MTYxIDguNzc0MzJMMjUuNTUyNiA2LjM5NDUzTDE3LjU5IDEyLjY4MDhIMTcuNTg2M0wxNy41ODI1IDEyLjY4NDVMOS42MTk5MyA2LjQwMjAxTDYuNjYwMTYgOC43ODE4MUwxNy41ODI1IDE3LjM5OTJMMTcuNTg2MyAxNy4zOTU1Wk0xNy41ODI4IDIzLjI4OTFMMTcuNTg2NSAyMy4yODU0TDMyLjIxMzMgMTEuNzQ1NkwzNS4xNzY4IDE0LjEyNTRMMjguNTIzOCAxOS4zNzUyTDE3LjU4NjUgMjhMMC4yODQzNzYgMTQuMzU3NEwwIDE0LjEyOTFMMi45NTk3NyAxMS43NTMxTDE3LjU4MjggMjMuMjg5MVoiIGZpbGw9IiMxRTgwRkYiLz4KPC9zdmc+Cg==&logoColor=ffffff&suffix=+%E5%85%B3%E6%B3%A8&cacheSeconds=3600)](https://juejin.cn/user/1838039172387262)
[![语雀](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.swo.moe%2Fstats%2Fyuque%2F85213&query=count&color=2CA5E0&label=%E8%AF%AD%E9%9B%80&labelColor=36d07c&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTc2IiBoZWlnaHQ9IjE3MiIgdmlld0JveD0iMCAwIDE3NiAxNzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxkZWZzPjxyYWRpYWxHcmFkaWVudCBjeD0iMzguMTc1JSIgY3k9Ijg2LjA3OCUiIGZ4PSIzOC4xNzUlIiBmeT0i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wNTYiIG9mZnNldD0iMTAwJSIvPjwvbGluZWFyR3JhZGllbnQ+PHBhdGggZD0iTTU2LjE5NiA1MC41ODdDMzUuMjIgNzQuMTkyIDEwLjI1NiAxMDIuOTEzLjc4IDExMy43MDFjLTEuODI1IDIuMDc5LS4wNTYgNC4wNDEgMS4zNTggNC4yODQgNzAuNyAxMi4xNTUgOTMuMTQ3LTIxLjE2MiA5OC4xNDctMzYuMzkyIDYuODQxLTIwLjgzOC0yLjgyNS0zMS4wMDYtOC4yOTUtMzQuMzIyLTE4LjU1LTExLjI0My0zMi4zMTQtLjU5OS0zNS43OTMgMy4zMTZ6IiBpZD0iYyIvPjwvZGVmcz48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKDE3LjkzMyAzMC4xMzUpIj48dXNlIGZpbGw9IiMzMUNDNzkiIHhsaW5rOmhyZWY9IiNhIi8+PHVzZSBmaWxsLW9wYWNpdHk9Ii42IiBmaWxsPSJ1cmwoI2IpIiB4bGluazpocmVmPSIjYSIvPjwvZz48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxNy45MzMgMzAuMTM1KSI+PHVzZSBmaWxsPSIjOTNFNjVDIiB4bGluazpocmVmPSIjYyIvPjx1c2UgZmlsbC1vcGFjaXR5PSIuNzUiIGZpbGw9InVybCgjZCkiIHN0eWxlPSJtaXgtYmxlbmQtbW9kZTpvdmVybGF5IiB4bGluazpocmVmPSIjYyIvPjwvZz48L2c+PC9zdmc+&suffix=+%E5%85%B3%E6%B3%A8&cacheSeconds=3600)](https://www.yuque.com/lyndon)You can easily create your own badge with our badge builder at [substats.swo.moe](https://substats.swo.moe/).
![Badge builder screenshot](assets/badge-builder-screenshot.png)
### 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:
```http
GET /stats/common?endpoint=&datapath=
```Such as:
```http
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:
```jsonc
{
"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](https://github.com/mariocasciaro/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](https://substats.swo.moe/common).
![Common route screenshot](assets/common-route-screenshot.png)
## Supported sources
- afdian
- bilibili
- coolapk
- feedly
- feedspub
- github
- inoreader
- jike
- mastodon
- medium
- neteasemusic
- sspai
- steamgames
- steamfriends
- telegram
- unsplash
- wikipediazh
- zhihu
- juejin
- yuque## What's new?
Yes, `substats` is now version `v2.0-beta`! Most of the updates are under-the-hood apart from API formats.
- [x] Refactored in TypeScript.
- [x] Updated to CloudFlare's module workers.
- [x] Worker is built with `esbuild` instead of `webpack`, extra fast!
- [x] Support for Newsblur has been deprecated ~~(seems nobody uses it)~~.
- [x] KV storages are now supported, some routes including `instagram` depends on this for storing cookies (wip).
- [x] Caching is ported to module workers in 2.0 and supported as always.
- [x] 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)](https://github.com/spencerwooo/substats/blob/1becc576f09b09cfa1389312d081f02a25ed0735/README.md).
## 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](https://vitejs.dev/) and [Chakra UI](https://chakra-ui.com/)). 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 - 微信/支付宝](https://ovi.swo.moe/sponsor) · [Patreon](https://www.patreon.com/spencerwoo) · [爱发电](https://afdian.net/@spencerwoo)
## License
[MIT](LICENSE)