Giter Site home page Giter Site logo

cabalist / py-bgg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from crustymonkey/py-bgg

0.0 1.0 0.0 33 KB

A simple Board Game Geek (boardgamegeek.com) API library in Python. This mainly just handles the API calls and converts the XML to representative dict/list format

License: GNU General Public License v2.0

Python 100.00%

py-bgg's Introduction

py-bgg

A simple Board Game Geek (boardgamegeek.com) API library in Python.
This mainly just handles the API calls and converts the XML to representative dict/list format

UPDATE: This is now feature complete for version 2 of the BGG API!

INSTALL

Installation is pretty easy. You can just to the standard as root:

tar -xvzf py-bgg-*.tar.gz
cd py-bgg-*
python setup.py install

You can also install directly using pip or easy_install

pip install py-bgg
easy_install py-bgg

USAGE

This follows the BGG api pretty closely so this should be self-explanatory with "pydoc libbgg" and the api definition at:

http://boardgamegeek.com/wiki/page/BGG_XML_API
http://boardgamegeek.com/wiki/page/BGG_XML_API2

BASIC TUTORIAL

This library will essentially just convert your calls into a URL and subsequently return a dict/list tree of objects that are accessible via standard object notation or dictionary style access

#!/usr/bin/env python

import json

from libbgg.apiv1 import BGG

conn = BGG()

# Perform a search
results = conn.search('bruges')
print(json.dumps(results, indent=4, sort_keys=True))

# Print out a list of names that were returned
for game in results.boardgames.boardgame:
    print(game.name.TEXT)

# You can also access items as a dictionary
for game in results['boardgames']['boardgame']:
    print(game['name']['TEXT'])

# Get game info
results = conn.get_game(136888, stats=True)
print(json.dumps(results, indent=4, sort_keys=True))

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.