How to use the Machine Attributes API
  • 05 Aug 2024
  • 3 Minutes to read
  • Contributors

How to use the Machine Attributes API


Article summary

How to use the Machine Attributes API

Create a Tulip Machine using data from Node-RED, Python or other services.

NOTE

Advanced Article - assumes previous experience with REST APIs.Click here to view our Machines API documentation.

Summary

The Machine Attributes API allows you to send data to a specific attribute of a Machine via a RESTful API using the /attributes/report endpoint. This enables many flexible options to integrate with Tulip from Node-RED, Python or other languages and services.

Setting up the Machine API

Note: If you have a Tulip Table API already set up, you may use that API Key and Secret

  1. Navigate to your Settings > API Tokens
  2. Click Create API Token in the upper right-hand corner of your screen
  3. Name your API Token, and select attributes:write for it's scope:

  1. A modal with your API Key, Secret and Auth Header will appear. Please save this information as it can not be accessed again!

Congratulations - you've officially set up your Machine API!

Setting up a new Machine

Once you've set up your Machine API, a new Machine Data Source will appear on your instance. To view this datasource click Shop Floor > Machines, and navigate to Machine Data Sources:

You will have to create a new machine linked to this data source. To create a new machine navigate to Machine Library, and click Create Machine.

The following modal will appear:

  1. Machine Name (Required): Name you machine
  2. Machine Data Source (Required): Select Tulip API
  3. Station (Optional)
  4. Type (Required): If no Type is available create a type first, in this example the type created is named default

Now that your machine is created, you'll need to add an attribute. Click on Edit on the top right of your screen. Then click on the + button in the top right of your screen:

Since no Machine Attributes have been created yet press the Machine Type in blue, in this case its Default.

This will take you to the Machine Type associated with the machine. Press the Edit button in the top right corner of your screen.

Then Press the + button next to Machine Attributes in the bottom left corner.

Now press + Create Machine Attribute in the bottom right corner

For this example, we will be creating a Counter attribute of type Integer.

Once your attribute is created, click the Counter Attribute in the list of Machine Attributes and then press the save in the top right corner

Proceed back to your machine page.

Now that your Machine Attribute is created, you can add it to your Machine. Press the Edit button in the top right corner. Then click on the + button in the top right corner and select the Counter attribute you've just created:

Please click Save in the upper right corner.

Your Tulip Instance is now set up with the Machine API, a Machine, and a Machine Attribute - now you can send data to a Tulip Machine from anywhere!

From here you can see the attributeId and machineID for the Counter attribute. This information can be copied by clicking the icon and will be used in the body of the http request.

To do this you will need to be familiar with REST APIs. Full documentation on how to use the /attributes/report endpoint, including the query parameters and body format, can be found at your-company.tulip.co/apidocs or by following the link on the API Token page...

... and in the docs there is a section for Machine Monitoring

Further Reading

Check out this article if you want to take the API further and see how it can be used with Edge MC and Node-RED!


Was this article helpful?