Skip to content
kimor79 edited this page Apr 5, 2013 · 4 revisions

api_producer is a template for use by web service APIs to provide a consistent public interface and behavior.

Output

For most output formats, the API will return at least a 'status' field. The value is similar to HTTP response codes:

  • 200 - Success
  • 400 - Client error
  • 500 - Server error

A 'message' field may also be present which will contain any errors.

Record-based API calls (in addition to above)

  • records - An array of records
  • recordsReturned - The number of records in the response
  • sortDir - Which direction the records are sorted
  • sortField - The field on which the records are sorted
  • startIndex - Which record number the records start at
  • totalRecords - The total number of records matching the search

Parameters

Parameters that support multiple values can be set either as foo[]=bar&foo[]=baz or usually comma separated (depends on the actual call), e.g. foo=bar,baz

A "true" value is: 1, on, true, yes
A "false" value is: 0, false, no, off

Supported Parameters

  • contentType - Set this to a false value to not include a Content-Type header. For example, the json outputFormat adds a Content-Type: application/json header
  • flatOutput - If data has nested arrays, set this to a true value to not have nested arrays and instead have nested.foo keys
  • outputFormat - What format to return output: json (default), print_r; others depending on the actual call, e.g. csv, list, xml
  • subDetails - If data has nested data, include nested data (eg do the JOIN)

Record-based API calls (in addition to above)

  • csvHeader - Add a header row to csv output
  • numResults - How many results to display (for pagination)
  • outputFields - Comma separated list of fields to return
  • sortDir - Which direction to sort on: asc (default), desc
  • sortField - Which column to sort on
  • startIndex - Where to start (for pagination)

Search fields can be defined in several formats:

String fields

  • field - Exact match
  • field_re - Regex match

Numeric fields

  • field - Exact match
  • field_ge - Greater than or equal to
  • field_gt - Greater than
  • field_le - Less than or equal to
  • field_lt - Less than