Loading...

Top
PFQ Banner

This is PokéFarm Q, a free online Pokémon collectables game.

Already a user? New to PFQ?

Retrieving Farm Notepad Contents through API

Forum Index > Core > Suggestions >

Citrisfur's AvatarCitrisfur
Citrisfur's Avatar
This suggestion is part of a larger topic I asked Niet about previously: if he was planning on implementing an API for Pokefarm. His response was that PFNew is expected to have one, so I somewhat expect this thread to be closed out / deferred for that reason. Regardless, I would like to have some part of it documented in the suggestions forum, and any updates or likewise on the issue would be appreciated. And if this thread is instead accepted I can create additional threads for other, more specific API additions if preferred. In short, I play as an IV breeder so I'm working on a userscript that reads Pokemon IVs and displays them on their respective icons in the field. I keep a text file that contains all of my Pokemon information, so when I get a Pokemon I want to keep, I add them to my text file inventory. The script is then able to compare new Pokemon I get and suggest whether or not I should keep them based on the inventory. I started the project with Pokefarm's existing Farm Notepad feature as my inventory file, but currently there isn't any way to update this through the userscript - all updates have to be done manually. My suggestion here then is to add API calls for retriving and writing to Pokefarm's Notepad files. Again, I know the introduction of API to a system is a timely and large scale project with many phases more suited for a site overhaul rather than a quick suggestion, I just thought a more specific end-goal suggestion would be preferred to a rather general "Add API to Pokefarm" thread.
New Discord Server for IV Breeders!
Come and hang out or talk shop!

Creator of PokeFarm Pokemon IVs;
a userscript that reports your best owned Pokemon.
Niet [Adam]'s AvatarNiet [Adam]
Niet [Adam]'s Avatar
If you know what you are doing, you can inspect the network activity when using the notepad, and replicate it in your script.
Clip from Pokémon anime, re-lined by me
-- OMNOMNOM!
Featured story: Injustice Feedback welcome!
Citrisfur's AvatarCitrisfur
Citrisfur's Avatar
That is an option I'll look into doing; I definitely prefer using Pokefarm's Notepad over having to store something locally or similar. It's a script for Pokefarm; I'd want to use as much of the site's resources as I can. The problem with that it's kind of a temporary workaround that semi-mimics what the API would be for, so while it'd work for now for my purposes it'd be nice if I was actually using a Pokefarm provided service for the same intent. And if I end up with a final product I like and might pass to others I'd again not want to watch their network (even if it's only watching specific traffic) over using a proper framework.
Niet [Adam]'s AvatarNiet [Adam]
Niet [Adam]'s Avatar
The Notepad in particular is already quite API-like anyway.
Hakano Riku's AvatarHakano Riku
Hakano Riku's Avatar
While I think it would be quite amazing as someone who also likes to poke around with code, I think the limitations of the current site are what makes this not viable. At least, not easily so. The original version of the website was released back in 2009! Quite early for the internet, considering Youtube was only just launched four years prior (just for reference). The APIs and programming languages used in websites back then were just kicking off and were NOTHING compared to what they are now. After the initial launch of the website, Niet changed site code as and when (and has been the sole programmer for the website mind you); long story short, it's a bit of a mess and not at all easy to work with, and new APIs and code are only strung in where possible, hence the new site being worked on from scratch. The new site should be MUCH easier to work with and easily allow for a website API. At least, that's the goal haha. So while I would also like this, I just don't believe it's easily viable right now and even if it were it might be a bit hacky to work with. For example, calling a request to the server for a notepad file will return text in the form of the HTML that is displayed; you would need to then parse the HTML for the actual text you want anyway. Not as easy as just, "get this file's text". Niet would have to entirely change the website - from scratch - to fix these behaviors in every little corner. Unfortunately, the best way to fit your needs right now is to use an external source for holding your text files such as Github, Dropbox, or anywhere else that allows you to overwrite/update files, or work around the hacky nature of much of the current code.. I will say though, it is possible to use the notepad if you're willing to put up with how it works and use the dev tools though! (If I'm wrong and it is more viable than I think; +1 to suggestion lol)
Avatar of Dian Rubens from Spice & Wolf
Type Race Score: 0
Type Race Clicklist: HERE
Citrisfur's AvatarCitrisfur
Citrisfur's Avatar
Again, I'm expecting this suggestion to be implemented as part of a total site overhaul. Adding an API to a server requires almost a complete rewrite of the back end which is not going to be done in any short amount of time. I'm aware that Niet works on the site code solo and I also understand that's probably a factor in why no such framework exists in the first place. But I will say I don't believe you're correct on the rest of your statements. APIs have been a part of webservers for many, many years, and systems even before 2009 include support for third-party developers to interact with and send requests to them remotely. In addition, APIs (especially when you are defining your own methods, like Pokefarm would be doing here) are highly customizable, a part of which being returning data in the specific format you want. Getting the HTML for a page is something that can be done without API (in fact, that's what my script is doing now), but with API you can get just the text of the file, if that's how the method is defined. It all depends on how Niet decides to implement it, when we get to that point. Thank you for your notes and your support on the topic though, I appreciate it.
Hakano Riku's AvatarHakano Riku
Hakano Riku's Avatar
Oh, I didn't mean APIs didn't work like that back then - just that the current website is still using older versions that don't have all the newest features yet, which make implementing a user-friendly API that much easier. For example, I know Niet uses LESS as an extension to CSS (which is why we can use things like @ variables in our site skins), but it's an older version that can't make use of the latest and greatest additions. If I recall, it was around v1.7.3 where the latest is v4.1.3! I remember being disappointed I couldn't use some new, interesting features. Pretty sure JQuery isn't too old but definitely not the latest either (not sure about the server-side as we can't see that). That's all I meant, apologies for not making that clearer ^^ it could easily have been added way back then, but I don't think Niet had anything like that in mind that far back or even thought so many users would join and thus why the code definitely isn't friendly enough for it currently. I also know that Niet doesn't want too much access by users to the server at the moment, as there are already some lag issues on site. If people make too many scripts that overload the server in any way, it could cause that much more of an issue...Some things like accessing the notepad shouldn't be an issue though! I would like see an overhaul for PFQ too, but I believe this was discussed in detail a few years ago with PFNew originally going to be the PFQ "rewrite" instead of a separate game, but because of how poorly data/information is handled on the server-side atm, quite a few things would be lost on a transfer. I can try to dig up some of the old posts if you'd like (if they're still around), but discussing it with the players resulted in PFNew becoming a separate thing instead of a rewrite because people don't want to lose some of their data again. Everyone's worked hard for what they have! Around 2014, there was a rewrite from what people call PF1 to PFQ - quite a lot was lost in this transfer from old Fakemon, items, specials...People were reasonably upset, thus why it was made a discussion/vote resulting in PFNew being separated. Nobody wanted it to happen again. So I'm not sure there will be such a vast rewrite to PFQ itself, but things do change! If a new discussion comes up involving a rewrite again, we'll have to see how that plays out. Otherwise it could be possible to tack in an API for the current site too, it just wouldn't be terribly user friendly due to how data is handled right now (technically there is already an undocumented API in place if you can call it that though). I may well have missed any updates in the past couple years as I've been gone though, so excuse me if any changes to the above were discussed recently ^^; I do really hope to see more positive changes to PFQ itself when and where possible! And an API would be lovely, thus why I'm quite excited for PFNew; JSON data and an API for UserScript players? Yes please! Sorry for long posts by the way, I'm terrible at being concise and get quite ramble-y haha...Perhaps I should start hideboxing my posts more ^^;
Citrisfur's AvatarCitrisfur
Citrisfur's Avatar
Sorry to reply to a very old thread, but I guess I'd like this to be resolved in some way? By which I mean this thread closed or deleted or what-not. Niet was correct in saying this was pretty much already a thing and by now I've figured out how to incorporate what I was suggesting on my end. While the access to the notepad still could be improved in the future (documented, more user-friendly, etc.) I think from reading his last dev log Niet's also pretty much aware of this and has it covered. I might bring a similar suggestion up on the new site but for now I'll see what's implemented then and bring it back up if needed. No worries if this is left open or whatever; I'm not staff, just figured it polite to say from my end I'm not watching this anymore to help out. Side note: I also learned that there may be a size limit to the files you can save to the notepad; does anyone know what that limit is or if there even is one? I seem to be unable to save files over the network bigger than I believe ~500Kb. My current workaround is to break my data and save to multiple files.

Cannot post: Please log in to post

© PokéFarm 2009-2024 (Full details)Contact | Rules | Privacy | Reviews 4.6★Get shortlink for this page