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
- Skip to main content [direct]
- itch.io [direct]
- Browse Games [direct]
- Game Jams [direct]
- Upload Game [direct]
- Developer Logs [direct]
- Community [direct]
- Log in [direct]
- Register [direct]
- Indie game store [direct]
- Free games [direct]
- Fun games [direct]
- Horror games [direct]
- Game development [direct]
- Assets [direct]
- Comics [direct]
- Sales [direct]
- Bundles [direct]
- Jobs [direct]
- Tags [direct]
- Game Engines [direct]
- About itch.io [direct]
- FAQ [direct]
- Community rules [direct]
- Hosting a jam [direct]
- Support & contact [direct]
- Finding existing purchases [direct]
- Creator FAQ [direct]
- Quality guidelines [direct]
- Getting started [direct]
- Access control [direct]
- Search & Browse [direct]
- Designing your page [direct]
- Interacting with fans [direct]
- Widget embed [direct]
- HTML5 games [direct]
- Limited releases [direct]
- Exclusive content [direct]
- Custom CSS [direct]
- Kickstarter [direct]
- Patreon [direct]
- How buying works [direct]
- Getting paid & VAT [direct]
- Pricing [direct]
- Download keys [direct]
- Hosting a sale [direct]
- Co-op bundles [direct]
- Two-factor authentication [direct]
- Followers [direct]
- itch.io app FAQ [direct]
- App guide [direct]
- Overview [direct]
- OAuth Applications [direct]
- Server-side API reference [direct]
- Sub-products reference [direct]
- Press Kit [direct]
- Become a Sponsor [direct]
- Terms of service [direct]
- Privacy Policy [direct]
- Cookie Policy [direct]
- YouTube [direct]
- Bluesky [direct]
- X [direct]
- Facebook [direct]
- Join our Discord [direct]
- Blog [direct]
- Directory [direct]
|
|