Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Download a game with the API

A topic by NaolShow created Aug 16, 2021 Views: 2,980 Replies: 12
Viewing posts 1 to 3

Hi, here’s what I am trying to achieve:

  • Download game files from itch io for a specific game for a specific user So basically I just give an API key and a game id (here my game id), and I could download the game files if the user have bought the game.

(This is for a custom launcher)

But I found that there is no way to do that ? I’ve tried to look into the Itch app code but I don’t find where is the entry point for the game’s download…

Is there any way to do that ? Thanks!

(2 edits)

Ok my bad it was not in itch io app code but in butler. But another problem comes, I cannot manage to use the fetch command (command that downloads a game) here’s an example with a free game:

butler fetch thorbjorn/tiled:win test
∙ Getting last build of channel win
itch.io API error (400): /wharf/channels/win: invalid game

And I just always get that error (latest butler version)

Edit: Do we actually need to use the game’s owner api key to do this ? Then how itch io fetch games without leaking the api key ?

Admin

win is not the name of any channel on tiled. You can try windows-64bit

Edit: Do we actually need to use the game’s owner api key to do this ? Then how itch io fetch games without leaking the api key ?

Downloads are not done via the owner’s API key, as you noted that makes no sense in the context of the app.

Hi! Thanks for your response. Yes I’ve found later on that the channel name was not good. (And by the way is there a command to get a list of all the channels names of an app ?)

So I’ve tried again with the correct channel name, and it’s exactly the same:

butler fetch thorbjorn/tiled:windows-64bit test
∙ Getting last build of channel windows-64bit
itch.io API error (400): /wharf/channels/windows-64bit: invalid game

But if it’s not the owner’s API key, which key should I use ? Because I’m trying to make a custom launcher in which the player connect with OAuth (and then he gives us it’s API key) but it do not work (do not have the right scope).

Edit: I’ve for the channels list: https://itch.io/api/1/APIKEY/wharf/channels?target=author/game (But this is only working for my own games, due to the api key I guess, so here how itch app can use it?)

Also I’ve looked into the itch app database (butler.db in the itch/db folder) and it is using one of my api key for butler. But when I use it myself with butler, with status,fetch commands they are not working (invalid target).

Thanks!

(1 edit)

I used to play with itch.io API for fun.

Given the creator (thorbjorn) and game (tiled), get the game’s numeric id:

https://thorbjorn.itch.io/tiled/data.json - returns JSON with id 28768

Get game’s uploads using game id:

https://itch.io/api/1/API_KEY/game/28768/uploads - returns JSON array of uploads, containing id’s, display/channel names, etc of uploads.

Download upload using upload id (e.g. of windows-64bit):

curl https://itch.io/api/1/API_KEY/upload/504289/download - returns download link in JSON

That should work for free games, with API_KEY of any user. I have not tried to work with paid ones.

EDITED: fixed mistake with upload info request

(1 edit)

Hi! Thanks for your response.

However it seems to not work… The data.json request is working properly I have access to the game_id however the /game/ request do not give the informations that you gave:

https://itch.io/api/1/API_KEY/game/28768

{
  "game": {
    "p_osx": true,
    "id": 28768,
    "published_at": "2015-06-21 12:11:55",
    "url": "https:\\/\\/thorbjorn.itch.io\\/tiled",
    "can_be_bought": true,
    "p_android": false,
    "p_linux": true,
    "created_at": "2015-06-21 09:52:56",
    "p_windows": true,
    "has_demo": false,
    "min_price": 0,
    "title": "Tiled Map Editor",
    "user": {
      "display_name": "Thorbjørn",
      "id": 59281,
      "url": "https:\\/\\/thorbjorn.itch.io",
      "cover_url": "https:\\/\\/img.itch.zone\\/aW1hZ2UyL3VzZXIvNTkyODEvMjE4NzA0LnBuZw==\\/100x100%23\\/kk5Ir6.png",
      "username": "thorbjorn"
    },
    "cover_url": "https:\\/\\/img.itch.zone\\/aW1nLzI2NTU0MzAucG5n\\/315x250%23c\\/OviaCR.png",
    "in_press_system": false,
    "classification": "tool",
    "short_text": "Free, easy to use and flexible level editor.",
    "type": "default"
  }
}

(I’ve tried with other games, it do not give any information about the uploads..)

and I’ve also tried your download request, and here it works I have the link. But as I said before how did you get the download id ? (the “504289” as I don’t have it in the /game/ request?)

Thanks for your help! It really helps me a lot!

Edit: And I’ve also tried to use an OAuth application api key but it do not work, so I don’t think this is the best solution (since the users would have to give their api key to the app, it’s a bit more annoying than just accepting the OAuth app..)

Shit, sorry, made a mistake. Indeed the game/GAME_ID request returns just general info on the game. Uploads info is https://itch.io/api/1/API_KEY/game/28768/uploads

(1 edit)

Nice thank you so much!

But yeah I hope Leafo will respond because this method works but only if the user gives it’s api key (it do not work with OAuth api key…) (And another problem is that with this method I can’t download the butler patch, I always need to download again the whole game)

(2 edits)

Yeah I think you may have better luck with butlerd https://github.com/itchio/butler/tree/master/butlerd - basically butler is a command line interface to butlerd which is a daemon with JSON RPC interface. I did not try it myself, but the docs seem to be pretty comprehensive https://docs.itch.ovh/butlerd/master/ .

GameHub launcher apparently uses butlerd for itch.io integration https://github.com/tkashkin/GameHub/tree/master/src/data/sources/itch

(+1)

Oh my god I haven’t seen this…

Thanks the documentation is much more complete than the butler doc..

Thank you so much I’ll dig into this!

Hi leafo, quyse helped me for api part with Butlerd.

Everything works perfectly as long as I ask for the username/password of the user. If I try to use an OAuth api key I can’t see the uploads for example (api key does not permit `game:view:uploads’)

But asking for the username/password of a user in a random game would be really suspicious.. Is there any way to let the regular oauth api key see the uploads of a game ? Thanks!

Admin

We don’t let oauth generated keys be used for downloading games. You will need to use a real API key.

(1 edit)

Ok no problem!

Thanks for the help

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