Skip to content
Python Wrapper For Graph Commons API.
Python
Branch: master
Clone or download

Latest commit

Latest commit ebfa5bb Sep 8, 2018

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Sep 11, 2015
LICENSE Initial commit Sep 11, 2015
README.md Updating README examples to work using Entity's dictionary Jul 8, 2018
graphcommons.py Merge pull request #6 from gregoryfoster/5-basestring Sep 8, 2018
setup.py Update setup.py and bump version Sep 11, 2015

README.md

Python Wrapper For Graph Commons API.

More detailed API documentation:

http://graphcommons.github.io/api-v1/

Installation

pip install graphcommons

Usage

Authentication

>>> from graphcommons import GraphCommons
>>> graphcommons = GraphCommons('<YOUR_API_KEY>')
>>> graphcommons.status()
{u'msg': u'Working'}

Get graph

graph = graphcommons.graphs('7141da86-2a40-4fdc-a7ac-031b434b9653')
print(graph['name'])  # Hello from python

for node in graph.nodes:
    print(node['name'])

    print(graph.edges_from(node))  # edges directed from the node
    print(graph.edges_to(node))  # edges directed to the node

New Graph

from graphcommons import Signal

graph = graphcommons.new_graph(
    name="Hello from python",
    description="Python Wrapper Test",
    signals=[
        Signal(
            action="node_create",
            name="Ahmet",
            type="Person",
            description="nice guy"
        ),
        Signal(
            action="edge_create",
            from_name="Ahmet",
            from_type="Person",
            to_name="Burak",
            to_type="Person",
            name="COLLABORATED",
            weight=2
        )
    ]
)


print(graph['id'])  # added graph's id

Update Graph

from graphcommons import Signal

graphcommons.update_graph(
    id="7141da86-2a40-4fdc-a7ac-031b434b9653",
    signals=[
        Signal(
            action="node_create",
            name="Ahmet",
            type="Person",
            description="nice guy"
        ),
        Signal(
            action="edge_create",
            from_name="Ahmet",
            from_type="Person",
            to_name="Burak",
            to_type="Person",
            name="COLLABORATED",
            weight=2
        )
    ]
)
You can’t perform that action at this time.