Developer API
The PhoneGap Build API allows applications to use the PhoneGap Build web service to create, build, update, and download PhoneGap apps. It integrates easily into IDEs, shell scripts, app builders, and elsewhere.
The core sections discussed in this documentation article are:
Here are some additional notes on using the API.
JSON
All successful requests return either a JSON-encoded string or a binary file. All requests that fail return a JSON-encoded string in the following form, with an appropriate status code:
{
"error":"some error message"
}
When using the API, check each returned status code; if it's not 200, check the error field on the parsed response, for example:
if (res.status != 200)
console.log(JSON.parse(res.body).error)
As is standard in HTTP, a 4xx status indicates an error with the request, while a 5xx status indicates an server error. Contact PhoneGap's support forums if you get a 500 error, or an unexpected 400 error.
JSONP
JSONP access is available for PhoneGap Build developers: just add a callback
parameter to your requests, and the JSONP response body is wrapped in that function:
$ curl https://build.phonegap.com/api/v1/me?auth_token=ASTRINGTOKEN&callback=exec
exec({
"username":"alunny",
"email":"andrew.lunny@nitobi.com"
})
This allows you to access the PhoneGap Build API using <script>
tags.
HATEOAS
Wherever possible, the PhoneGap Build API v1 uses Hypermedia as the Engine of Application State (HATEOAS). This means you can access the source of the api (/api/v1
), then follow nested resources' link
attributes to navigate the application, with no knowledge of the other routes within your application.
The home resource for the API v1 is the same as the /me
resource, which represents the current user.