A fast and simple Xbox Live API, built on Cloudflare Workers.
This project uses two Cloudflare Workers KV namespaces:
- (Required)
TOKEN_STORE
: Used to store Xbox access tokens - (Optional)
PROFILES_CACHE
: Used to cache Xbox profiles to reduce responses time (profiles are cached for one hour)
- Fast: Running on more than 300 datacenters worldwide thanks to the power of Cloudflare Workers
- Easy to use: A profile can be fetched with a single GET request
- Install Wrangler CLI
- Install dependencies with
npm install
- Copy
wrangler.example.toml
towrangler.toml
- Create a KV namespace named
TOKENS_STORE
and add its id in thewrangler.toml
- (Optional) Create a KV namespace named
PROFILES_CACHE
and add its id in thewrangler.toml
- Configure the
XBOX_ACCESS_TOKEN
andXBOX_REFRESH_TOKEN
variables in thewrangler.toml
with your Xbox Live tokens (see below to obtain them) - Deploy to Workers with
workers deploy
- Go on this link in your browser, authenticate and once you reach a blank page, copy the URL
- Extract the
access_token
andrefresh_token
parameters from the copied URL (you can also use this tiny tool)
GET /profiles/{xuid}
Example profile:
{
"xuid": "2533275056522057",
"gamerscore": "28337",
"gamertag": "Hello",
"gamerpic": "https://images-eds-ssl.xboxlive.com/image?url=wHwbXKif8cus8csoZ03RW8ke8ralOdP9BGd4wzwl0MJ9z6QzuGwZjtvbE7sSsMVWdbcqfkxoWP60BSmwjdrqjdnbtjpTZg2sgv2Zu6A4iNhBj4V1ePvsMGSKEhUsgp5yZqOg.wtIFgQcnAf.8lY8BoeFGho.yDFWyybpENa_9L0-",
"reputation": "GoodPlayer",
"tier": "Gold",
"bio": "",
"location": "Hello from the otherside!"
}
GET /profiles/search/{gamertag}
Example profile:
{
"xuid": "2533275056522057",
"gamerscore": "28337",
"gamertag": "Hello",
"gamerpic": "https://images-eds-ssl.xboxlive.com/image?url=wHwbXKif8cus8csoZ03RW8ke8ralOdP9BGd4wzwl0MJ9z6QzuGwZjtvbE7sSsMVWdbcqfkxoWP60BSmwjdrqjdnbtjpTZg2sgv2Zu6A4iNhBj4V1ePvsMGSKEhUsgp5yZqOg.wtIFgQcnAf.8lY8BoeFGho.yDFWyybpENa_9L0-",
"reputation": "GoodPlayer",
"tier": "Gold",
"bio": "",
"location": "Hello from the otherside!"
}