TracCloud: API: Difference between revisions

From Redrock Wiki

No edit summary
No edit summary
 
Line 300: Line 300:
==TracCloud Table List==
==TracCloud Table List==


This is a list of TracCloud data tables and fields that are relevant for API access.
[[TracCloud:_Rosetta|Click here to view a list of TracCloud tables and fields accessible via the API.]]


<hr>
<div style="float: left; margin-top: 0em; margin-bottom: 1em"><big>Type Definitions</big></div><div class="mw-collapsible mw-collapsed">
<br><br>
{| class="wikitable" border="1" style="margin:auto"
!Type!!Description
|-
|varchar(#)||Alphanumeric field with a specified maximum length.
|-
|int||Integer, maximum value of about 4 billion, or a 10-digit numeric value.
|-
|bigint||Big integer, maximum value of about 9 quintillion, or a 16-digit numeric value.
|-
|tinyint||Tiny integer, typically used to store a 1 or 0 as true or false.
|-
|date||Date, formatted as YYYY-MM-DD
|-
|time||A specific time using a 24-hour format (HH:MM:SS), e.g., 13:45:00
|-
|datetime||Date and time, YYYY-MM-DD HH:MM:SS
|-
|double||Decimal # with up to 12 digits precision
|-
|json||JSON-formatted field that contains multiple fields and values (e.g., custom fields).
|}
</div>
<hr>
<div style="float: left; margin-top: 0em; margin-bottom: 1em"><big><b>Visits</b></big></div><div style="float: right">[[TracCloud:_Rosetta|Moved {{#fas:arrow-up-right-from-square}}]]</div>
<br>
<hr>
<div style="float: left; margin-top: 0em; margin-bottom: 1em"><big><b>Appointments</b></big></div><div style="float: right">[[TracCloud:_Rosetta|Moved {{#fas:arrow-up-right-from-square}}]]</div>
<hr>
<div style="float: left; margin-top: 0em; margin-bottom: 1em"><big><b>Students</b></big></div><div style="float: right">[[TracCloud:_Rosetta|Moved {{#fas:arrow-up-right-from-square}}]]</div>
<br>
<hr>
<div style="float: left; margin-top: 0em; margin-bottom: 1em"><big><b>Staff</b></big></div><div style="float: right">[[TracCloud:_Rosetta|Moved {{#fas:arrow-up-right-from-square}}]]
</div>
<hr>
<div style="float: left; margin-top: 0em; margin-bottom: 1em"><big><b>Subject Related</b> (Courses, Sections, Terms, Registrations, Faculty, SectionSchedule)</big></div><div style="float: right">[[TracCloud:_Rosetta|Moved {{#fas:arrow-up-right-from-square}}]]</div>
<br>
<hr>
<div style="float: left; margin-top: 0em; margin-bottom: 1em"><big><b>Profile Related</b> (Profiles, Centers, Groups, Reasons)</big></div><div style="float: right">[[TracCloud:_Rosetta|Moved {{#fas:arrow-up-right-from-square}}]]
</div>
<hr>
<div style="float: left; margin-top: 0em; margin-bottom: 1em"><big><b>SurveyTrac Related</b> (Surveys, SrvyQuestions, Responses, SrvyRespAnswers)</big></div><div class="mw-collapsible mw-collapsed">
<br><br>
{| class="wikitable"
|+ Surveys
|-
! Column !! Type !! Notes
|-
|Sequence|| bigint AI PK || Static identifier for each Survey.
|-
|Name|| varchar(80) ||
|-
|CreatedBy|| bigint || Relates to Staff.Sequence.
|-
|Options|| json || This field can be ignored for API purposes.
|-
|ProfileID|| bigint || Relates to Profiles.Sequence.
|-
|CenterID|| bigint ||
|-
|AutoSend|| varchar(80) || The chosen "Initiated Via" option.
|-
|Active|| tinyint ||
|-
|ActiveFrom|| date ||
|-
|ActiveTo|| date ||
|-
|Instructions|| text ||
|-
|useXML|| tinyint || Unused.
|-
|Assessment|| tinyint || Unused.
|-
|Function|| varchar(80) || Unused.
|-
|Confirmation|| text ||
|-
|HeadText|| text||
|}
{| class="wikitable"
|+ SrvyQuestions
|-
! Column !! Type !! Notes
|-
|Sequence||bigint AI PK||Static identifier for each Question, sequences are not reused even across multiple surveys.
|-
|Question||text||
|-
|SurveyID||bigint|| Relates to Surveys.Sequence.
|-
|Points||double||
|-
|Answer||varchar(80)||
|-
|AnswerChoices||text||
|-
|Options||json||
|-
|LinkName||varchar(80)|| Unused.
|-
|LinkURL||varchar(80)|| Unused.
|-
|Type||varchar(80)||
|-
|Number||int||
|-
|CustomData||json||
|}
{| class="wikitable"
|+ Responses
|-
! Column !! Type !! Notes
|-
|Sequence||bigint AI PK || Static identifier for each response.
|-
|SurveyID||bigint || Relates to Surveys.Sequence.
|-
|linkedUID||varchar(36) ||
|-
|SentByID||varchar(36) ||
|-
|StudentID||bigint || Relates to Students.Sequence (not Students.ID).
|-
|SentBy||varchar(80) ||
|-
|SentDate||datetime ||
|-
|AnsweredDate||datetime ||
|-
|StaffID||bigint || Relates to Staff.Sequence.
|-
|FacultyID||bigint || Relates to Faculty.Sequence.
|-
|SentManually||tinyint ||
|-
|CustomData||json||
|}
{| class="wikitable"
|+ SrvyRespAnswers
|-
! Column !! Type !! Notes
|-
|Sequence||bigint AI PK ||Static identifier for each question response.
|-
|QuestionID||bigint || Relates to SrvyQuestions.Sequence.
|-
|ResponseID||bigint || Relates to Responses.Sequence.
|-
|aAnswer||varchar(80) ||
|-
|nAnswer||double ||
|-
|tAnswer||text ||
|-
|CustomData||json||
|}
</div>
<hr>
</div>
<hr>
<hr>
</div>
</div>
[[Category:TracCloud Manual]]
[[Category:TracCloud Manual]]

Latest revision as of 18:55, 19 March 2025

TracCloud API

This section of our technical documentation covers TracCloud's v1 API support. For further assistance, reach out to us using the "Support" tab at the top of the page.

Sending Requests

Our API endpoint is: https://traccloud.go-redrock.com/CAMPUSCODE/app/webhook.php
Replace 'CAMPUSCODE' with your campus code, or replace traccloud.go-redrock.com/CAMPUSCODE with your custom URL if applicable.

For testing purposes, you can send the request from a browser's network tab like this.



That same request with curl looks like this. The rest of this article will use curl. Most of the examples will include line breaks for readability, it will work either way.


Updating Records (Action: update, store, create)



pass a parameter named "data" in the following format:

data={"action": "update", "APIKey": "YOUR_API_KEY", "KeyID": 1910,  "table": "Students", "Last_Name": "Halsteader"}

The response should be:

{"status":"success","message":"data Students record updated #1910","data":{"Sequence":1910}}

Example curl command.

curl -d 'data={
"action": "update",
"APIKey": "YOUR_API_KEY",
"KeyID": 1931,
"table": "Students",
"Last_Name": "Smith"
}' https://traccloud.go-redrock.com/demo/app/webhook.php

Available fields and their options:

  • action
update will update an existing record, if you try updating when the record does not exist, it will return an error.
store will update records, or create records if a record doesn't exist.
create will create the currently non-existent record. If you try creating when the KeyID already exists, it will return an error.

  • APIKey
Your API key.

  • KeyID
Provide the sequence number of the record being modified.

  • table
Provide the table of the record being modified (Students, Registrations, etc).

  • [field]
Provide the field you want to modify (e.g., Last_Name) as well as the value you want to set it to.


Retrieving Records (Action: query)



The next API action is “query”, which can be used to retrieve fields from records. Here's an example that finds 20 students who's ID is greater than 1.

curl -d 'data={
    "action": "query",
    "from": "students",
    "page": 1,
    "page_recs": 20,
    "APIKey": "YOUR_API_KEY",
    "fields": ["Sequence", "First_Name", "Last_Name"],
    "order": "first_name ASC",
	"query": {
		"fields": [{
            "field": "Sequence",
		    "value": "1",
		    "op": ">"
        }]
    }
}' https://traccloud.go-redrock.com/demo/app/webhook.php

This query will return the following.

{"status":"success","message":"data queried","data":
[{"Sequence":1901,"First_Name":"Jackson","Last_Name":"Gomez-Lopez"},
{"Sequence":1910,"First_Name":"Angi","Last_Name":"Halsteader"},
{"Sequence":1911,"First_Name":"Ou00edhare","Last_Name":"Wallace"},
{"Sequence":1912,"First_Name":"Joe","Last_Name":"BarraganIII"},
{"Sequence":1913,"First_Name":"Lori","Last_Name":"Train"},
{"Sequence":1914,"First_Name":"John","Last_Name":"Cunningham"},
{"Sequence":1915,"First_Name":"Jaime","Last_Name":"Tsosie"},
{"Sequence":1916,"First_Name":"David","Last_Name":"Perry"},
{"Sequence":1917,"First_Name":"Luis","Last_Name":"Frias"},
{"Sequence":1918,"First_Name":"Freida","Last_Name":"Miller"},
{"Sequence":1919,"First_Name":"Andre","Last_Name":"Davis"},
{"Sequence":1920,"First_Name":"Alyssa","Last_Name":"Gumeringer"},
{"Sequence":1921,"First_Name":"Nils","Last_Name":"Christianson"},
{"Sequence":1922,"First_Name":"Jeanne","Last_Name":"Patterson"},
{"Sequence":1923,"First_Name":"Rachelle","Last_Name":"Rodriguez"},
{"Sequence":1924,"First_Name":"Damian","Last_Name":"Garcia"},
{"Sequence":1926,"First_Name":"Brandi","Last_Name":"Clee"},
{"Sequence":1927,"First_Name":"Edward","Last_Name":"Ireland"},
{"Sequence":1928,"First_Name":"Nicole","Last_Name":"Love-Cleasby"},
{"Sequence":1929,"First_Name":"Liam","Last_Name":"Howlett"}]}

  • Action
Should be "Query", otherwise review the previous section of this article.

  • from
The table you wish to retrieve data from (Students, Visits, etc).

  • page
The page number to get records from, similar to pages on listings. This attribute allows you to write a program that continues hitting the server 1 page at a time getting the number of records in page_recs at a time. The programmer would pass 1 as page the first time, get the results and process, then pass 2 as page, etc, until the number of records is less than the amount in page_recs.

  • page_recs (Optional, seems to default to 20)
The quantity of records to return.

  • APIKey
Your API key.

  • fields
The fields you want to display from the records you're retrieving. Twig tags can be used. Center.Name, etc. Custom fields would be formatted like "Students.CustomData->>``$.cf_123``" with 123 being the sequence number of the custom field.

  • order
How data is sorted. Choose a field and sort ascending (ASC) or descending (DESC).

  • Query
  • Query type
Detailed further into this article.
  • field
Choose the field you want to search by.
  • value
The value you want to search by.
  • op (use | for "or")
= - Equals.
!= - Not.
> - Greater than.
< - Less than.
<= - Less than or equal to.
>= - Greater than or equal to.
LIKE - Similar to, use % as a wildcard.
NOT LIKE - Similar to, use % as a wildcard.

Query Options



The examples below only include the "Query" portion of the data for brevity. These can be copied into the example curl command from earlier in this section.

fields | Search for specific values, using additional operators if needed.

	"query": {
		"fields": [{
            "field": "ID",
		    "value": "1933",
		    "op": "="
        }]
    }

orfields | Search for records that match any of the listed criteria. This can include an unlimited number of fields.

    "query": {
        "orfields": [
            {
                "field": "First_Name",
                "value": "%",
                "op": "LIKE"
            },
            {
                "field": "Last_Name",
                "value": "%e%|%i%|%son",
                "op": "LIKE"
            },
            {
                "field": "Major",
                "value": "Biology",
                "op": "!="
            }
        ]
    }


andfields | Search for records that match all of the listed criteria. This can include an unlimited number of fields.

    "query": {
        "andfields": [
            {
                "field": "First_Name",
                "value": "Rob",
                "op": "="
            },
            {
                "field": "Last_Name",
                "value": "S%",
                "op": "LIKE"
            },
            {
                "field": "Major",
                "value": "Biology",
                "op": "="
            }
        ]
    }

or | Used to combine 2 (and only 2) instances of andfields/orfields. Records are returned if either criteria is met.

        "or": [
            {
                "andfields": [
                    {
                        "field": "Sequence",
                        "value": "1",
                        "op": ">"
                    },
                    {
                        "field": "Sequence",
                        "value": "1000000",
                        "op": "<"
                    }
                ]
            },
            {
                "orfields": [
                    {
                        "field": "First_Name",
                        "value": "%",
                        "op": "LIKE"
                    },
                    {
                        "field": "Last_Name",
                        "value": "%e%|%i%|%son",
                        "op": "LIKE"
                    }
                ]
            }
        ]
    }


and | Used to combine 2 (and only 2) instances of andfields/orfields. Records are returned if both criteria are met.

    "query": {
        "and": [
            {
                "andfields": [
                    {
                        "field": "Sequence",
                        "value": "1",
                        "op": ">"
                    },
                    {
                        "field": "Sequence",
                        "value": "1000000",
                        "op": "<"
                    }
                ]
            },
            {
                "orfields": [
                    {
                        "field": "TimeIn",
                        "value": "{{\"now\"|date_modify(\"-7 days\")|date(\"Y-m-d H:i:s\")}}",
                        "op": ">"
                    },
                    {
                        "field": "Last_Name",
                        "value": "%e%|%i%|%son",
                        "op": "LIKE"
                    }
                ]
            }
        ]
    }

TracCloud Table List

Click here to view a list of TracCloud tables and fields accessible via the API.