This code gets all peers from running Mastodon, Pleroma or Lemmy host server and then all peers from host server's peers. Goal is to collect maximum number of alive fediverse's servers by querying their API and then post servers and registered users.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
10 KiB

4 months ago
  1. # Fediverse Stats
  2. This code gets all peers from running Mastodon, Pleroma and Lemmy host servers and then all peers from host server's peers. Goal is to collect maximum number
  3. of alive fediverse's servers and then query their API to obtain their registered users (if their API provide such information).
  4. At the end it post the results to host server bot account.
  5. ### Dependencies
  6. - **Python 3**
  7. - Postgresql server
  8. - Mastodon or Pleroma running server.
  9. ### Usage:
  10. Within Python Virtual Environment:
  11. 1. Run `pip install -r requirements.txt` to install needed libraries.
  12. 2. Run `python db-setup.py` to setup and create new Postgresql database and needed tables in it.
  13. 3. Run `python setup.py` to get your bot's access token of your Mastodon or Pleroma server existing account. It will be saved to 'secrets/secrets.txt' for further use.
  14. 4. Run `python getpeers.py` to get all peers from your host and the whole world of fediverse's servers (or almost the whole world).
  15. 5. Run `python fetchservers.py` to add servers to alive servers database.
  16. 6. Run `python fediverse.py` to query world alive servers API. It gets data from server's API according this table:
  17. | Software | API peers | API users (nodeinfo/2.0.json) | API users (nodeinfo/2.0) | API users (api/v1/instance) | API users (main/nodeinfo/2.0) | API users (api/nodeinfo/2.0.json) | API users (api/nodeinfo) | Software |
  18. |:--------------:|:---------------------:|:------------------------------------------:|:----------------------------------------------------------------------------------------------:|:---------------------------:|:-----------------------------:|:---------------------------------:|:---------------------------:|:--------------:|
  19. | Diaspora | | ['usage']['users']['total'] | | | | | | Diaspora |
  20. | Friendica | api/v1/instance/peers | | ['usage']['users']['total'] | | | | | Friendica |
  21. | Ganggo | | | ['usage']['users']['total'] | | | | | Ganggo |
  22. | GNU Social | | | | | ['usage']['users']['total'] | | | GNU Social |
  23. | GNU Social 2.x | | | | | | ['usage']['users']['total'] | | GNU Social 2.x |
  24. | Groundpolis | | | ['usage']['users']['total'] | | | | | Groundpolis |
  25. | Hubzilla | | | ['usage']['users']['total'] | | | | | Hubzilla |
  26. | Lemmy | api/v2/site ['federated_instances']['linked'] | ['usage']['users']['total']| | | | | | Lemmy |
  27. | Mastodon | api/v1/instance/peers | ['usage']['users']['total'] (since v3.0.0) | | ['stats']['user_count'] | | | | Mastodon |
  28. | Misskey | | | **NO** (['usage']['users'] returns {}) so using ['usage']['users']['activeHalfyear'] instead | | | | | Misskey |
  29. | Osada | | | ['usage']['users']['total'] | | | | | Osada |
  30. | Peertube | | ['usage']['users']['total'] | | | | | | Peertube |
  31. | Pixelfed | | | | | | ['usage']['users']['total'] | | Pixelfed |
  32. | Pleroma | api/v1/instance/peers | ['usage']['users']['total'] | | | | | | Pleroma |
  33. | Plume | | | ['usage']['users']['total'] | | | | | Plume |
  34. | Prismo | | | ['usage']['users']['total'] | | | | | Prismo |
  35. | Ravenvale | | ['usage']['users']['total'] | | | | | | Ravenvale |
  36. | Squus | | | ['usage']['users']['total'] | | | | | Squus |
  37. | Writefreely | | | | | | | ['usage']['users']['total'] | Writefreely |
  38. | Zap | | | ['usage']['users']['total'] | | | | | Zap |
  39. | software | API | software name |
  40. |-------------|:---------------------:|:--------------------:|
  41. | diaspora | nodeinfo/2.0.json | ['software']['name'] |
  42. | dolphin | nodeinfo/2.0 | ['software']['name'] |
  43. | ganggo | nodeinfo/2.0 | ['software']['name'] |
  44. | friendica | nodeinfo/2.0 | ['software']['name'] |
  45. | gnusocial | main/nodeinfo/2.0 | ['software']['name'] |
  46. | gnusocialv2 | api/nodeinfo/2.0.json | ['software']['name'] |
  47. | groundpolis | nodeinfo/2.0 | ['software']['name'] |
  48. | hubzilla | nodeinfo/2.0 | ['software']['name'] |
  49. | lemmy | nodeinfo/2.0.json | ['software']['name'] |
  50. | mastodon | nodeinfo/2.0.json | ['software']['name'] |
  51. | misskey | nodeinfo/2.0 | ['software']['name'] |
  52. | osada | nodeinfo/2.0.json | ['software']['name'] |
  53. | peertube | nodeinfo/2.0.json | ['software']['name'] |
  54. | pixelfed | api/nodeinfo/2.0.json | ['software']['name'] |
  55. | pleroma | nodeinfo/2.0.json | ['software']['name'] |
  56. | plume | nodeinfo/2.0 | ['software']['name'] |
  57. | prismo | nodeinfo/2.0.json | ['software']['name'] |
  58. | ravenvale | nodeinfo/2.0.json | ['software']['name'] |
  59. | squs | nodeinfo/2.0 | ['software']['name'] |
  60. | wordpress | wp-json/nodeinfo/2.0 | ['software']['name'] |
  61. | writefreely | api/nodeinfo | ['software']['name'] |
  62. | zap | nodeinfo/2.0.json | ['software']['name'] |
  63. 5. Use your favourite scheduling method to set `python fediverse.py` to run twice daily, `python fetchservers.py` one time daily and `python getworld.py` to run monthly.
  64. 18.2.21 - New feature! Added [Lemmy project](https://join.lemmy.ml)
  65. 12.5.21 - New feature! Added Wordpress support. The code can now detect Wordpress instances with ActivityPub enabled plugin.
  66. 12.5.21 - New feature! New shinny creation of servers and users graphs.