Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.
/ blizzapi-example Public archive

Sample REST API based on Express.js demonstrating BlizzAPI features

License

Notifications You must be signed in to change notification settings

lwojcik/blizzapi-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blizzapi-example

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.

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

License

Licensed under MIT License.

Legal

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