Skip to content

Sample REST API based on Express.js demonstrating BlizzAPI features

License

Notifications You must be signed in to change notification settings

blizzapi/blizzapi-example

Repository files navigation

BlizzAPI logo

blizzapi-example

Build status codecov

Sample REST API based on Express.js demonstrating BlizzAPI features.

Note that this project is for illustrative purposes only. It is not designed to run as a production server.

Deploy to Heroku

Install

git clone https://github.com/blizzapi/blizzapi-example.git
cd blizzapi-example
npm install

Setup

Register a client app with Blizzard Battle.net Developer Portal. Note down client id and client secret.

Copy and rename the file .env.sample to .env. Edit it accordingly:

PORT='8080'
API_BATTLENET_KEY='your client app id'
API_BATTLENET_SECRET='your client app secret'

Run

With Node:

npm start

With Nodemon:

nodemon start.js

Available endpoints

API endpoints

GET /api/query/:region?endpoint=:endpoint

Fetches data from a Battle.net API endpoint using a specified regional server using BlizzAPI.query method.

Example: http://localhost:8085/api/query/1?endpoint=/sc2/profile/1/2/242838

GET /api/validateAccessToken/:region/:accessToken

Checks if access token is valid using BlizzAPI.validateAccessToken method.

Example: http://localhost:8085/api/validateAccessToken/eu/sampleAccessToken

GET /api/getAccessToken/:region

Obtains and returns OAuth access token using BlizzAPI.getAccessToken method.

Example: http://localhost:8085/api/getAccessToken/eu

Utility endpoints

Utility endpoints match the following pattern:

GET /utils/BlizzAPI_funtion_name_here/:parameter1/:parameter2ifNeeded

Examples:

http://localhost:8085/utils/getAllRegions
http://localhost:8085/utils/validateRegionName/eu
http://localhost:8085/utils/isLocaleValidForRegionId/en_US/1

For a complete list of method names see BlizzAPI utility methods.

License

Licensed under MIT License. See LICENSE for more information.

Legal

Battle.net and Blizzard Entertainment are trademarks or registered trademarks of Blizzard Entertainment, Inc. in the U.S. and/or other countries.