AppApiPage adds the /page endpoint to the AppApi routes definition. Makes it possible to query pages via the api.

AppApiPage adds the /page endpoint to the AppApi routes definition. Makes it possible to query pages via the api.

Current Version Current Version Current Version

Buy Me A Coffee

Relies on AppApi:

Installation


AppApiPage relies on the base module AppApi, which must be installed before AppApiPage can do its work.

AppApi and AppApiPage can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules

The prerequisites are PHP>=7.2.0 and a ProcessWire version >=3.93.0 (+ AppApi>=1.2.0). However, this is also checked during the installation of the module. No further dependencies.

Quickstart


AppApiPage will add an api-endpoint that can be used to call any page in the processwire pagetree.

RouteDescription
/api/page/Calls the root page of the page-tree
/api/page/42Will call the page with id=42
/api/page/my/test/pageCalls your page with path my/test/page

Simply add the following code at the top of your ProcessWire-template to add JSON output:

<?php
// Check if AppApi is available:
if (wire('modules')->isInstalled('AppApi')) {
  $module = $this->wire('modules')->get('AppApi');
  // Check if page was called via AppApi
  if($module->isApiCall()){
    // Output id & name of current page
    $output = [
      'id' => wire('page')->id,
      'name' => wire('page')->name
    ];

    // sendResponse will automatically convert $output to a JSON-string:
    AppApi::sendResponse(200, $output);
  }
}

// Here continue with your HTML-output logic...

Changelog


Changes in 1.0.2 (2022-06-01)

  • Bugfix throw 404 status if not found

Changes in 1.0.1 (2022-04-29)

  • Added support for Multi-Language URLS

Changes in 1.0.0 (2022-03-06)

  • Added page endpoint

Versioning


We use SemVer for versioning. For the versions available, see the tags on this repository.

License


This project is licensed under the Mozilla Public License Version 2.0 - see the LICENSE.md file for details.

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Twitter updates

  • Adding custom actions to ProcessWire image fields in the admin, part of this week’s dev branch additions: More
    27 January 2023
  • ProcessWire 3.0.210 new main/master version released— More
    6 January 2023
  • ProcessWire 3.0.209: Core updates and an interesting AI that knows ProcessWire– More
    30 December 2022

Latest news

  • ProcessWire Weekly #456
    The 456th issue of ProcessWire Weekly covers latest core updates, introduces a new third party module called TextformatterRockDown, and more. Read on!
    Weekly.pw / 4 February 2023
  • ProcessWire 3.0.210 new main/master version
    140 commits, 55 resolved issues, dozens of new features, eight contributors, and five new pull requests make yet another great new version of ProcessWire.
    Blog / 6 January 2023
  • Subscribe to weekly ProcessWire news

“To Drupal, or to ProcessWire? The million dollar choice. We decided to make an early switch to PW. And in retrospect, ProcessWire was probably the best decision we made. Thanks are due to ProcessWire and the amazing system and set of modules that are in place.” —Unni Krishnan, Founder of PigtailPundits