PAGENODE

About Documentation Github

JSON Interface

You can enable Pagenode's JSON interface by defining the PN_JSON_API_PATH before including the pagenode.php. Be aware that enabling the JSON Interface makes it possible to load any .md file under the current directory.

To make the JSON interface available at /json:

// Enable JSON Interface
define('PN_JSON_API_PATH', '/json');

// Load Pagenode
require_once('pagenode.php');

You can then query the API:

Example Request:

/json?path=nodes&sort=date&order=asc&count=5&fields=title,date,body

Example Response:

{
    "nodes": [
        {
            "title": "JSON Interface",
            "date": 1540910835
        },
        {
            "title": "Adding Content",
            "date": 1542017904
        },
        {
            "title": "Pagenode",
            "date": 1543494733
        },
        {
            "title": "Getting Started",
            "date": 1543497516
        },
        {
            "title": "Routing Requests",
            "date": 1543502838
        }
    ],
    "info": {
        "totalRuntime": 0.5369850158691406
    }
}

The JSON API for this site is enabled. Give it try:

/json?path=nodes&fields=keyword,title,date,tags&tags=documentation,api

Parameters

path

The path from which to select nodes. Default ''.

fields

A comma separated list of all the Node properties you want to retrieve.

sort, order, count

Analogous to select()->query($sort, $order, $count).

keyword, date, tags, meta, page

Analogous to Selector Params.

To supply arrays for tags, meta or date you can specify &meta[title]=SomeTitle or &date[0]=2018.

© 2024 Dominic Szablewski – rendered in (1.96ms)