All Projects → petrbroz → Forge Server Utils

petrbroz / Forge Server Utils

Tools for accessing Autodesk Forge APIs from modern Node.js apps.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Forge Server Utils

Api Generator
PHP-code generator for Laravel framework, with complete support of JSON-API data format
Stars: ✭ 244 (+960.87%)
Mutual labels:  api, generator
Laravel Api To Postman
Generate a Postman collection automatically from your Laravel API
Stars: ✭ 320 (+1291.3%)
Mutual labels:  api, generator
Genawaiter
Stackless generators on stable Rust.
Stars: ✭ 263 (+1043.48%)
Mutual labels:  async, generator
Apigcc
一个非侵入的api编译、收集、Rest文档生成工具。工具通过分析代码和注释,获取文档信息,生成RestDoc文档。
Stars: ✭ 198 (+760.87%)
Mutual labels:  api, generator
Full Stack
Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
Stars: ✭ 451 (+1860.87%)
Mutual labels:  api, generator
Fastapi Gino Arq Uvicorn
High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (w/ Redis and PostgreSQL).
Stars: ✭ 204 (+786.96%)
Mutual labels:  api, async
Example Scalping
A working example algorithm for scalping strategy trading multiple stocks concurrently using python asyncio
Stars: ✭ 267 (+1060.87%)
Mutual labels:  api, async
Api Client Generator
Angular REST API client generator from Swagger YAML or JSON file with camel case settigs
Stars: ✭ 92 (+300%)
Mutual labels:  api, generator
Verb
HEADS UP! Verb is going though a major transition, we've completely refactored everything from the ground up. If you're interested, please see the dev branch.
Stars: ✭ 442 (+1821.74%)
Mutual labels:  api, generator
Stone
The Official API Spec Language for Dropbox API V2
Stars: ✭ 371 (+1513.04%)
Mutual labels:  api, generator
Fastapi Crudrouter
A dynamic FastAPI router that automatically creates CRUD routes for your models
Stars: ✭ 159 (+591.3%)
Mutual labels:  api, async
Recoil
Asynchronous coroutines for PHP 7.
Stars: ✭ 765 (+3226.09%)
Mutual labels:  async, generator
Thispersondoesnotexist Js
Api for https://thispersondoesnotexist.com Generates an image of a person that does not exist in real life
Stars: ✭ 101 (+339.13%)
Mutual labels:  api, generator
Luna Commons
市场上许多界面和工具的集合,例如ftp,httpd等文件与工具操作,包括但不限于图像处理、人脸识别等的api。
Stars: ✭ 244 (+960.87%)
Mutual labels:  api, generator
Telebot.nim
Async client for Telegram Bot API in pure Nim [Bot API 5.1]
Stars: ✭ 93 (+304.35%)
Mutual labels:  api, async
Twitchio
TwitchIO - An Async Bot/API wrapper for Twitch made in Python.
Stars: ✭ 268 (+1065.22%)
Mutual labels:  api, async
Flowa
🔥Service level control flow for Node.js
Stars: ✭ 66 (+186.96%)
Mutual labels:  api, async
Routegen
Define your API and SPA routes in one place. Use them anywhere. Only 1.3kb.
Stars: ✭ 86 (+273.91%)
Mutual labels:  api, generator
Swagger Typescript Api
TypeScript API generator via Swagger scheme
Stars: ✭ 342 (+1386.96%)
Mutual labels:  api, generator
Groupco
PHP的服务化框架。适用于Api、Http Server、Rpc Server;帮助原生PHP项目转向微服务化。出色的性能与支持高并发的协程相结合
Stars: ✭ 473 (+1956.52%)
Mutual labels:  async, generator

forge-server-utils

Publish to NPM npm version node npm downloads platforms license

Unofficial tools for accessing Autodesk Forge APIs from Node.js applications and from browsers, built using TypeScript and modern language features like async/await or generators.

Autodesk Forge

Usage

Server Side

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:

// JavaScript
const { DataManagementClient } = require('forge-server-utils');
// TypeScript
import {
	DataManagementClient,
	IBucket,
	IObject,
	IResumableUploadRange,
	DataRetentionPolicy
} from 'forge-server-utils';

Authentication

If you need to generate 2-legged tokens manually, you can use the AuthenticationClient class:

const { AuthenticationClient } = require('forge-server-utils');
const { FORGE_CLIENT_ID, FORGE_CLIENT_SECRET } = process.env;
const auth = new AuthenticationClient(FORGE_CLIENT_ID, FORGE_CLIENT_SECRET);
const authentication = await auth.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('forge-server-utils');
const dm = new DataManagementClient({ client_id: '...', client_secret: '...' });
const bim360 = new BIM360Client({ token: '...' });

Data Management

const { DataManagementClient } = require('forge-server-utils');
const { FORGE_CLIENT_ID, FORGE_CLIENT_SECRET } = process.env;
const data = new DataManagementClient({ client_id: FORGE_CLIENT_ID, client_secret: FORGE_CLIENT_SECRET });

const buckets = await data.listBuckets();
console.log('Buckets', buckets.map(bucket => bucket.bucketKey).join(','));

const objects = await data.listObjects('foo-bucket');
console.log('Objects', objects.map(object => object.objectId).join(','));

Model Derivatives

const { ModelDerivativeClient } = require('forge-server-utils');
const { FORGE_CLIENT_ID, FORGE_CLIENT_SECRET } = process.env;
const derivatives = new ModelDerivativeClient({ client_id: FORGE_CLIENT_ID, client_secret: FORGE_CLIENT_SECRET });
const job = await derivatives.submitJob('<your-document-urn>', [{ type: 'svf', views: ['2d', '3d'] }]);
console.log('Job', job);

Design Automation

const { DesignAutomationClient } = require('forge-server-utils');
const { FORGE_CLIENT_ID, FORGE_CLIENT_SECRET } = process.env;
const client = new DesignAutomationClient({ client_id: FORGE_CLIENT_ID, client_secret: FORGE_CLIENT_SECRET });
const bundles = await client.listAppBundles();
console.log('App bundles', bundles);

Reality Capture

const { OutputFormat, RealityCaptureClient, SceneType } = require('forge-server-utils');
const { FORGE_CLIENT_ID, FORGE_CLIENT_SECRET } = process.env;
const recap = new RealityCaptureClient({ client_id: FORGE_CLIENT_ID, client_secret: FORGE_CLIENT_SECRET });
const options = {
    scenename: '<scene name>',
    scenetype: SceneType.Aerial,
    format: OutputFormat.RecapPhotoMesh,
    callback: '<callback>'
};
const photoscene = await recap.createPhotoScene(options);
console.log('Photoscene', photoscene);

Client Side (experimental)

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 Forge 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.

<script src="https://cdn.jsdelivr.net/npm/forge-server-utils/dist/browser/forge-server-utils.js"></script>
<script>
	const data = new forge.DataManagementClient({ token: '<your access token>' });
	const deriv = new forge.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/[email protected]/dist/browser/forge-server-utils.js.

Testing

export FORGE_CLIENT_ID=<your-client-id>
export FORGE_CLIENT_SECRET=<your-client-secret>
export FORGE_BUCKET=<your-test-bucket>
export FORGE_MODEL_URN=<testing-model-urn>
yarn run build # Transpile TypeScript into JavaScript
yarn test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].