Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Node.js REST Client for the PhoneGap Build API
JavaScript
tag: 0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
package.json

README.md

phonegap-build-rest-js Build Status

Node.js REST Client for the PhoneGap Build API

Overview

This library simplfies authentication and requests to the PhoneGap Build REST API for node.js clients.

In many ways, this library is little more than a convenience wrapper for mikeal's request library. You can expect that all of request's functionality to be available to the API object returned by client.auth();.

If something is inaccurate or missing, please send a pull request!

API

Authentication

var client = require('phonegap-build-rest');

// Authenticate
client.auth({ username: 'zelda', password: 'tr1f0rce' }, function(e, api) {

    // GET https://build.phonegap.com/api/v1/me
    api.get('/me', function(e, data) {
        console.log(data.username);
    });

});

Authentication Options

var client = require('phonegap-build-rest');

var options = {
    username: 'zelda',               // Required
    password: 'tr1f0rce',            // Required
    protocol: 'https:',              // Optional
    host:     'build.phonegap.com',  // Optional
    port:     80,                    // Optional
    path:     '/api/v1'              // Optional
};

client.auth(options, function(e, api) {
    // ...
});

GET Requests

// GET https://build.phonegap.com/api/v1/apps

api.get('/apps', function(e, data) {
    console.log(data.apps[0].title);
});

or use the short-hand syntax:

// GET https://build.phonegap.com/api/v1/apps

api('/apps', function(e, data) {
    console.log(data.apps[0].title);
});

POST Requests

// POST https://build.phonegap.com/api/v1/apps

var options = {
    'data': { 'title': 'My App', 'create_method': 'file' },
    'form': { 'file': '/Users/alunny/app.zip' }
};

api.post('POST /apps', options, function(e, data) {
    console.log(data.id);
});

PUT Requests

// PUT https://build.phonegap.com/api/v1/apps/:id

var options = {
    'form': { 'file': '/Users/alunny/app.zip' }
};

api.put('apps/10', options, function(e, data) {
    // app 10 is now rebuilding
});

DELETE Requests

// DELETE https://build.phonegap.com/api/v1/apps/:id

api.delete('/apps/10', function(e, data) {
    // app 10 is deleted
});

Alternative Implementations

Java

Node.js

Something went wrong with that request. Please try again.