SOLFIND
Web Lens
Portal home

JavaScript API reference - itch.io

https://itch.io/docs/api/javascript • 26 KB fetched
Open original page


JavaScript API reference - itch.io Skip to main content itch.io Browse Games Game Jams Upload Game Developer Logs Community Log in Register Indie game store Free games Fun games Horror games Game development Assets Comics Sales Bundles Jobs Tags Game Engines General About itch.io FAQ Community rules Hosting a jam Support & contact Buying Finding existing purchases Creating Creator FAQ Quality guidelines Getting started Access control Search & Browse Designing your page Interacting with fans Widget embed HTML5 games Limited releases Exclusive content Custom CSS Integrations Kickstarter Patreon Selling How buying works Getting paid & VAT Pricing Download keys Hosting a sale Co-op bundles Accounts Two-factor authentication Followers App itch.io app FAQ App guide API Overview OAuth Applications Server-side API reference JavaScript API reference Sub-products reference More Press Kit Become a Sponsor Legal Terms of service Privacy Policy Cookie Policy JavaScript API reference The itch.io JavaScript API gives you the ability to embed a game purchase button into an existing web page. All you need to do is create a button or link on your page, include a JavaScript file, and run a small snippet of code to connect them. Table of contents * Reference * Itch.attachBuyButton(element, options) * Itch.getGameData(options) The pop-up is also suitable if you have 0 as a minimum price because it will give the visitor the option to go directly to the downloads. Let s see it in action, first we'll add a button that will be our buy button: <button id = "buy_button" > Buy My Game! </button> Next, we'll add something like the following, updating the user and game to be your username and the slug from the game you wish to sell. <script type = "text/javascript" src = "https://static.itch.io/api.js" ></script> <script type = "text/javascript" > Itch . attachBuyButton ( document . getElementById ( "buy_button" ), { // replace the following with the correct information about your game user : "{{user}}" , game : "{{game}}" }); </script> Now when someone clicks on the button a pop-up will appear giving the visitor an opportunity to purchase your game. Try it out: Buy My Game! Reference Methods in https://static.itch.io/api.js Itch.attachBuyButton(element, options) Attaches a buy button to a DOM element on the page. element is a DOM element. (If you're using jQuery make sure you pass in the DOM element and not the jQuery object) options is an object that can contain the following fields: * user : Required The username of the game seller * game : Required The slug of the game, the slug is the name of the game from the URL of the game. For example, if your game s URL is http://leafo.itch.io/x-moon then the slug is x-moon . * width : The width of the pop-up, defaults to 650 * height : The height of the pop-up, defaults to 400 Itch.getGameData(options) Asynchronously get information about a game. options is an object that can contain the following fields: * user : Required The username of the game seller * game : Required The slug of the game, see above for an example * onComplete : Required A function to call when the game information is loaded. Receives one argument: a hash table of game information * secret : If your game is in draft, you can pass the secret here to let the API access it. Note that anyone can get access to this secret by viewing the source of your page. We recommend only using this parameter for testing. In addition to some basic game metadata, gameData will return any information about the current price of the game and any rewards. You can use this in conjunction with the buy button API to show current price. The price will reflect any sales that might be active. Example: <script type = "text/javascript" src = "https://static.itch.io/api.js" ></script> <script type = "text/javascript" > Itch . getGameData ({ user : "leafo" , game : "x-moon" , onComplete : function ( data ) { console . log ( data ) } }) </script> A game with rewards might return something like this: { "id" : 1 , "title" : "X-moon" , "price" : "$20.00" , "rewards" : [ { "amount" : 1000 , "price" : "$20.00" , "title" : "Limited Access round" , "id" : 90 , "amount_remaining" : 0 , "available" : false } ] } A game on sale might return something like this: { "id" : 36 , "title" : "ExoSlime DX: Revenge of Slime" , "price" : "$0.60" , "original_price" : "$1.21" , "sale" : { "id" : 18 , "end_date" : "2016-06-30 10:17:59-07" , "title" : "My first sale" , "rate" : 50 } } Follow itch.io on YouTube , Bluesky , X , Facebook , or Join our Discord for new games and site updates. itch.io on Twitter itch.io on Facebook About FAQ Blog Contact us Copyright © 2026 itch corp · Directory · Terms · Privacy · Cookies

Links found on this page

  1. Skip to main content [direct]
  2. itch.io [direct]
  3. Browse Games [direct]
  4. Game Jams [direct]
  5. Upload Game [direct]
  6. Developer Logs [direct]
  7. Community [direct]
  8. Log in [direct]
  9. Register [direct]
  10. Indie game store [direct]
  11. Free games [direct]
  12. Fun games [direct]
  13. Horror games [direct]
  14. Game development [direct]
  15. Assets [direct]
  16. Comics [direct]
  17. Sales [direct]
  18. Bundles [direct]
  19. Jobs [direct]
  20. Tags [direct]
  21. Game Engines [direct]
  22. About itch.io [direct]
  23. FAQ [direct]
  24. Community rules [direct]
  25. Hosting a jam [direct]
  26. Support & contact [direct]
  27. Finding existing purchases [direct]
  28. Creator FAQ [direct]
  29. Quality guidelines [direct]
  30. Getting started [direct]
  31. Access control [direct]
  32. Search & Browse [direct]
  33. Designing your page [direct]
  34. Interacting with fans [direct]
  35. Widget embed [direct]
  36. HTML5 games [direct]
  37. Limited releases [direct]
  38. Exclusive content [direct]
  39. Custom CSS [direct]
  40. Kickstarter [direct]
  41. Patreon [direct]
  42. How buying works [direct]
  43. Getting paid & VAT [direct]
  44. Pricing [direct]
  45. Download keys [direct]
  46. Hosting a sale [direct]
  47. Co-op bundles [direct]
  48. Two-factor authentication [direct]
  49. Followers [direct]
  50. itch.io app FAQ [direct]
  51. App guide [direct]
  52. Overview [direct]
  53. OAuth Applications [direct]
  54. Server-side API reference [direct]
  55. Sub-products reference [direct]
  56. Press Kit [direct]
  57. Become a Sponsor [direct]
  58. Terms of service [direct]
  59. Privacy Policy [direct]
  60. Cookie Policy [direct]
  61. YouTube [direct]
  62. Bluesky [direct]
  63. X [direct]
  64. Facebook [direct]
  65. Join our Discord [direct]
  66. Blog [direct]
  67. Directory [direct]