Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Options

Talking to Onshape's API

billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,014 PRO
edited June 2021 in General
@john_mcclary @kai_schmid

There's a fair amount of work involved with talking to Onshape. The good news, it's all modern technology, it's exciting, it's the future and it's worth learning.

1. Go here to get started: https://dev-portal.onshape.com/

2. Get the api-explorer working

3. Tackle permissions 

4.  api-support@onshape.com note that Onshape isn't a web development company although I have found they're support to be amazing. Using this forum is the best place for support, but you'll be figuring it out.



So the basics:

You can get your computer to talk to Onshape's servers fairly easy through a console. What's nice is that when you log into onshape, your computers logged in and permissions are easy. I'd still start with the api explorer and would skip this step. For this to work in the real world, people would have to download your code locally and run it. No one's going to do that. This isn't real.




This is what you want. This is a real website which requires you to control a server on the web. There's a billion youtube videos on how to set this up. Onshape is pushing Heroku because it's easy, I want to configure my server so I use digital ocean. Pick your own poison, I'd stay away from shared servers.


I'm not sure how much you know about programming the web. I find it interesting and fun. I'm currently using javascript, nginx, nodejs, mongo, redis & react and would recommend this approach.. Of course, next month things might be different. Welcome to the web.


There's a git repository with a ton of code to get started. Downloading a repository and expecting it to work isn't going to be effective. It's way to fragile for that.  https://github.com/onshape-public


I'm thinking success is like climbing stairs. Take small steps and eventually you'll get there.




Comments

  • Options
    alan_baljeualan_baljeu Member, User Group Leader Posts: 111 ✭✭
    yes, this is the process I was going through also.  I have succeeded with steps 1-3, albeit using C#.  My challenge with being a .net dev and having mostly JS samples.  I clearly need to learn this stuff just so I can follow the examples.
    Creating knowledge-driven design automation software, for molds, etc.
    www.virtualmold.com

  • Options
    billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,014 PRO
    edited June 2021
    @alan_baljeu I know nothing about the Microsoft ecosystem and I'm avoiding it on purpose. I supported SW for 20 years and I'm done with windows. I like linux and feel comfortable with it. A lot of my friends like windows so I don't know what the future is.

    I think your C# port will be more challenging than a my port from Heroku to ubuntu. 

    C# is just client side communication, right?

    Are you running nodejs on Azure? The calls you're making are language agnostic and you could just use a system command and curl the requests.  The language doesn't really matter. The headers that you're sending, they matter. Check them in the browser console and make sure they're correct.  You can see the communication streams and now is a good time to find them. You'll use them a lot eventually.

    Alan, when I was working permissions, I went through every line and console logged everything line by line.


  • Options
    billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,014 PRO
    edited June 2021
    2 ways to ask Onshape for data?

    There's 2 ways to access data from Onshape:

    The API store will want you to use this one. With Oauth, onshape will grant you permissions to use other people's data. In the setup, you set the amount of data you need and the data owner (user) has to approve this. https://github.com/onshape-public/app-gltf-viewer is using Oauth. I found it fairly easy to setup but it does require a dance between servers. If you want your app in the app store, you have to use Oauth.

    You don't have to register Oauth with the app store for it to work. Sorry Joe, it'll work without registering with the app store. If you build a bitch'n app, you'll want to register it with the app store.




    This is my preferred method. It just works and there's no dance between servers. Boom, you're in your account and no questions asked. The problem is you don't have direct access to other companies' data. This isn't good for the App store. My work around is to have someone share their data with me. Boom it's on my website. 

    https://github.com/onshape-public/apikey is a python program showing this method. Like most server side code, the language doesn't matter, you just copy the calls over to your language. Python & javascript are very similar when it comes to making requests.




Sign In or Register to comment.