2017 © Pedro Peláez
 

silverstripe-module silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

image

nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  • Monday, January 15, 2018
  • by nglasl
  • Repository
  • 2 Watchers
  • 13 Stars
  • 306 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 35 Versions
  • 3 % Grown

The README.md

apiwesome

The current release is 2.2.15, (*1)

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications., (*2)

Requirement

  • SilverStripe 3.0 → 3.5

This module is no longer supported., (*3)

Getting Started

  • Place the module under your root project directory.
  • Define any custom JSON/XML data object exclusions/inclusions through project configuration.
  • /dev/build
  • Select JSON/XML through the CMS.
  • Configure attribute visibility.
  • Regenerate the security token x:y
  • /apiwesome/retrieve/data-object-name/json?token=x:y
  • /apiwesome/retrieve/data-object-name/xml?token=x:y

Overview

Data Object Exclusions/Inclusions

ALL data objects are included by default (excluding some core), unless disabled or inclusions have explicitly been defined., (*4)

DataObjectOutputConfiguration::customise_data_objects('exclude', array(
    'DataObjectName'
));
DataObjectOutputConfiguration::customise_data_objects('include', array(
    'DataObjectName'
));

To completely disable the JSON/XML:, (*5)

DataObjectOutputConfiguration::customise_data_objects('disabled');

Attribute Visibility Customisation

visibility, (*6)

The JSON/XML feed will only be available to data objects with attribute visibility set through the CMS. Any has_one relationships may be displayed, where attribute visibility is determined recursively., (*7)

Recursive Relationships

These are enabled by default, however will greatly impact performance if many nested relationships are visible., (*8)

To disable the recursion:, (*9)

Injector:
  APIwesomeService:
    properties:
      recursiveRelationships: false

Security Token

A JSON/XML feed request will require the current security token passed through, where this may be regenerated by an administrator (invalidating the previous security token)., (*10)

token, (*11)

The security token generation (and validation) is modular, and can still be used when the JSON/XML is completely disabled (more below):, (*12)

SecurityAdmin:
  extensions:
    - 'APIwesomeTokenExtension'

Output

A JSON/XML feed request may have a number of optional filters applied, where the &filter will only apply to visible attributes:, (*13)

  • &limit=5
  • &sort=Attribute,ORDER
  • &filter1=value
  • &filter2=value

It may also be previewed through the appropriate model admin of your data object., (*14)

preview, (*15)

Pretty JSON

This is enabled by default, however will slightly impact performance if many nested relationships are visible., (*16)

To disable the pretty printing:, (*17)

Injector:
  APIwesomeService:
    properties:
      prettyJSON: false

Developer Functionality

PHP

Accessing the service:, (*18)

$service = Singleton('APIwesomeService');

The methods available may be programmatically called to generate JSON, with optional filters:, (*19)

$JSON = $service->retrieve('DataObjectName', 'JSON');
$JSON = $service->retrieve('DataObjectName', 'JSON', 5, array(
    'Attribute',
    'ORDER'
), array(
    'Attribute1' => 'value',
    'Attribute2' => 'value'
));
$objects = DataObjectName::get()->toNestedArray();
$JSON = $service->retrieveJSON($objects);

XML, with optional filters:, (*20)

$XML = $service->retrieve('DataObjectName', 'XML');
$XML = $service->retrieve('DataObjectName', 'XML', 5, array(
    'Attribute',
    'ORDER'
), array(
    'Attribute1' => 'value',
    'Attribute2' => 'value'
));
$objects = DataObjectName::get()->toNestedArray();
$XML = $service->retrieveXML($objects);

JSON/XML for a versioned page (though the CMS may not correctly preview XML), with regard to the respective stage in index():, (*21)

return $service->retrieveStaged($this->data()->ID, 'JSON');

They may also be used to parse JSON/XML from another APIwesome instance. Therefore, this module may be used as both an API and external connector between multiple projects., (*22)

$objects = $service->parseJSON($JSON);
$objects = $service->parseXML($XML);

The security token validation (and generation) is modular, and can be used for other applications (more above):, (*23)

$validation = $service->validateToken($this->getRequest()->getVar('token'));
switch($validation) {
    case APIwesomeService::VALID:

        // The token matches the current security token.

        break;
    case APIwesomeService::INVALID:

        // The token does not match a security token.

        break;
    case APIwesomeService::EXPIRED:

        // The token matches a previous security token.

        break;
}

jQuery

JSON example:, (*24)

;(function($) {
    $(function() {

        $.getJSON('//ss3.1/apiwesome/retrieve/data-object-name/json?token=' + token(), function(JSON) {

            // Iterate over each data object.

            if(JSON['APIwesome'] !== undefined) {
                $.each(JSON['APIwesome']['DataObjects'], function(index, object) {

                    // The JSON feed security token is no longer valid!

                    if((index === 'Expired') && (object === true)) {
                        return false;
                    }

                    // Iterate over each visible attribute.

                    $.each(object, function(type, attributes) {
                        $.each(attributes, function(attribute, value) {
                        });
                        break;
                    });
                });
            }
        })

        // The JSON feed has either not yet been configured, or no data objects were found.

        .fail(function() {
        });

    });
})(jQuery);

Maintainer Contact

Nathan Glasl, nathan@symbiote.com.au

The Versions

15/01 2018

dev-master

9999999-dev https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml feed silverstripe

15/01 2018

2.2.15

2.2.15.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml feed silverstripe

01/08 2017

2.2.14

2.2.14.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml feed silverstripe

23/05 2017

2.2.13

2.2.13.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml feed silverstripe

17/02 2017

2.2.12

2.2.12.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml feed silverstripe

16/02 2017

2.2.11

2.2.11.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml feed silverstripe

16/02 2017

2.2.10

2.2.10.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml feed silverstripe

15/02 2017

2.2.9

2.2.9.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml feed silverstripe

01/02 2017

2.2.8

2.2.8.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml feed silverstripe

19/01 2017

2.2.7

2.2.7.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

05/01 2017

2.2.6

2.2.6.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

20/06 2016

2.2.5

2.2.5.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

20/06 2016

2.2.4

2.2.4.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

12/05 2016

2.2.3

2.2.3.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

17/03 2016

2.2.2

2.2.2.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

16/03 2016

2.2.1

2.2.1.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

16/03 2016

2.2.0

2.2.0.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

17/01 2016

2.1.x-dev

2.1.9999999.9999999-dev https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

17/01 2016

2.1.1

2.1.1.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

05/11 2015

2.1.0

2.1.0.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

02/11 2015

2.0.x-dev

2.0.9999999.9999999-dev https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

02/11 2015

2.0.3

2.0.3.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

15/07 2015

2.0.2

2.0.2.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

12/07 2015

2.0.1

2.0.1.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

29/05 2015

1.2.x-dev

1.2.9999999.9999999-dev https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

29/05 2015

1.1.x-dev

1.1.9999999.9999999-dev https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

27/05 2015

2.0.0

2.0.0.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

25/05 2015

1.2.3

1.2.3.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

19/05 2015

1.2.2

1.2.2.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

05/05 2015

1.2.1

1.2.1.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

04/05 2015

1.2.0

1.2.0.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages).

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

10/04 2015

1.1.3

1.1.3.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

12/01 2015

1.1.2

1.1.2.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

12/12 2014

1.1.1

1.1.1.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe

25/11 2014

1.1.0

1.1.0.0 https://github.com/nglasl/silverstripe-apiwesome

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects.

  Sources   Download

BSD-3-Clause

The Requires

 

api json xml silverstripe