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: 25 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 (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-06T12:41:05.000Z (about 1 year ago)
- Last Synced: 2024-04-13T14:04:09.387Z (about 1 year 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
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:
[](https://github.com/spencerwooo)
[](https://t.me/realSpencerWoo)
[](https://weibo.com/6265807914)
[](https://sspai.com/u/spencerwoo)
[](https://afdian.net/@spencerwoo)
[](https://m.okjike.com/users/4DDA0425-FB41-4188-89E4-952CA15E3C5E)
[](https://steamcommunity.com/profiles/76561198336249957)
[](https://www.zhihu.com/people/bi-xiao-tian-99)
[](https://space.bilibili.com/401742377)
[](https://juejin.cn/user/1838039172387262)
[](https://www.yuque.com/lyndon)You can easily create your own badge with our badge builder at [substats.swo.moe](https://substats.swo.moe/).

### 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).

## 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)