The Magic Frog: API and Refactoring (Development Update)

in utopian-io •  2 months ago

the-magic-frog

Repositories

https://github.com/mktcode/the-magic-link (new)
https://github.com/mktcode/the-magic-frog

This update does not change anything visible to the user but a lot in the background. There's now an API to fetch the necessary data for the websites. This makes it easier to extend and reduced code duplication dramatically.
I also think it would be nice to story the data in an own database, in addition to the blockchain. Simply to have quicker and more independent access. Then, at the latest, it makes totally sense to do that.

Endpoints

Starting with just the delegators, to fix an "exposed key issue"... I soon thought, that it might be quite handy to have endpoints for all the data, like posts, contributors, current submissions and so on.

https://api.the-magic-frog.com

  • /delegators: Returns all delegators, order by SP.
  • /contributors: Returns all users who have contributed to a story, together with their total number of contributions, ordered by that number.
  • /submissions: Returns all currently voteable submissions, order by votes.
  • /stories: Returns the last post for each story that exists.
  • /storyposts: Returns all posts that belong to a story.

To chose which instance of the Magic Frog is concerned, an account parameter is needed.

So, for example, to get a list of all users that have contributed to a story in the English instance, call:
https://api.the-magic-frog.com/contributors?account=the-magic-frog

All the endpoints support only the account names that actually host a Magic Frog instance ( @the-magic-frog, @der-zauberfrosch, @grenouille ).

Implementation

I'm using express for the first time here. Feel free to have a look at the code and give me feedback.

The API is a new repo of course so I won't list commits here. But have fun with the first few commit messages. I tried to write them as a story but then forgot about it and broke the story. :D

Updated Frontend/Website

Commits:

Roadmap

  • Error handling should be a bit more verbose.
  • The bot still needs to be adjusted to make use of the API.
  • If needed, there will be more endpoints of course. But for now there's nothing specific on my mind.
  • Set up own DB and connect it with the API.

Get in touch

If you want to get in touch with me and other community members, the preferred way is now our discord. There's not much going on there yet but I'm sure this will change overtime. We need creative minds! If you are, join!

Stay tuned and happy storytelling!

Visit:
the-magic-frog.com
de.the-magic-frog.com
fr.the-magic-frog.com

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thanks for the contribution, @mkt! How was it using Express for the first time?

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

·

I knew that it's an ease. I just still need to learn some details... like proper error handling. If you have some advice... let me know! :)

Hey @mkt
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Super !
I saw you built this website and it's really cool!
Great work !

·

Thank you! Feel free to participate!