Development APIs : The get functions

This second suite of functions (cf the main api and the list functions) was initially created as part of a set of “data sanity checking” web pages, however it became apparent that their usefullness lived beyond my own needs, so they have been brought in-line with the other functions, and made generic.

Data returns

All APIs return data in the same ways:

  1. You can specify the format either with the Accepts header in the http request, or with the format parameter. The options are ‘prototype’ (the only place this format is available), ‘json’, ‘xml’, or ‘text’, with ‘json being the default if nothing is specified.
    • If there’s a callback parameter, and the format is json, then a crossDomain package is returned… very useful!
  2. For prototype returns, the data is formatted as an xhtml unordered list (as per the scriptalicious/prototype requirements), with the for attribute set to match EPrints field names.
  3. For all other returns, the data is a list of data records (as per the desciption here)

The queries

Currently at http://devel.edina.ac.uk:1201/cgi/get_xxx5, this is a suite of three APIs that are there to support AJAX calls.

The basic premis is that the term to be looked up is passed in a parameter “q”, and all the records that have that term somewhere in the data are returned.

Additional parameters can be used to tune the query:

  • format will define the format being returned
  • field will specify which field to query on (see the individual functions for more details on this)

The three queries are:

  • get_orgs5
  • get_nets5
  • get_repos5

get_orgs5

This query will search either the name or the url to return a list of organisaions that match. By default, the name field is searched.

get_nets5

This query will search either the name or an ip number to return a list of networks that match. By default, the name field is searched, however if the script spots an IP number, it will automatically switch to an ip search.

get_repos5

This query will search either by name or url to return a list of networks that match. By default, the name field is searched.

Comments are closed.