autodesk-forge-tools
v0.2.0
Published
Tools for accessing Autodesk Forge APIs from Node.js apps.
Downloads
19
Readme
autodesk-forge-tools
Unofficial tools for accessing Autodesk Forge APIs from Node.js applications, using modern language features like async/await or generators.
Usage
Authentication
const { AuthenticationClient } = require('autodesk-forge-tools');
const auth = new AuthenticationClient(); // If no params, gets credentials from env. vars FORGE_CLIENT_ID and FORGE_CLIENT_SECRET
const authentication = await auth.authenticate(['bucket:read', 'data:read']);
console.log('2-legged Token', authentication.access_token);
Data Management
const { DataManagementClient, AuthenticationClient } = require('autodesk-forge-tools');
const data = new DataManagementClient(new AuthenticationClient());
// List buckets
for await (const buckets of await data.buckets()) {
console.log('Buckets', buckets.map(bucket => bucket.bucketKey).join(','));
}
// List objects in bucket
for await (const objects of data.objects('foo-bucket')) {
console.log('Objects', objects.map(object => object.objectId).join(','));
}
Model Derivatives
const { ModelDerivativeClient, AuthenticationClient } = require('autodesk-forge-tools');
const derivatives = new ModelDerivativeClient(new AuthenticationClient());
const job = await derivatives.submitJob('<your-document-urn>', [{ type: 'svf', views: ['2d', '3d'] }]);
console.log('Job', job);
Testing
export FORGE_CLIENT_ID=<your-client-id>
export FORGE_CLIENT_SECRET=<your-client-secret>
export FORGE_BUCKET=<your-test-bucket>
npm test