Giter Site home page Giter Site logo

py-xbox-webapi's Introduction

Xbox-WebAPI

Xbox-WebAPI is a python library to authenticate with Xbox Live via your Microsoft Account and provides Xbox related Web-API.

Authentication via credentials or tokens is supported, Two-Factor-Authentication is also possible.

Dependencies

  • Python >= 3.4
  • Libraries: requests, python-dateutil, demjson, six

Installation

To install this library, execute the following via cmdline

python setup.py install

Authentication

import sys
from xbox_webapi.authentication.auth import AuthenticationManager
from xbox_webapi.common.exceptions import AuthenticationException

# Tokens will be saved on successful login
# That way credentials can be omitted next time
# Usage with valid tokens:
# auth_mgr = AuthenticationManager('tokens.json')
# try:
#     auth_mgr.authenticate()
# except AuthenticationException as e:
#     print('Tokens are expired! Err: %s' % e)
#     sys.exit(-1)

auth_mgr = AuthenticationManager('tokens.json')
try:
    tokenstore = auth_mgr.authenticate(email_address="[email protected]", password="password")
except AuthenticationException as e:
    print('Email/Password authentication failed! Err: %s' % e)
    sys.exit(-1)

# Tokenstore holds tokens and userinfo
print(tokenstore.refresh_token)
print(tokenstore.xsts_token)
print(tokenstore.userinfo)

API usage

import sys, json
from xbox_webapi.api.provider import XboxLiveClient

ts = tokenstore

xbl_client = XboxLiveClient(ts.userinfo.userhash, ts.xsts_token, ts.userinfo.xuid)
# For Xbox One
resp = xbl_client.eds.get_singlemediagroup_search("cuphead", 10, "DGame", domain="Modern")
# For 360
# xbl_client.eds.get_singlemediagroup_search("skate", 10, "Xbox360Game", domain="Xbox360")
if resp.status_code != 200:
    print("Invalid EDS details response")
    sys.exit(-1)

print(json.dumps(resp.json(), indent=2))

Documentation

Soon.. maybe...

py-xbox-webapi's People

Contributors

anthonylavado avatar tuxuser avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.