Code Snippets
This page contains collection of code snippets to demonstrate use of the API to achieve common workflows. The snippets are written using JavaScript and can be executed using the Node.js runtime. Each snippet can be executed independently.
The complete repository can be found here. In addition to JavaScript there is also Python version available.
Configuration
Before running the snippet it is necesary to configure Autodesk Tandem to allow service access.
- Create a new application using APS Portal.
- Open your test facility in Autodesk Tandem.
- Navigate to Users then select Service.
- Enter the Client ID of an application from step 1 above.
- Make sure to specify the correct permissions (Edit permission is needed to run all snippets).
- Click on Add. After this, the application can use a 2-legged authentication token to access the facility using the API.
Check out Authentication for more details regarding authentication.
Usage
To run the snippet use following steps:
- Open the source folder using your code editor.
- Locate the example you want to run and open it.
- At the top of the file there is block with global variables. Replace those variables according to your environment:
// update values below according to your environment const APS_CLIENT_ID = 'YOUR_CLIENT_ID'; const APS_CLIENT_SECRET = 'YOUR_CLIENT_SECRET'; const FACILITY_URN = 'YOUR_FACILITY_URN';
Most of the examples are self-contained. Reusable code is located under common folder.
Snippets
The examples are organized into multiple folders based on topic:
- assets - asset related examples
- classification - classification related examples
- documents - document related examples
- elements - generic examples related to elements
- facility - facility related examples
- groups - group related examples
- history - history related examples
- streams - streams related examples
- systems - system related examples
- views - view related examples