This is the version 2 of the API.
Before getting into the hard definitions, here are some words to help you understand the rest better.
The basic idea is: each linkode can have several nodes, it's a tree with only one root. The initial version of a linkode is created without specifying an id, and it will be the root. Subsequent versions will be children of already created nodes; all share the same root id.
- type: POST - url: /api/2/linkode/ - data: content: the content of the linkode (Unicode!) text_type: the type of the content (plain text, Python, diff, C, etc.) [optional] read_only: set to "true" if you want the linkode to be read only. [optional] (default: false) - returns: linkode_id: the unique id of the new node linkode_url: the URL to access that node root_id: the id of the root of all the structure (as in this case a brand new linkode was created, it matches the node id) root_url: the URL to access the linkode
>>> import requests >>> data = {'content': 'The content of a Python script', 'text_type': 'python'} >>> response = requests.post("https://linkode.org/api/2/linkode", json=data) >>> response.status_code 201 >>> response.json() {'linkode_id': '7bxvJqtvFIggJnyNXba1K4', 'linkode_url': '/api/2/linkode/7bxvJqtvFIggJnyNXba1K4', 'root_id': '7bxvJqtvFIggJnyNXba1K4', 'root_url': '/api/2/linkode/7bxvJqtvFIggJnyNXba1K4'}
$ curl -s -H 'Content-type: application/json' -d ' > {"content": "The content of a Python script", "text_type": "python"}' \ > "https://linkode.org/api/2/linkode" { "linkode_id": "SrDotVY03btcJBxSAtINC6", "linkode_url": "https://linkode.org/api/2/linkode/SrDotVY03btcJBxSAtINC6", "root_id": "SrDotVY03btcJBxSAtINC6", "root_url": "https://linkode.org/api/2/linkode/SrDotVY03btcJBxSAtINC6" }
To get here an example in your favorite programming language please open an issue.
- type: POST - url: /api/2/linkode/<parent_linkode_id>/ - data: content: the content of the new node (Unicode!) text_type: the type of the content (plain text, Python, diff, C, etc.) [optional] read_only: set to "true" if you want the linkode to be read only. [optional] (default: false) - returns: linkode_id: the unique id of the new node linkode_url: the URL to access that node root_id: the id of the root of all the structure root_url: the URL to access the root linkode
>>> # a children of root >>> update = {'content': 'new content', 'text_type': 'python'} >>> response = requests.post("https://linkode.org/api/2/linkode/7bxvJqtvFIggJnyNXba1K4/", json=update) >>> response.status_code 201 >>> response.json() {'linkode_id': 'TRgCnj5fXrcEC66dALDxt7', 'linkode_url': '/api/2/linkode/TRgCnj5fXrcEC66dALDxt7', 'root_id': '7bxvJqtvFIggJnyNXba1K4', 'root_url': '/api/2/linkode/7bxvJqtvFIggJnyNXba1K4'} >>> >>> # a children of the just created node >>> update = {'content': 'even newer content', 'text_type': 'python'} >>> response = requests.post("https://linkode.org/api/2/linkode/TRgCnj5fXrcEC66dALDxt7/", json=update) >>> response.status_code 201 >>> response.json() {'linkode_id': 'dkaj4P3pJrdpMZomSKuQb7', 'linkode_url': '/api/2/linkode/dkaj4P3pJrdpMZomSKuQb7', 'root_id': '7bxvJqtvFIggJnyNXba1K4', 'root_url': '/api/2/linkode/7bxvJqtvFIggJnyNXba1K4'}
$ # a children of root $ curl -s -H 'Content-type: application/json' -d ' > {"content": "new content", "text_type": "python"}' \ > "https://linkode.org/api/2/linkode/SrDotVY03btcJBxSAtINC6/" { "linkode_id": "x1F110pkRqWclAhXVcqtD1", "linkode_url": "https://linkode.org/api/2/linkode/x1F110pkRqWclAhXVcqtD1", "root_id": "SrDotVY03btcJBxSAtINC6", "root_url": "https://linkode.org/api/2/linkode/SrDotVY03btcJBxSAtINC6" } $ $ # a children of the just created node $ curl -s -H 'Content-type: application/json' -d ' > {"content": "even newer content", "text_type": "python"}' \ > "https://linkode.org/api/2/linkode/x1F110pkRqWclAhXVcqtD1/" { "linkode_id": "ww9RtsVzx6srGGjYmlpiY5", "linkode_url": "https://linkode.org/api/2/linkode/ww9RtsVzx6srGGjYmlpiY5", "root_id": "SrDotVY03btcJBxSAtINC6", "root_url": "https://linkode.org/api/2/linkode/SrDotVY03btcJBxSAtINC6"
To get here an example in your favorite programming language please open an issue.
- type: GET - url: /api/2/linkode/<linkode_id>/ - returns: linkode_id: the unique id of the new node linkode_url: the URL to access that node content: the text of the node text_type: its text type read_only: whether it is read only timestamp: when it was created root_id: the id of the root of all the structure root_url: the URL to access the linkode
>>> response = requests.get("https://linkode.org/api/2/linkode/TRgCnj5fXrcEC66dALDxt7/") >>> response.status_code 200 >>> response.json() {'content': 'even newer content', 'linkode_id': 'TRgCnj5fXrcEC66dALDxt7', 'linkode_url': '/api/2/linkode/TRgCnj5fXrcEC66dALDxt7', 'read_only': False, 'root_id': '7bxvJqtvFIggJnyNXba1K4', 'root_url': '/api/2/linkode/7bxvJqtvFIggJnyNXba1K4', 'text_type': 'python', 'timestamp': '2024-08-22T19:57:22.244297'}
$ curl -s "https://linkode.org/api/2/linkode/x1F110pkRqWclAhXVcqtD1/" { "content": "new content", "linkode_id": "x1F110pkRqWclAhXVcqtD1", "read_only": false, "linkode_url": "https://linkode.org/api/2/linkode/x1F110pkRqWclAhXVcqtD1", "root_id": "SrDotVY03btcJBxSAtINC6", "root_url": "https://linkode.org/api/2/linkode/SrDotVY03btcJBxSAtINC6", "text_type": "python", "timestamp": "2024-08-22T20:12:38.023853" }
To get here an example in your favorite programming language please open an issue.
- type: GET - url: /api/2/tree/<linkode_id>/ # only for the root id - returns: A tree structure, each node having: linkode_id: the node id timestamp: when it was created children: a list of nodes (each with exactly this info, recursive) for whose this node is the parent
>>> response = requests.get("https://linkode.org/api/2/tree/7bxvJqtvFIggJnyNXba1K4/") >>> response.status_code 200 >>> response.json() {'linkode_id': '7bxvJqtvFIggJnyNXba1K4', 'timestamp': '2024-08-22T12:31:53.237094', 'order': 1, 'children': [{'children': [{'children': [], 'linkode_id': 'dkaj4P3pJrdpMZomSKuQb7', 'order': 3, 'timestamp': '2024-08-22T19:57:54.454925'}], 'order': 2, 'linkode_id': 'TRgCnj5fXrcEC66dALDxt7', 'timestamp': '2024-08-22T19:57:22.270264'}]}
$ curl -s "https://linkode.org/api/2/tree/SrDotVY03btcJBxSAtINC6/" { "children": [ { "children": [ { "children": [], "linkode_id": "ww9RtsVzx6srGGjYmlpiY5", "order": 3, "timestamp": "2024-08-22T20:13:24.673839" } ], "linkode_id": "x1F110pkRqWclAhXVcqtD1", "order": 2, "timestamp": "2024-08-22T20:12:38.499254" } ], "linkode_id": "SrDotVY03btcJBxSAtINC6", "order": 1, "timestamp": "2024-08-22T12:49:29.845979" }
To get here an example in your favorite programming language please open an issue.