GithubHelp home page GithubHelp logo

onshape_getting-started_server's Introduction

This series of sample apps illustrate the use of API keys to call Onshape APIs with Node.js. The following apps are available:

massByMaterial expensiveDoNothing uploadBlob getDocuments exportStl

To use them, you must have node and npm installed on your computer, and run npm install on the command line in this directory to install the dependencies. Run the app with node <app> in this directory. Try node <app> -u or node <app> --usage to print a usage message specifying the parameters.

You must also copy config/apikeyexample.js to a new file called apikey.js inside the config directory; build an API key (with at least the relevant permissions) through the Developer Portal, and add these credentials to it. Make sure that the API key corresponds to the stack against which you are running the app -- for most users it should just be cad.onshape.com.

massByMaterial

This massByMaterial.js sample app tallies the total weight of each material used in a given part studio element. It demonstrates a generic GET request. (Requires OAuth2Read)

Usage:

This app will tally the total weight of each material in a given part studio.
Usage: node massByMaterial.js -d <documentId> -[wvm] <wvmId> -e <elementId>
(wvmId should be a workspaceId (-w), versionId (-v), or microversionId (-m), depending on the given value of [wvm])

To get a meaningful result, you'll also need a part studio with parts that have been assigned some materials, of course!

expensiveDoNothing

This expensiveDoNothing.js sample app creates an element then deletes it, which provides no potential benefit to the user, but at least it does so using API keys. It demonstrates generic POST and DELETE requests. (Requires OAuth2Write, OAuth2Delete)

Usage:

This app will create an element then delete it, resulting in nothing particularly helpful.
Usage: node expensiveDoNothing.js -d <documentId> -w <workspaceId>

uploadBlob

This uploadBlob.js sample app creates a new blob element from a given file. It demonstrates a multi-part file upload. (Requires OAuth2Write)

Usage:

This app will upload a given file to a new blob element.
Usage: node uploadBlob.js -d <documentId> -w <workspaceId> -f <filepath> -t <MIME type>
An example file is provided at ./example/blobexample.txt, with MIME type text/plain.

getDocuments

This getDocuments.js sample app simply gets a list of documents with given query parameters. It demonstrates GET requests. (Requires OAuth2Read)

Usage:

This app will get documents available to the user with the specified query params.
Usage: node getDocuments.js [--query <query>] [--filter <filter>] [--owner <owner>] [--ownerType <ownerType>] [--sortColumn <sortColumn>] [--sortOrder <sortOrder>] [--offset <offset>] [--limit <limit>]
See API documentation for query parameters.

exportStl

This exportStl.js sample app exports a given part studio as STL and helpfully prints it to the console. It demonstrates GET requests resulting in 307 redirects. (Requires OAuth2Read)

Usage:

This app will export a part studio as STL and print the STL file to the console.
Usage: node exportStl.js -d <documentId> -w <workspaceId> -e <workspaceId>

node exportStl.js -d 5c5d8d0d2ba495668d8ed088 -w 2dc95bee6a868fc7fa19a51f -e 2a47e3f569c9244f14ab390b

onshape_getting-started_server's People

Contributors

billschnoebelen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.