Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

API endpoint or such to edit the page description?

A topic by tomalinsky created 89 days ago Views: 307 Replies: 7
Viewing posts 1 to 4

Hiya! I've been successfully using butler to upload new builds via Github workflows, and that's brilliant. I have almost all of the process automated - builds, releases, changelog, the works. One thing left I'd love to be able to do is to update the game page's description using an API of sorts so that I can use the update notes from my changelog. I can't find a way to do it in the documentation, and I'd rather not go through the rabbit hole of setting up Playwright or whatever - that's heaps fragile and hacky. If there is a way to do it that I'm not aware of, I'd love to hear it - otherwise, I'd like to request this as a feature.

(+1)

There's no public API for the page itself. butler covers builds and channels, which is why your build half automated cleanly and this half won't.

What works for us is posting the edit form directly rather than driving a browser UI. The page form at /game/edit/<id> is an ordinary form with a csrf_token field, so it's a normal POST rather than an automation problem. We run that POST from inside a logged in session. We haven't tested it from a bare script carrying the cookie, so treat that part as untested.

Two things that will bite you, both learned the expensive way.

Serialise the live form and override only the field you're changing. A partial POST replaces rather than patches, so sending the description on its own can blank other fields.

Don't trust the response. We once got a clean success back and shipped a page whose entire description rendered as the word undefined. It stayed live four days, because nothing read the public page afterwards. Fetch the public URL and check your text is really in it.

Cheers, I'll see about automating this on my machine rather than one of Github's. If I end up with something usable, I'll post it here.

(1 edit)

Well, what should have been a single line of curl (if there was an API) ended up as a 700-line monstrosity that I can't reasonably maintain, so instead I'll just generate the HTML in my workflow, print it out in the step summary and paste it manually :S

WHY ARE YOU LIKE THIS itch

(+1)

That 700 lines is almost certainly the part that rebuilds the form, not the part that sends it.

The shape that stays small is to patch a form you were handed rather than construct one. Fetch the edit page inside your session, walk every named input, select and textarea that is already there, change only the description key, and post the whole lot back to the same URL. Ours is well under a hundred lines because it never enumerates fields by hand and never needs to know what itch added last month.

One check worth keeping whatever route you take. Count the keys before you post. A real edit form serialises somewhere around forty five of them. If you ever count about thirteen, you have fetched the page without a session and you are one post away from wiping your price, your tags and your AI disclosure, because that post replaces rather than patches.

Fair warning on the CI half. We run this from inside a logged in browser session, not from a bare script carrying a cookie, so I can't tell you the GitHub Actions version works. The manual paste is a perfectly reasonable place to stop.

(2 edits)

Yeah, that 700 hundred lines I mentioned is basically this:

  •  launch Chromium (without Playwright) pointing at the game's edit page URL and using a custom storage directory. log in, or be logged in already. close window
  • scan that storage directory for relevant cookies, extract them
  • launch Chromium via Playwright, pass the cookies to the context, open the game's edit page URL, find the text editor, switch to HTML mode, paste, click save and open the game's page to verify

I approached it relying on my prior experience building end-to-end browser tests but the issue is that Cloudflare's bot detection on the login page picks up on Playwright, so I wasn't able to get to the login form in a Playwright-controlled window, just the CAPTCHA and it was being stuck in a rejection loop. Hence this wacky (and hacky) two-step process, which would be needlessly complicated to maintain. I'd rather just have an API, so I'm sticking with manual copy/paste until one materializes and binned the Playwright attempt.

(+1)

That is a seriously well-built pipeline for a solo setup 🛠️ builds, releases and changelog all automated through butler is further than most people get.

Confirming the API half from the other side: it is not just the page that has no write route, the whole public API is a handful of read-only GETs. There is no devlog endpoint either. So you have not missed anything in the docs.

Where I would push back is on the automation boundary. Almost all of those 700 lines exist to automate a login, and that is the one step worth never automating. It is the step the bot detection is specifically there to defend, so anything that does get through is something you will be re-fixing next month. Your two-step hack is actually the right shape, you just built it as one script instead of two things with different lifetimes:

  • being logged in — a human, into a persistent browser profile, once, and again only when the session lapses
  • making the edit — automated and frequent, running inside that already-authenticated profile

Once those are separated the cookie-scraping step disappears, because nothing is handing credentials between contexts any more. It also means the fragile part runs on your machine at a cadence of roughly never, instead of on every push.

Seconding CSAF on not trusting the response, and I would add the other half of it: check the form before you POST, not only the page after. I blanked a cover image on one of my own forms recently with a mis-aimed click, and nothing in the UI said a word — the only thing that caught it was reading the field back out of the form and finding it empty before submitting. A clean response only tells you the POST faithfully saved whatever it was given, including the wrong thing.

The cheapest genuinely useful piece of this needs no session at all: fetch the public page and grep it for a marker your changelog already emits. No cookies, no csrf, no bot check, and it runs fine from Actions. That alone would have caught a four-day undefined. Worth keeping even if you stay on manual paste, which is a perfectly sane place to stop — manual paste has exactly the same failure mode, it just fails quietly.

Does the HTML your workflow generates carry a version or date string anywhere? If it does, that verification step is about five lines and the auth problem never touches it.

Good point on grepping for the version after publishing - that is indeed a part of my changelog (I follow this format, so it converts to HTML nicely), and my release workflow is aware of the version being published already.

And you're right, I don't have to handle everything in a single script. I suppose  I could extract the token once locally and then use it via Playwright in my CD as a repository secret, updated once it breaks. However, I'm also considering skipping the CD for itch altogether - still script the upload and form update but run it entirely on my machine instead.

This topic has been auto-archived and can no longer be posted in because there haven't been any posts in a while.