Exporting your usage data, the easy way with Forge
by Bastien Mazeran, Designated Support Specialist, at Autodesk on December 18, 2018
You have just read Understanding your Autodesk token consumption with Forge and wanted to learn more about the export capability of the new Forge TokenFlex Usage Data API.
The Token Flex Usage Data API is separated into three categories:
- Metadata: Use these endpoints to get contract details.
- Usage: Use these endpoints to construct ad-hoc analytical queries of usage data.
- Export: Use these endpoints to receive a bulk-export of usage data in CSV file format.
In this article, we will discuss the export endpoints and show you a simple Python script that you can use today to integrate with the TokenFlex Usage Data API and quickly generate a bulk export of your Autodesk usage data in CSV file format.
If you would like to see a demo of the script before continuing, please watch this video:
If you like what you’ve watched, you can proceed to download the Python scripts from this GitHub repository to get started.
Like all Forge APIs, the TokenFlex Usage Data API is REST based. This means that all we need to do is call the REST endpoints to interact with the API. With Python, we chose the Requests library to call the /tokenflex/v1/export endpoints to initiate the bulk export of usage data.
Security is always paramount in the Forge Platform. To fully secure your data, this API requires the use of 3-legged oAuth2 tokens. This means that the data returned is always in the context of a contract manager or software coordinator user, none else can see your usage data.
The diagram below explains the flow of the scripts in more details:
To learn more about the details of the setup, please refer to the GitHub README.
The report script loops through each contract and downloads the usage data. A new CSV file is downloaded per contract to your script directory.
Here is the final result after viewing it in Microsoft Excel:
You have learned a new way to bulk export your Autodesk usage data to a CSV file, which you can now import into your favorite BI solution, such as Microsoft PowerBI.
You could be looking next at modifying the report script to combine desktop and cloud products data, or data within a specific date range, including spanning active and expired contracts. Last but not least, you could learn how to run your custom reports on a schedule by integrating with the schedule endpoints.
You have now access to an API that lets you create and schedule your own custom usage reports. Happy Forging!
Additional technical resources: