Get Data
This endpoint allows you to get data from a database. This is useful should you want to get all data for that database or if you want to selectively query for rows of data based on specific conditions (perhaps to ascertain what data the database currently holds and to find whether it needs to be updated).
POST Parameters
| Parameter | Required | Value | Description |
|---|---|---|---|
api_key | {key} | An API key that has access to the resource you want to query for | |
database_id | {integer} | The ID of the database you want to get data for | |
column_id | {string} | Enter one or more column IDs as a comma-separated list (e.g., 123,456). Each ID should be a numeric identifier corresponding to specific columns. | |
row | |||
type | {string} | Specify the data structure type. Accepted values are table or array. If left blank, the default value is table. | |
limit | {integer} | The number of rows that you want to have returned (Default: 100) | |
offset | {integer} | If the response contains more rows than the limit, you can choose at what row the result will show | |
conditions | {associative array} | The conditions allow you to set certain parameters which you want to filter the result on. E.g. you may wish to only return rows where certain column(s) contain certain value(s) |
Using Conditions: You can pass either the column name or column ID within the conditions (e.g., conditions [123] is the same as conditions [columnA] if columnA had an ID of 123).
Example: conditions [columnA] =value1&conditions [columnB] =value2
Note: When using more than one condition, "&" equates to "or" not "and".
i.e., a condition of "43827=Current2&46293=New Zealand" will return records where column 43827 = "Current" OR column 46293 = "New Zealand"
Code Examples
The cURL, PHP, Python, Node.js, and C# examples call Xtracta from a trusted server. The React example calls an application-defined backend proxy so the API key is never exposed in browser code.
Store XTRACTA_API_KEY as a server-side environment variable. Never embed it in browser-delivered code.
curl --request POST 'https://api-app.xtracta.com/v1/databases/data' \ --header 'Accept: application/json' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'api_key=<API_KEY>' \ --data-urlencode 'database_id=<DATABASE_ID>' \ --data-urlencode 'conditions[A]=test' \ --data-urlencode 'conditions[B]=value'
Sample Request
POST https://api-app.xtracta.com/v1/databases/data HTTP/1.1 api_key=123&database_id=456789&conditions[A]=test&conditions[B]=value
Sample Response
<?xml version="1.0" encoding="UTF-8"?>
<databases_response>
<status>200</status>
<message>The request has been successfully processed</message>
<data>
<row id="1">
<column id="61">test</column>
<column id="62">value</column>
<column id="63">51234124</column>
</row>
<row id="2">
<column id="61">test</column>
<column id="62">value</column>
<column id="63">512363</column>
</row>
<row id="3">
<column id="61">test</column>
<column id="62">value</column>
<column id="63">512390789</column>
</row>
</data>
</databases_response>
Schema Definition
Response Elements
| Element | Description |
|---|---|
<status> | A status code in response to the operation. |
<message> | Additional information about the operation ā human readable. |
<data> | The unique ID of the database. |
<data>ā<row> | A container for the row of data (including its row_id) |
<data>ā<row>ā<column> | The column (and column_id) of the field of data and the data from within the row. |
Example
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="ValueRowType"><xs:simpleContent><xs:extension base="xs:string"><xs:attribute name="id" type="xs:positiveInteger" use="required"/></xs:extension></xs:simpleContent></xs:complexType>
<xs:complexType name="ValueColumnType"><xs:sequence><xs:element name="row" type="ValueRowType" maxOccurs="unbounded"/></xs:sequence><xs:attribute name="id" type="xs:positiveInteger" use="required"/></xs:complexType>
<xs:complexType name="TableColumnType"><xs:simpleContent><xs:extension base="xs:string"><xs:attribute name="id" type="xs:positiveInteger" use="required"/></xs:extension></xs:simpleContent></xs:complexType>
<xs:complexType name="TableRowType"><xs:sequence><xs:element name="column" type="TableColumnType" maxOccurs="unbounded"/></xs:sequence><xs:attribute name="id" type="xs:positiveInteger" use="required"/></xs:complexType>
<xs:complexType name="DataType"><xs:choice><xs:element name="row" type="TableRowType" maxOccurs="unbounded"/><xs:element name="column" type="ValueColumnType" maxOccurs="unbounded"/></xs:choice></xs:complexType>
<xs:element name="databases_response"><xs:complexType><xs:sequence>
<xs:element name="status" type="xs:positiveInteger"/><xs:element name="message" type="xs:string"/><xs:element name="data" type="DataType" minOccurs="0"/>
</xs:sequence></xs:complexType></xs:element>
</xs:schema>
Error Responses
For JSON and XML responses generated by this endpoint, the response is wrapped in databases_response and includes the HTTP status code and a message.
| Status | Message | Description |
|---|---|---|
400 | database_id is required / database_id must be natural number | Supply the positive integer database ID to query. |
400 | <parameter> must be natural number | limit, offset, and row must use supported non-negative or positive integer values. |
400 | column_id must be comma separated values | Supply column IDs as a comma-separated list. |
404 | No data found | No accessible row matched the database, column, row, or condition filters. |
500 | Internal server error occurred. Please try again later or contact support@xtracta.com | Retry and contact support with the request parameters and timestamp if it persists. |
Authentication, permission, IP-access-control, and rate-limit failures can be returned before this endpoint processes the request. Confirm the API key and caller access first.