Skip to content

gregoryfoster/graphcommons-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
        )
    ]
)

About

Python Wrapper For Graph Commons API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%