TheBigDB Python bindings.
Python
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
README.md
__init__.py
requirements.pip
tests.py
thebigdb.py

README.md

TheBigDB Python Wrapper

A simple python wrapper for making requests to the API of TheBigDB.com. Full API documentation.

Install

Just grab the file thebigdb.py. You'll only need to have the package requests intalled.

Simple usage

First, you need to initialize the class with:

from thebigdb import TheBigDB
thebigdb = TheBigDB()

The following actions return a dict object from the parsed JSON the server answered.

Search (api doc)

thebigdb.search({"subject": {match: "James"}, "property": "job", "answer": "President of the United States"})
thebigdb.search({"subject": "London", "property": "population"}, {"period": {"on": "2007-06-05"}})

Create (api doc)

thebigdb.api_key = "your-private-api-key"

thebigdb.create({"subject": "iPhone 5", "property": "weight", "answer": "112 grams"})
thebigdb.create({"subject": "Bill Clinton", "property": "job", "answer": "President of the United States"}, {"period": {"from": "1993-01-20 12:00:00", "to": "2001-01-20 12:00:00"}})

Show (api doc), Upvote (api doc) and Downvote (api doc)

thebigdb.show("id-of-the-sentence")

thebigdb.upvote("id-of-the-sentence") # don't forget to set your API key
thebigdb.downvote("id-of-the-sentence") # don't forget to set your API key

That's it!

Response object

If you want more details on what has been received, you can check thebigdb.response after each request. It is the object returned by the requests package after each request.

It has several readable attributes:

thebigdb.show("id-of-the-sentence")
thebigdb.response.content       # String of the actual content received from the server
thebigdb.response.headers       # Dict of the headers received from the server

More details

Other Features

You can access other parts of the API in the same way as statements:

thebigdb.user(action, parameters)

# Examples
thebigdb.user("show", {"login": "christophe"})["user"]["karma"]

Requirements

  • Python 2.7+

Contributing

Don't hesitate to send a pull request !

Testing

First, install the required packages:

pip install -r requirements.pip

Then, run the tests in the tests.py file with:

nosetests

Thanks

  • bobtwinkles for creating the first version of this wrapper
  • The community for their invaluable feedback!