Skip to main content

A lightweight ORM for Linked Data: Consume Linked Data resources, modify the graph and write the changes back to their original source

Project description

Ldtools is a simple library to handle RDF data in a convenient way. It can be used as a simple ORM for Linked Data Resources and their Origins. A resource “” might be mentioned by different origins. Ldtools helps to keep track of verified statements (authoritative) about resources and provides an API to query more information about resources.

Different rdf triple storage backends are provided for the retrieved data: RestBackend, FileBackend or MemoryBackend

The CLI ldtools can be used to retrieve information about linked data resources.


Just use pip:

pip install Ldtools

This will install all dependencies (argparse, rdflib) needed and provide the command line utility “ldtools”.

Alternatively, do a git clone and execute python install/develop.

How to use it?

Via the commandline, all information within a Linked Data resource can be retrieved by executing:


Further options can be utilised to influence whether the URIs that are discovered within the origin should be followed and how deep. Try:

ldtools --help

for more usage information.

Alternatively, the python console can be used:

First, we create an Origin object:

import pprint, rdflib
from ldtools.resource import Resource
from ldtools.origin import Origin

uri = ""
origin, created = Origin.objects.get_or_create(uri)

Process it, hopefully discovering more Origins in there (rdfs:seeAlso, owl:sameAs…):


If everything went well, there now is a Resource object for our uri:

resource, created = Resource.objects.get_or_create(uri, origin=origin)

Process all the other Origins we know about:


Result: 5 URIs crawled and 500 Resources discovered and processed.


  • The Semantic Web is out there and there is really not enough tools yet to work with Linked Data

  • SPARQL is not needed to get the RAW data from resources, this library demonstrates that. Just the basic Linked Data Stack: URIs, Content Negotiation, RDF needed

  • ldtools intends to make it easy to handle the data you get from an URI and to follow links you discover

  • Based on that, you can modify your objects and PUT them back to their origin


To run the tests, install spec and/or nose and run nose:

pip install spec coverage
nosetests --with-coverage --cover-package=ldtools
nosetests --with-specplugin

Build Status status_image


Feel free to submit ideas and bugs to, I’ll be happy to accept pull requests for new features.

Thank you Travis CI for running the tests :)

Thanks to Django, Flask, peewee and sentry for inspiration regarding model structure!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Ldtools-0.8.0.tar.gz (16.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page