Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

elvanto/api-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Elvanto API Node.js Library

This library is all set to go with version 1 of the Elvanto API.

Installation

The preferred way to install Elvanto for Node.js is to use the npm package manager for Node.js. Simply type the following into a terminal window:

npm install elvanto-api

Authenticating

The Elvanto API supports authentication using either OAuth 2 or an API key.

What is This For?

  • This is an API wrapper to use in conjunction with an Elvanto account. This wrapper can be used by developers to develop programs for their own churches, or to design integrations to share to other churches using OAuth authentication.
  • Version 1.0.0

Using OAuth 2

This library provides functionality to help you obtain an access token and refresh token. The first thing your application should do is redirect your user to the Elvanto authorization URL where they will have the opportunity to approve your application to access their Elvanto account. You can get this authorization URL by using the authorizeUrl method, like so:

var elvanto = require('elvanto-api');
var authorizeUrl = elvanto.authorizeUrl(clientId, redirectUri, scope, state);
// Redirect your users to authorizeUrl.

If your user approves your application, they will then be redirected to the redirectUri you specified, which will include a code parameter, and optionally a state parameter in the query string. Your application should implement a handler which can exchange the code passed to it for an access token, using exchangeToken like so:

var elvanto = require('elvanto-api');
elvanto.exchangeToken(clientId, clientSecret, code, redirectUri, callback);
elvanto.configure({accessToken: accessToken});
// Use callback function to get access to access_token, expires_in and refresh_token.

At this point you have an access token and refresh token for your user which you should store somewhere convenient so that your application can look up these values when your user wants to make future Elvanto API calls.

Once you have an access token and refresh token for your user, you can authenticate and make further API calls like so:

var elvanto = require('elvanto-api');
elvanto.configure({accessToken: newAccessToken});
allPeople = elvanto.apiCall("people/getAll", {}, callback);

All OAuth tokens have an expiry time, and can be renewed with a corresponding refresh token. If your access token expires when attempting to make an API call, you will receive an error response, so your code should handle this. Here's an example of how you could do this:

var elvanto = require('elvanto-api');
elvanto.refreshToken(refreshToken, callback);

Using an API key

var elvanto = require('elvanto-api');
elvanto.configure({apiKey: apiKey});
var people = elvanto.apiCall("people/search", {"search": {"firstname": firstname}}, callback);

Documentation

Documentation can be found on the Elvanto API website.

Updates

Follow our Twitter to keep up-to-date with changes in the API.

Support

For bugs with the API Node JS Wrapper please use the Issue Tracker.

For suggestions on the API itself, please post in the forum or contact us via our website.