Endpoints for API calls

Version: 0.9.1 (beta)

Supported client libraries: Javascript, Python

API Functions

endpoint.makeUrl({method, service, domain, path, secure, version}, extendedPath)

This function creates the url endpoint for api calls or widgets and can be used for all apis.

Options

  • method: api function or widget to be called.
  • service: The name of the service to construct the url for
  • domain (optional): The subdomain name or fully qualified domain name. e.g ‘mydomain’ will be extended to ‘mydomain.nive.io’. The domain is only required for cross domain calls or in development mode.
  • path (optional): To be used with services using a subtree structure (e.g. FileStore). Setting the base url can delegate the api call to the wanted level in the subtree.
  • secure (optional): Disable ssl encryption by seting ‘secure’ to false. By default https protocol is used.
  • version (optional): The api version identifier to be used e.g. ‘api’. Future releases of apis will have version numbers to support backward compatibility and long term stability of apis.
  • extendedPath (optional): additional relative path to be used in services with subtree structure (e.g. FileStore). extendedPath is used by libraries in the first place to overwrite the path parameter passed in options dict. Calling makeUrl() directly makes this obsolete, just use path directly.

Throws endpoint.EndpointException if required values are missing.

Returns

Url to be used in http requests

Javascript Examples

This example returns the url to call getItem of a mystorage DataStorage service.

// get DataStorage.getItem api url
var url = nive.endpoint.makeUrl({
               'method': 'getItem',
               'name': 'mystorage',
               'version': 'api'
          });

The same as above. But this time the domain is explicitly added to the url.

// get DataStorage.getItem api url for domain 'mydomain'
var url = nive.endpoint.makeUrl({
               'method': 'getItem',
               'name': 'mystorage',
               'domain': 'mydomain.com',
               'version': 'api'
          });

If hosted on nive.io you can also simply pass the domain as my-nive-domain. It will be extended to my-nive-domain.nive.io.

// get DataStorage.getItem api url for domain 'mydomain'
var url = nive.endpoint.makeUrl({
               'method': 'getItem',
               'name': 'mystorage',
               'domain': 'my-nive-domain',
               'version': 'api'
          });

The File Store service uses a hirarchical directory structure to store content. To list the files contained in /first/second directory you need to pass in the parameter path.

// get FileHost.list api url for the subtree level '/first/second'
var url = nive.endpoint.makeUrl({
               'method': 'list',
               'name': 'myapp',
               'version': 'api',
               'path': '/first/second'
          });

This example returns the url to load the signup widget of the User Account service.

// get user signup widget url
var url = nive.endpoint.makeUrl({
               'method': 'signup',
               'version': 'widget',
               'name': 'users'
          });