RESTful Model Access (RMA) is an HTTP service designed along RESTful principles to allow access to data in the Allen Institute API. Data model queries support JSON, XML and CSV formats. They can include join, filter, sort, page and eager loading of associations. RMA can also pipe results to perform compound queries and connect to data services. RMA services support JSON and XML formats. The API utility, RMA Query Builder, can be used to compose RMA queries.
The path to the RMA service is /api/v2/data. Other models may be substituted for Organism, such as Gene, Chromosome, or Structure. Model names are always capitalized and singular. The number following the model is a resource id. Valid result formats include JSON (.json), XML (.xml) and CSV (.csv)
Use a browser or other HTTP client to access:
Use the keyword query rather than an id to search across all resources in a model.
Use the keyword describe to retrieve information about the available associations for a model. .json format is also available.
Use the keyword enumerate to retrieve information about all available models and associations. .json format is also available.
Use the keyword query without a model or id if the needed information is specified elsewhere in the url. The part after the question mark is explained throughout this document.
JSON, XML and CSV formats are supported. For example:
Resources in the models are associated with other resources. Display this additional information using the include= parameter:
Retrieve details for the Chromosome with ID=12 and include its associated organism:
The associated information will be nested in the response:
The include= parameter is discussed in more detail in the RMA Path Syntax section.
Use the criteria parameter to refine the query.
The following criteria will find chromosome resources from the organism with NCBI taxonomy id 9606 (which happens to be Homo Sapiens).
The criteria= parameter is discussed in more detail in the RMA Path Syntax section.
Use the only= or except= parameters to restrict the attributes returned in the response. By default the results include all literal attributes of the resource. These options can be applied to model stages, but not service or pipe stages.
Use tabular= to restrict the attributes and also return them in a tabular format. Use 'as' to alias an attribute name or 'distinct' to eliminate duplicate rows. This option is recommended for accessing data in applications where sorting and paging are used in a tabular, spreadsheet-like display. This option can be applied to model stages, but not service or pipe stages. The csv format is required to be tabular and it defaults to displaying all attributes of the model. If associated models are referenced in the tabular= option, they should be present in a criteria= option as well. The tabular= option masks include= for serialization purposes.
Limit the number of results by using the start_row=, num_rows= and order= URL parameters. Use num_rows=all to retrieve all records (not recommended for large queries). The response body contains information about the progress of paging. Use count=false if you do not want paging information returned in the response.
Request the first Product by specifying start_row=0:
Request 10 Products beginning with the 20th row, and order by the Products' names:
|num_rows||Integer (optional)||Requested page size. The default is 50.|
|start_row||Integer (optional)||First row number requested. This is zero-based.|
|order||String (optional)||The value of order= is an attribute name which may be qualified with a lowercase plural table name (i.e. organisms.name). Use a comma-separated list in the order= parameter to sort on multiple attributes. Sort in reverse order by adding +desc to the order= parameter.|
|num_rows||Number of rows returned.|
|start_row||First row number requested. This is zero-based.|
|total_rows||The total number of rows that met the search criteria.|
RMA uses the ActiveRecord Query Interface.
|criteria||Associations are treated like an AR Query joins() argument and can be thought of as a series of SQL inner joins.|
|include||Associations are treated like an AR Query includes() argument and are used to drive eager loading of the associated resources. They can be thought of as a series of SQL outer joins.|
|start_row||Generates an offset() AR Query argument and is similar to an SQL OFFSET clause.|
|num_rows||Generates a limit() AR Query argument and is similar to an SQL ORDER BY clause.|
|order||Generates an order() AR Query argument and is similar to an SQL ORDER BY clause.|
||Includes debugging information in the response such as equivalent ActiveRecord and SQL queries when set to 'true'.|
The filter clauses in both the criteria= parameter and the includes= parameter are treated as an AR Query where() argument. They can be thought of as an SQL where clause combined with the boolean 'and' operation.
Models are similar to SQL tables, attributes correspond to literal SQL columns and associations can be thought of as SQL foreign keys.