Unofficial SDK for accessing Autodesk Platform Services from Node.js applications and from browsers, built using TypeScript and modern language features like async/await or generators.
The TypeScript implementation is transpiled into CommonJS JavaScript module with type definition files, so you can use it both in Node.js projects, and in TypeScript projects:
// JavaScriptconst{ DataManagementClient }=require('aps-sdk-node');// TypeScriptimport{DataManagementClient,IBucket,IObject,IResumableUploadRange,DataRetentionPolicy}from'aps-sdk-node';If you need to generate 2-legged tokens
manually, you can use the AuthenticationClient class:
const{ AuthenticationClient }=require('aps-sdk-node');const{APS_CLIENT_ID,APS_CLIENT_SECRET}=process.env;constauth=newAuthenticationClient(APS_CLIENT_ID,APS_CLIENT_SECRET);constauthentication=awaitauth.authenticate(['bucket:read','data:read']);console.log('2-legged token',authentication.access_token);Other API clients in this library are typically configured using a simple JavaScript object
containing either client_id and client_secret properties (for 2-legged authentication),
or a single token property (for authentication using a pre-generated access token):
const{ DataManagementClient, BIM360Client }=require('aps-sdk-node');constdm=newDataManagementClient({client_id: '...',client_secret: '...'});constbim360=newBIM360Client({token: '...'});const{ DataManagementClient }=require('aps-sdk-node');const{APS_CLIENT_ID,APS_CLIENT_SECRET}=process.env;constdata=newDataManagementClient({client_id: APS_CLIENT_ID,client_secret: APS_CLIENT_SECRET});constbuckets=awaitdata.listBuckets();console.log('Buckets',buckets.map(bucket=>bucket.bucketKey).join(','));constobjects=awaitdata.listObjects('foo-bucket');console.log('Objects',objects.map(object=>object.objectId).join(','));const{ ModelDerivativeClient }=require('aps-sdk-node');const{APS_CLIENT_ID,APS_CLIENT_SECRET}=process.env;constderivatives=newModelDerivativeClient({client_id: APS_CLIENT_ID,client_secret: APS_CLIENT_SECRET});constjob=awaitderivatives.submitJob('<your-document-urn>',[{type: 'svf',views: ['2d','3d']}]);console.log('Job',job);const{ DesignAutomationClient }=require('aps-sdk-node');const{APS_CLIENT_ID,APS_CLIENT_SECRET}=process.env;constclient=newDesignAutomationClient({client_id: APS_CLIENT_ID,client_secret: APS_CLIENT_SECRET});constbundles=awaitclient.listAppBundles();console.log('App bundles',bundles);const{ OutputFormat, RealityCaptureClient, SceneType }=require('aps-sdk-node');const{APS_CLIENT_ID,APS_CLIENT_SECRET}=process.env;constrecap=newRealityCaptureClient({client_id: APS_CLIENT_ID,client_secret: APS_CLIENT_SECRET});constoptions={scenename: '<scene name>',scenetype: SceneType.Aerial,format: OutputFormat.RecapPhotoMesh,callback: '<callback>'};constphotoscene=awaitrecap.createPhotoScene(options);console.log('Photoscene',photoscene);The transpiled output from TypeScript is also bundled using webpack, so you can use the same functionality in a browser. There is a caveat, unfortunately: at the moment it is not possible to request APS access tokens from the browser due to CORS limitations, so when creating instances of the various clients, instead of providing client ID and secret you will have to provide the token directly.
<scriptsrc="https://cdn.jsdelivr.net/npm/aps-sdk-node/dist/browser/aps-sdk-node.js"></script><script>constdata=newAPS.DataManagementClient({token: '<your access token>'});constderiv=newAPS.ModelDerivativeClient({token: '<your access token>'});data.listBuckets().then(buckets=>{console.log('Buckets',buckets);}).catch(err=>{console.error('Could not list buckets',err);});deriv.submitJob('<your document urn>',[{type: 'svf',views: ['2d','3d']}]).then(job=>{console.log('Translation job',job);}).catch(err=>{console.error('Could not start translation',err);});</script>Note that you can also request a specific version of the library from CDN by appending @<version>
to the npm package name, for example, https://cdn.jsdelivr.net/npm/aps-sdk-node@4.0.0/dist/browser/aps-sdk-node.js.
export APS_CLIENT_ID=<your-client-id>export APS_CLIENT_SECRET=<your-client-secret>export APS_BUCKET=<your-test-bucket>export APS_MODEL_URN=<testing-model-urn>
yarn run build # Transpile TypeScript into JavaScript
yarn test