REST Connector Configuration

On the Data Connections screen in MAPS Config, select Add Connection. Choose REST Connector from the list of data connection types.Rest Connector option on the Add Data Connection dialog, showing as not installed

Select the Install button to download and install the driver.

Connection successfully installed

When installation is complete, select Configure to configure the data connection properties.

On the General screen, enter a descriptive name for the data connection, and any desired notes.

Connection Name: USGS Earthquake Catalog.  Notes: This data connection uses the REST Connector to connect to the USGS Earthquake database.

Driver Properties

Driver Properties screen with Base URL of https://earthquake/usgs.gov/fdsnws/event/1/, response type of XML, logging basic, and authentication none.

On the Driver Properties screen, enter the following parameters:

Custom Headers

Custom Headers screen underneath Driver Properties showing a custom header field called "X-API-Key" and a value consisting of the string API key.

The Custom Headers screen allows you to include optional custom headers in the HTTP request, if the API supports or requires it. Custom headers may be used for authentication or to specify an environment (such as a sandbox account) of the REST source. Type in the name of the header field, followed by its value. Use the Add and Remove buttons underneath the list of custom headers to add or remove additional custom headers as needed.

Endpoint Configuration

Next, select Endpoint Configuration under the Driver Properties tab.

Endpoints screen showing the URI, Schema Name, and XPath of the endpoints that have been configured for this connection.

Select Add at the bottom of the dialog to add an endpoint.

Edit REST Endpoint dialog with Endpoint, XPath, and Table Name fields.  The base URL is shown at the top.  In this example, the base URL is "https://earthquake.usgs.gov/fdsnws/event/1/", and the endpoint is "query".

The Edit REST Endpoint dialog has three fields:

Your Endpoints may require a variable value to be placed in the URL path. To use a variable in the Endpoint URL, use the format [_input.<variable_name>]. For Example, if searching for students by ID, at the Endpoint: students/{id}, you would type: student/[_input.id] in the Endpoint field. Whatever field is used for [_input.<variable_name>] must be in the schema.

Note: This format will only work when the WHERE clause contains "=" for the variable. In addition, only a single value can be assigned to the variable.

Input varibales have to exist in the schema.

Generate Schema

Select the Generate Schema button to generate the schema file by calling the API using the parameters and paths specified. You will be prompted to (temporarily) edit the constructed URL to include query parameters that limit the data. This will allow the API call to complete faster so that you can quickly retrieve a list of fields without downloading a lot of data.

MAPS will make a test API call in order to generate the schema. To avoid requesting a large number of records, you can add some limiting query parameters to the test URL. URL: edit field "https://earthquake.usgs.gov/fdsnws/event/1/query".  Warning: Testing this endpoint may result in data charges for your institution if there is a cost associated with using this API.

As an example, for the earthquake API above we might add a start and end time to the query to limit it to a few results:

https://earthquake.usgs.gov/fdsnws/event/1/query?format=xml&starttime=2014-01-01&endtime=2014-01-02

Select OK to proceed. Depending on the amount of data being returned, it may take a moment to complete the request. If the request was successful, you should see an updated XPath, the schema name, and a list of fields in the Fields table below.

Edit REST Endpoint dialog showing a table name of "event" followed by a list of fields found in the data.  Fields in the earthquake data include: description_text, description_type, event__id, magnitude_creationInfo_agencyID, magnitude_evaluationMode, and many others in a list.

Edit Schema

The Edit Schema button opens the definition file for the schema. You may need to modify this file if a field is not detected as the correct data type. Otherwise, you should not need to make changes to the schema definition.

Pagination

The REST Connector supports customization of four different pagination styles, each of which allows all available sets of data to be returned. Once configured, the REST connection endpoint will automatically page the results when a query is executed and the full result will be returned.

Selecting the Pagination button will open the Pagination Options window.

The Edit Pagination screen, where you can select your desired style of pagination.

The default option will be set to None, which means that the API will not page through the data. Open the drop-down list to select one of the four types of pagination supported by the REST Connector.

Next Page URL.

Paging Token option.

Record Offset option.

Page Number option.

Map Query Parameters

The next step is to map query parameters available in the API to the different comparison operators for each field that DataBlock Designers may want to use in their queries. This allows MAPS to intelligently convert (or 'map') the query written by the user into an API call that makes use of the available URL parameters provided by the API. Without this, the API call will request all records, and then MAPS will filter the results after they come back.

Select a field that relates to a parameter available in the API, then click the Map Query Parameters button.

Two operator/parameter pairs have been added: Less than corresponds to maxmagnitude, and greater than corresponds to minmagnitude.

You will default to the Map Query Parameters page, however you will also have the option to navigate to the Set Advanced Filters using the radio buttons near the top.

Use the Add Operator/Parameter Pair button to add the operator(s) you want to configure, then enter the parameters that should be associated with those operators.

In the example above, we are specifying the parameters that will be used if a query uses the less than or greater than comparison operators against the magnitude_mag_value field in its WHERE clause. If the query contains WHERE magnitude_mag_value > 5 (i.e., limiting results to earthquakes with magnitudes greater than 5), the API call will now contain &minmagnitude=5 in the parameter list.

Query Construction

Queries must be kept relatively simple in order to take advantage of any query parameter mappings you have configured. See the Query Construction section at the end of the Using the REST Connector in Argos page for examples of supported SQL.

Set Advanced API Filters

Configure JSON objects/arrays that will be used in the URL of an endpoint.

Selecting the Set Advanced Filters radio button will allow you to configure JSON objects/arrays that will be used in the URL of an endpoint.

Selecting Add, Edit, or Delete will open the Edit Advanced API Filter screen.

Select Object or Array as your JSON Type.

When Object is selected as the JSON type:

When Array is selected as the JSON type:

Select Object or Array as your JSON Type.

When Comma Separated Objects is selected as your Array Structure, you will see the following options:

When Single Object is selected as the Array Structure, you will see the following options:

The Item Source is the field from the schema that triggers the inclusion of the value in the object when used in a SQL statement.

The REST data connection configuration is now complete. You do not need to modify any values on the Query Properties or SQL Formatting screens. If you want to set up specific users or groups on the User/Group Rules screen, each group that you want to be able to use this connection should be set to the default of "Use connection user name and password".

Lastly, authorize the connection for use with the desired application(s).