autodesk-forge-tools

0.2.0 • Public • Published

autodesk-forge-tools Build Status npm version

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

Readme

Keywords

Package Sidebar

Install

npm i autodesk-forge-tools

Weekly Downloads

7

Version

0.2.0

License

MIT

Unpacked Size

19.9 kB

Total Files

11

Last publish

Collaborators

  • petrbroz