diggrtoolbox.unified_api package

Submodules

diggrtoolbox.unified_api.diggr_api module

class diggrtoolbox.unified_api.diggr_api.DiggrAPI(base_url, get_on_item=False, raw=False)[source]

Bases: object

This class provides easy access to the diggr unified API. On initialization you have to provide the address of your desired unified API endpoint. You can now set the dataset and filters, which are persistent until reset. This allows you to iterate over a dataset without having to apply a filter each time.

The get() method will do some magic to determine the correct way of creating the directory string depending on the content and dataset selected. I.e. prepend a “/slug”, if the identifier is a slug and not an id, or replace slashes in gamefaqs ids.

Example:
>>> d = DiggrAPI("http://localhost:6660").dataset("mobygames").filter("companies")
>>> result = d.item("1").get()

For the sake of readability you may want to execute the query immediately after the item is set.

>>> d = DiggrAPI("http://localhost:6660", get_on_item=True)
>>> d.dataset("mobygames").filter("companies")
>>> results = []
>>> for i in range(10):
>>>     results.append(d.item(i))
DATASETS = ('mobygames', 'gamefaqs', 'mediaartdb')
FILTERS = ('companies', 'links', 'cluster')
dataset(dataset)[source]

Selects a dataset.

directory

Returns the directory string from self.query. Raises ValueError if no dataset or item is set.

filter(filterstring)[source]

Applies a filter. Must be in self.FILTERS.

get()[source]

Runs the query and returns the result.

item(id_or_slug)[source]

Selects an item, can be given a numeric id or a slug. Returns self or the result of the query if get_on_item is set.

Module contents

class diggrtoolbox.unified_api.DiggrAPI(base_url, get_on_item=False, raw=False)[source]

Bases: object

This class provides easy access to the diggr unified API. On initialization you have to provide the address of your desired unified API endpoint. You can now set the dataset and filters, which are persistent until reset. This allows you to iterate over a dataset without having to apply a filter each time.

The get() method will do some magic to determine the correct way of creating the directory string depending on the content and dataset selected. I.e. prepend a “/slug”, if the identifier is a slug and not an id, or replace slashes in gamefaqs ids.

Example:
>>> d = DiggrAPI("http://localhost:6660").dataset("mobygames").filter("companies")
>>> result = d.item("1").get()

For the sake of readability you may want to execute the query immediately after the item is set.

>>> d = DiggrAPI("http://localhost:6660", get_on_item=True)
>>> d.dataset("mobygames").filter("companies")
>>> results = []
>>> for i in range(10):
>>>     results.append(d.item(i))
DATASETS = ('mobygames', 'gamefaqs', 'mediaartdb')
FILTERS = ('companies', 'links', 'cluster')
dataset(dataset)[source]

Selects a dataset.

directory

Returns the directory string from self.query. Raises ValueError if no dataset or item is set.

filter(filterstring)[source]

Applies a filter. Must be in self.FILTERS.

get()[source]

Runs the query and returns the result.

item(id_or_slug)[source]

Selects an item, can be given a numeric id or a slug. Returns self or the result of the query if get_on_item is set.