Skip to content

appyay/appyay-management-js

Repository files navigation

Appyay Management Javascript SDK

Client Javascript library (node and browser) for Appyay Content Management API.

Getting started

To get started with the Appyay Management JS SDK you'll need to install it, and then get credentials which will allow you to access your content in Appyay.

Installation

npm i

This library is still in development and not yet available on NPM.

Usage

Initialisation

Node & browser

import {createClient} from "appyay-management-js";
const client = createClient({
        environmentId: '<environment_id>', 
        accessToken: '<access_token>', //for write access
        apikey: '<api_key>' //for read access
   });

Browser

<script src="path/to/appyay-delivery-js/dist/appyay-management.browser.js"></script>

Accessing the global variable:

const client = appyayManagement.createClient({
        environmentId: '<environment_id>', 
        accessToken: '<access_token>', //for write access
        apikey: '<api_key>' //for read access
   });

API

Client API

Get Content Types

    client.getContentTypes()
    .then(function(response){
        console.log('content types retrieved', response.contentTypes);
    });

Get Content Type

    client.getContentType(contentTypeId)
    .then(function(response){
        console.log('content type retrieved', response.id);
    });

Get Items

    client.getItems(contentTypeId)
    .then(function(response){
        console.log('items retrieved', response.items);
    });

Get Content Item

    client.getItem(itemId)
    .then(function(item){
        console.log('item retrieved', item);
    });

Create Item

    client.createItem(contentTypeId, { 
        fields: {
        title: 'New post'
        },
        status: 'published'
    })
    .then(function(item){
        console.log('item created', item);
    });

Content Types API

Get Items

    contentType.getItems()
    .then(function(response){
        console.log('items retrieved', response.items);
    });

Delete Content Type

    contentType.delete();

Add Item

    contentType.addItem({
        fields: {
        title: 'New post'
        },
        status: 'published'
    })
    .then(function(response){
        console.log('items retrieved', response.items);
    });

Item API

Update Item

    let title = 'Updated post';
    item.fields.title = title;
    item.update();

Delete Item

    item.delete();

Supported environments

Browsers and Node.js:

  • Chrome
  • Firefox
  • Edge
  • Safari
  • node.js (6.x, 8.x)

Testing

node <path_to_appyay-management-js>/test/integration/index.js

Support

If you have a problem with this library, please file an issue here on GitHub.

About

JavaScript SDK for the Appyay Content Management API (node and browser).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published