These are chat archives for WP-API/node-wpapi

8th
Jul 2016
kkuhler
@kkuhler
Jul 08 2016 19:01
@kadamwhite can you access the equivalent of these through the api
https://mysite.com/wp-json/ee/v4.8.36
https://mysite.com/wp-json/wp/v2
K Adam White
@kadamwhite
Jul 08 2016 19:03
you mean the root endpoints for each namespace?
kkuhler
@kkuhler
Jul 08 2016 19:04
yes... to see what is available
K Adam White
@kadamwhite
Jul 08 2016 19:05
Yep, there is. Two options:
If you use auto-discovery, then the namespace will be registered on the bound site client instance returned from the discovery method, and you can inspect its capabilities directly:
'use strict';

var WP = require( 'wpapi' );
var ready = WP.discover( 'http://demo.wp-api.org' )
    .then(function( site ) {
        // Enumerate the discovered methods
        console.log( Object.keys( site.namespace( 'wp/v2' ) ) );

        // Supports posts?
        console.log( !!site.namespace( 'wp/v2' ).posts );
    });
K Adam White
@kadamwhite
Jul 08 2016 19:11
Alternatively, you can make the queries directly using the .root method
var WP = require( 'wpapi' );
var site = WP.site( 'http://demo.wp-api.org/wp-json' );
site.root( 'wp/v2' ).then(function( results ) {
    console.log( results );
});
@kkuhler the .root method is probably more what you were asking for
kkuhler
@kkuhler
Jul 08 2016 19:12
excellent... either should work... Thanks so much.
K Adam White
@kadamwhite
Jul 08 2016 19:12
np!
Happy building
If you launch something using the library please let us know, we'll cross-promote!
kkuhler
@kkuhler
Jul 08 2016 19:15
my application is for custom reporting and display of data on my site (we have a business teaching technology and programming to children). Not something generally useful. but working with your code has made life much easier
K Adam White
@kadamwhite
Jul 08 2016 19:32
I am glad to hear it; thanks for asking questions and please let us know if you run into any further difficulties
Also, that sounds like an exciting business!
kkuhler
@kkuhler
Jul 08 2016 19:33
Its a good thing. We are enjoying it. Still working on the business model but its been good