{"id":32623210,"url":"https://github.com/ooridata/onya","last_synced_at":"2026-07-02T06:32:08.652Z","repository":{"id":138954684,"uuid":"336350687","full_name":"OoriData/Onya","owner":"OoriData","description":"Knowledge graph expression, serialization, and Python implementation. Useful for LLM context.","archived":false,"fork":false,"pushed_at":"2026-06-10T16:37:32.000Z","size":457,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-10T17:11:16.732Z","etag":null,"topics":["data","graph","knowledge-graph","model","property-graph","rdf","web"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OoriData.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2021-02-05T18:05:08.000Z","updated_at":"2026-06-10T16:37:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"1bd19738-7513-4e03-bf6d-f42eaafabac0","html_url":"https://github.com/OoriData/Onya","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/OoriData/Onya","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OoriData%2FOnya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OoriData%2FOnya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OoriData%2FOnya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OoriData%2FOnya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OoriData","download_url":"https://codeload.github.com/OoriData/Onya/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OoriData%2FOnya/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35036551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data","graph","knowledge-graph","model","property-graph","rdf","web"],"created_at":"2025-10-30T19:55:17.317Z","updated_at":"2026-07-02T06:32:08.645Z","avatar_url":"https://github.com/OoriData.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"**Onya** is a knowledge graph expression and implementation. This repository combines a [data model and format spec](SPEC.md) with a Python parser and API implementation.\n\nNote: Using our provided [onya-graph.SKILL.md](onya-graph.SKILL.md) with your favorite AI coding agent is a good way to automate Onya authoring and explore the format. Try providing a text document and asking it to generate a graph therefrom.\n\n# Python quick start\n\n[![PyPI - Version](https://img.shields.io/pypi/v/onya.svg)](https://pypi.org/project/Onya)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/onya.svg)](https://pypi.org/project/Onya)\n\n## Installation\n\n\u003c!--\n```bash\npip install amara\n```\n\nOr with uv (recommended):\n\n```bash\nuv pip install amara\n```\n--\u003e\n\nRequires Python 3.12 or later. The package is still in early development, so install directly from source:\n\n```bash\ngit clone https://github.com/OoriData/Onya.git\ncd Onya\npip install -U .\n```\n\n\u003c!--\npip install git+https://github.com/OoriData/Onya.git\n--\u003e\n\n## Command line tool\n\nYou can use the built-in CLI to export directly from an Onya Literate (`.onya`) file to the Mermaid diagram format:\n\n```sh\nonya convert test/resource/schemaorg/thingsfallapart.onya \u003e out.mmd\n```\n\nThen use a site such as https://mermaid.live/ to generate a diagram such as:\n\n![Running MLX-LM generate within Python](test/resource/schemaorg/thingsfallapart.png)\n\n## Basic Python Usage\n\nHere's a simple example demonstrating the core Onya API. First, let's define a small friendship graph in Onya Literate format:\n\n```\n# @docheader\n\n* @document: http://example.org/friendship-graph\n* @nodebase: http://example.org/people/\n* @schema: https://schema.org/\n\n# Chuks [Person]\n\n* name: Chukwuemeka Okafor\n* nickname: Chuks\n* age: 28\n\n# Ify [Person]\n\n* name: Ifeoma Obasi\n* nickname: Ify\n* age: 27\n```\n\nParse this graph and interact with it using the Python API.\n\n```python\nfrom onya.graph import graph\nfrom onya.serial.literate import LiterateParser\n\n# Parse the Onya Literate text into a graph\nonya_text = '''\n# @docheader\n\n* @document: http://example.org/friendship-graph\n* @nodebase: http://example.org/people/\n* @schema: https://schema.org/\n\n# Chuks [Person]\n\n* name: Chukwuemeka Okafor\n* nickname: Chuks\n* age: 28\n\n# Ify [Person]\n\n* name: Ifeoma Obasi\n* nickname: Ify\n* age: 27\n'''\n\ng = graph()\nop = LiterateParser()\nresult = op.parse(onya_text, g)\ndoc_iri = result.doc_iri\nprint(f'Parsed document: {doc_iri}')\nprint(f'Graph has {len(g)} nodes')\n\n# Access nodes and their properties\nchuks = g['http://example.org/people/Chuks']\nify = g['http://example.org/people/Ify']\n\n# Get a specific property value\nfor prop in chuks.getprop('https://schema.org/name'):\n    print(f'Name: {prop.value}')\n\n# Add a friendship edge between Chuks and Ify\nfriendship = chuks.add_edge('https://schema.org/knows', ify)\nprint(f'Added edge: {friendship}')\n\n# Add nested properties to the friendship (metadata about the relationship)\nfriendship.add_property('https://schema.org/startDate', '2018-03-15')\nfriendship.add_property('https://schema.org/description', 'Met at university')\n\n# Add a new property to Ify\nify.add_property('https://schema.org/jobTitle', 'Software Engineer')\n\n# Modify a property by removing the old one and adding a new one\nage_props = list(chuks.getprop('https://schema.org/age'))\nfor prop in age_props:\n    chuks.remove_property(prop)\nchuks.add_property('https://schema.org/age', '29')\n\n# Traverse edges\nfor edge in chuks.traverse('https://schema.org/knows'):\n    friend = edge.target\n    for name_prop in friend.getprop('https://schema.org/name'):\n        print(f'Chuks knows: {name_prop.value}')\n    # Access nested properties on the edge\n    for date_prop in edge.getprop('https://schema.org/startDate'):\n        print(f'  Friends since: {date_prop.value}')\n\n# Find all nodes of a certain type\nfor person in g.typematch('https://schema.org/Person'):\n    for name_prop in person.getprop('https://schema.org/name'):\n        print(f'Person in graph: {name_prop.value}')\n\n# Reserialize to Onya literate\nfrom onya.serial.literate import write\n\nwrite(g)\n```\n\nThis example demonstrates:\n- Parsing Onya Literate format\n- Accessing nodes and properties\n- Adding edges with nested properties (reified relationships)\n- Modifying properties\n- Traversing the graph\n- Querying by type\n\n# Visualization / export\n\nOnya includes simple serializers to help you visualize graphs:\n\n- **Graphviz (DOT)**: `from onya.serial import graphviz` → `graphviz.write(g, out=f)` (see `demo/graphviz_basic/`)\n- **Mermaid (flowchart)**: `from onya.serial import mermaid` → `mermaid.write(g, out=f)` (see `demo/mermaid_basic/`; quick viewing via [Mermaid Live Editor](https://mermaid.live/))\n\n# Command line tool\n\nYou can use the built-in CLI to export directly from an Onya Literate (`.onya`) file:\n\n```bash\n# Mermaid (default)\nonya convert test/resource/schemaorg/thingsfallapart.onya \u003e out.mmd\n\n# Graphviz DOT\nonya convert test/resource/schemaorg/thingsfallapart.onya --dot \u003e out.dot\n```\n\n# Acknowledgments\n\n\u003ctable\u003e\u003ctr\u003e\n  \u003ctd\u003e\u003ca href=\"https://oori.dev/\"\u003e\u003cimg src=\"https://www.oori.dev/assets/branding/oori_Logo_FullColor.png\" width=\"64\" /\u003e\u003c/a\u003e\u003c/td\u003e\n  \u003ctd\u003eOnya is primarily developed by the crew at \u003ca href=\"https://oori.dev/\"\u003eOori Data\u003c/a\u003e. We offer LLMOps, data pipelines and software engineering services around AI/LLM applications.\u003c/td\u003e\n\u003c/tr\u003e\u003c/table\u003e\n\n# Background\n\nOnya is based on experience from developing [Versa](https://github.com/uogbuji/versa) and also working on [the MicroXML spec](https://dvcs.w3.org/hg/microxml/raw-file/tip/spec/microxml.html) and implementations thereof.\n\nThe URL used for metavocabulary is [managed via purl.org](https://purl.archive.org/purl/onya/vocab).\n\nThe name is from Igbo \"ọ́nyà\", web, snare, trap, and by extension, network. The expanded sense is ọ́nyà úchè, web of knowledge.\n\n# Contributing\n\nContributions welcome! We're interested in feedback from the community about what works and what doesn't in real-world usage. To get help with the code implementation, read [CONTRIBUTING.md](CONTRIBUTING.md).\n\n# License\n\n- **Code** (Python library): Apache 2.0 - See [LICENSE](LICENSE)\n- **Specification** (wordloom_spec.md): [Creative Commons Attribution 4.0 International (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/) - See [LICENSE-spec](LICENSE-spec)\n\nThe specification is under CC BY 4.0 to encourage broad adoption and derivative work while ensuring attribution. We want the format itself to be as open and reusable as possible, allowing anyone to create implementations in any language or adapt the format for their specific needs.\n\n# Related Work\n\n- [networkx](https://github.com/networkx/networkx): Network Analysis in Python\n- [Apache AGE](https://github.com/apache/incubator-age): PostgreSQL Extension that for graphs. ANSI SQL \u0026 openCypher over the same DB.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fooridata%2Fonya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fooridata%2Fonya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fooridata%2Fonya/lists"}