API Overview

From ampEducator

(Redirected from API)
Jump to: navigation, search

Contents

Introduction

ampEducator offers an easy to use and powerful RESTFul API gateway allowing you to move information in and out of the application effortlessly. The API gateway is accessed by posting HTTP request queries and receiving data in XML or JSON formats. There are four basic operations: POST, GET, PUT and DELETE.

POST

To add a new prospect to ABC School we can do the following:

https://username:password@abcschool.ampeducator.com/api/v1/prospects?method=POST&firstName=John&lastName=Smith&responseType=xml

In response we would get something like:

<response statusCode="200" statusMessage="OK" method="POST">

  <metaData/>
  <messages> 
    <general>The prospect was successfully added.</general>
    <withErrors>false</withErrors>
  </messages>
  <data>
    <prospect id="123"> 
      <createdByUserID>23</createdByUserID>
      <createdDateTime>2012-12-01 09:44:33</createdDateTime>
      <recruiterID>54</recruiterID>
      <locationID>1</locationID>
      <firstName>John</firstName>
      <lastName>Smith</lastName>
      <expectedRevenue>0.0</expectedRevenue> 
      <expectedRevenueProbability>0.0</expectedRevenueProbability>  
    </prospect>
  </data> 
</response>

The API will respond will both an HTTP status code as well as provide feedback using messages embedded in the response.

GET

Now if we wanted to get that prospect at a later time:

https://username:password@abcschool.ampeducator.com/api/v1/prospects/123

Response:

<response statusCode="200" statusMessage="OK" method="GET">

  <metaData/>
  <messages> 
    <withErrors>false</withErrors>
  </messages>
  <data>
    <prospect id="123"> 
      ...
    </prospect>
  </data> 
</response>

Note that if no method is specified, it is assumed to be GET. If we want to get all prospects with say a status of 'Lead':

https://username:password@abcschool.ampeducator.com/api/v1/prospects?currentStatus=Lead&limit=3

Response:

<response statusCode="200" statusMessage="OK" method="GET">

  <metaData>
    <currentRecord>3</limit>
    <totalRecords>453</totalRecords>
    <criteria>currentStatus=Lead;LIMIT 0,10</criteria>
  </metaData>
  <messages>
    <withErrors>false</withErrors>
  </messages>
  <data>
    <prospects>
      <prospect id="342">
      ....
      </prospect>
      <prospect id="122">
      ....
      </prospect>
      <prospect id="432">
      ....
      </prospect>
    </prospects>
  </data>
</response>

In addition to responding with the data the api will also provide additional information about the result in the metaData section of the response.

PUT

We can also update the prospect by specifying the changed fields. For example to update where this prospect's expected revenue:

https://username:password@abcschool.ampeducator.com/api/v1/prospects/123?method=PUT&expectedRevenue=5500.00&expectedRevenueProbability=75.00

Response:

<response statusCode="200" statusMessage="OK" method="PUT">

  <metaData/>
  <messages>
    <general>Prospect was successfully updated.</general>
    <withErrors>false</withErrors>
  </messages>
  <data>
    <prospect id="123">
      ...
      <expectedRevenue>5500.00</expectedRevenue>
      <expectedRevenueProbability>75.00</expectedRevenueProbability>
    </prospect>
  </data>
</response>

DELETE

Lastly we can delete the prospect.

https://username:password@abcschool.ampeducator.com/api/v1/prospects/123?method=DELETE

The result being:

<response statusCode="200" statusMessage="OK" method="DELETE">
  <metaData/>
  <messages>
    <general>The prospect was successfully deleted.</general>
    <withErrors>false</withErrors>
  </messages>
  <data>
    <prospect>
      <prospectID>123</prospectID>
    </prospect>
  </data>
</response>

These are the basics. In these examples we've used the 'method' parameter to tell the API how it should handle the request but the API ca also determine the method from the HTTP Request Method (i.e. POST,GET,PUT,DELETE). Continue reading to find out all the details.


Setup & Authentication

In order to use the api an administrator must enable it through the Institution module in the ampEducator application. When enabling the API a username, password and optionally an email configuration must be made. Each request to the API must then include this authorization string. While there are more secure methods like oAuth we felt the complexity involved for the end developer was not justified. Basic authorization over HTTPS is essentially the same level of security which we provide to regular admins and the API has pretty much the same level of access as an administrator. For more information on HTTP Basic Authentication please see http://en.wikipedia.org/wiki/Basic_access_authentication.


Endpoint URL

The api can be accessed at https://purl.ampeducator.com/api/v1/endpoint where purl is the purl of your institution and the endpoint is one of the endpoints available. Only access through HTTPS is available and currently there is only v1 of the API.


Parameters

In order to make the api as useful and flexible as possible the following parameters are accepted. In cases where they do not apply they will be ignored by the API. All parameters are optional.










Dates & Times

The API expects all dates and times to be in 24hr mySql format.


Encoding

The API expects all incoming data to be encoded as UTF-8.

Personal tools
Namespaces
Variants
Actions
Home
Tutorials
Manual
API
Other
Toolbox