Giter Site home page Giter Site logo

brewerydb's Introduction

BreweryDB API Python Wrapper

This is a simple wrapper around the BreweryDB API packaged as a Python module.

Remember: Good People Drink Good Beer!

Version

  • 1.1 Reimplemented wrapper using reflection and updated README.
  • 1.0 Initial release

Todo

By Priority

  • Find elegant way to support post requests

Dependencies

Notes

This wrapper uses reflection to instantiate its methods at runtime. This was done to avoid huge amounts of code duplication. However, it also has the added benefit of allowing you to extend it without modifying it. Simply call one of:

__make_simple_endpoint_fun(name)
__make_singlearg_endpoint_fun(name)

This will generate a new function called name that creates a new request to: BreweryDb base url + "/" + name.

If your name has slashes in it, it will turn those into underscores for the method name. So for example, the method for the search/upc endpoint would be search_upc.

Usage

from brewerydb import *
BreweryDb.configure(apikey[, baseuri])

It is important that configure is called before calling any of the other methods. Methods are created at runtime during configure.

If you see an error: AttributeError: class BreweryDb has no attribute X

You most likely did not call BreweryDb.configure.

Code Examples

Fetching all beers:

BreweryDb.beers()

Getting a list of beers on a specific page:

BreweryDb.beers({'page':10})

Searching for beers with a specific query:

BreweryDb.search({'type':'beer','q':'unibroue'})

Getting a specific beer or brewery by ID:

BreweryDb.beer(O3tmVI)

Getting all the breweries around Seattle, WA:

BreweryDb.breweries({'geo':1,
                     'lat':47.6097,
                     'lng':-122.3331,
                     'radius':30,
                     'units':'m'})

brewerydb's People

Contributors

yarian avatar mjaskula avatar

Watchers

James Cloos 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.