Skip to content

Quick start

oc-ocdm is a Python library for producing, modifying and exporting RDF data structures compliant with the OCDM specification. It requires Python 3.10 or later.

pip install oc-ocdm

Create a bibliographic resource, assign it a title and a DOI, then write the result to a JSON-LD file:

from oc_ocdm.graph import GraphSet
from oc_ocdm import Storer
base_iri = "https://w3id.org/oc/meta/"
resp_agent = "https://w3id.org/oc/meta/prov/pa/1"
g_set = GraphSet(base_iri)
br = g_set.add_br(resp_agent)
br.has_title("OpenCitations Meta")
br.create_journal_article()
br.has_pub_date("2024-03")
doi = g_set.add_id(resp_agent)
doi.create_doi("10.1162/qss_a_00292")
br.has_identifier(doi)
storer = Storer(g_set)
storer.store_graphs_in_file("output.jsonld")

This produces a JSON-LD file containing the RDF triples for the resource and its identifier.