cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How Thingworx Get API works ?

Lo_ry96
7-Bedrock

How Thingworx Get API works ?

Hello, 

 

i'm using Thingworx at my work place and i'm trying to understand how Thingworx API works. Is Data requested from the Database? How the data flow works , for a GET request for example ? 

 

Many thanks 

6 REPLIES 6
Surya_Tiwari
15-Moonstone
(To:Lo_ry96)

Hi @Lo_ry96  Look at the below article, and let us know if you have any doubts.

https://www.ptc.com/en/support/article/CS328166

hi, thanks for the information provided. Still, it's not very clear how data flow works once a get request is made using API. Can elaborate on that please? 

BR

VladimirRosu
19-Tanzanite
(To:Lo_ry96)

Considering that there are hundreds of API (if we're looking at the Snippets themselves, exposed as APIs) it's impossible to describe how each works in detail, or the data flow for this matter.

What happens however, at its core, is that the logic behind each API call is basically a combination of local logic executed at the level of the instance, in Java, and database calls (which will happen in any of the databases ThingWorx is using, like PostgreSQL, MSSQL, InfluxDB etc).

It's not mandatory that both will happen - it all depends on that specific API logic. For example: creating an infotable entry based on a Datashape will issue NO call to the database, but executing a QueryPropertyHistory will issue a call to the database.

Generally speaking, all the API calls that "generally" read "stuff" (not including historical data or table data) do not result in a call to the database, since ThingWorx loads the model in-memory.

Anything that will "update" or "write" data (create a Thing, property) will result in a write to the database (to persist the change).

What I wrote above is extremely general in nature - many exceptions exist.

 

What exactly would you want to achieve in the platform? If you would be able to share some details we can certainly advise on what's the best way to do that.

 

Hi, Thanks for the reply. My final goal is to expose data from Thingworx , push it into influxDB and then Grafana for vizualisation. The thing is as a start i don't want to break donw Thingworx current architecture (Kepware, Thingworx server, MSSQL DB..). In a further step maybe we will consider getting data directly from Kepserver (Thingworx applications are not seen to bring added value for end users so the idea is to switch to Grafana but that won't happen over night..). As a start get data from thingworx API , push it to InfluxDB then Grafana. 

 

I hope i was clear. Let me know what you think about the idea? and what best architetcure would you advise ? 

 

Many thanks 

 

BR 

VladimirRosu
19-Tanzanite
(To:Lo_ry96)

Thanks @Lo_ry96 ,

Looking at your reply, there's one immediate thing that's apparent: if you want to switch to Grafana, first define an use-case with proper value assessment, then work on the technicalities (how do I get data from ThingWorx). Otherwise, if the Grafana dashboards you intend to build do not bring value, you'll end up in the same situation. I know Grafana's nice visualization capabilities, but that is all to it - it's not a tool to build complete custom applications (not just graphs) that are tailored for your specific situation. We see this situation when the "pains" (better said: areas of improvement) a customer has were not the input for a ThingWorx application OR the business users were involved way later in the design process.

 

Going to the question you asked: What kind of data you want to get outside of ThingWorx? Can you go in the details, as much as possible in this forum format? There are different APIs you'd use. One thing is guaranteed: whatever data needed you can get it out of ThingWorx, as by our nature we're very open in this aspect.

 

Hi @VladimirRosu , many thanks for your quick response. 

 

Exactly as you mentioned , the business was not earlier involved in the design of applications. the situation is currently no one uses these applications in our company as the mashups are not "sexy" and pretty static (updating data takes forever). So from here came the idea to suggest them Grafana dashboard with easy access and more interesting visuals  where we would display information about all our machines in same dashboard.

Data will be the metrics measured with sensors at machije level and collected with kepware etc.. 

 

About requirements: 

  • collect data point each 500ms-1s max 
  • Automate the process of data request and ingestion to the InfluxDB
  • As of now I tested "properties" end point : https://thingworxplatform/Thingworx/Things/Machine_A/Properties and managed to fetch needed data from json
  • Next step is to work on pushing this data to InfluxDB and automate the whole process

Hope it's more clear now. 

 

Any recommandations / ideas is appreciated. 

 

BR 

 

 

Top Tags