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.

API | Enumerate Revisions

Martyn_GierlickiMartyn_Gierlicki Member, csevp Posts: 3 PRO

Hi all - 

I am starting to delve into the API development portal and the glasswork API explorer. 

Concentrating on the "Enumerate all revisions created in a company" (
https://cad.onshape.com/glassworks/explorer/#/Revision/enumerateRevisions) the API call limit is limited to 100 records. Our company enterprise has more than 100 parts/assemblies/drawings with a revision. 

Is there a way to pull all the records from the enterprise? Not limiting it to 100?

We typically use Excel PowerQuery to report on and manipulate data from all manner of places (SQL databases, web, spreadsheets etc) so it would be advantageous to undertake a similar process with "Enumerate all revisions created in a company" to have a live report of all released parts/assemblies/drawings in our company enterprise. 

Any help/guidance would be greatly appreciated.

TIA

Best Answer

  • caden_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    Answer ✓
    Its generally bad practice to have an endpoint that could potentially return an enormous result. A company with enough revisions will have the endpoint timeout, or have users requesting way more data than they need.

    While the api call is limited to 100, you can still get all of the records. It just requires doing multiple calls. If you look at the example response, there is a field "next" and "previous". The "next" field will provide a URL formatted for the next 100 entries. All  you need to do is continually call the "next" url, add the results to the previous results, and wait for the "next" url to be null.

Answers

  • caden_armstrong2caden_armstrong2 Member, User Group Leader Posts: 127 ✭✭✭
    Answer ✓
    Its generally bad practice to have an endpoint that could potentially return an enormous result. A company with enough revisions will have the endpoint timeout, or have users requesting way more data than they need.

    While the api call is limited to 100, you can still get all of the records. It just requires doing multiple calls. If you look at the example response, there is a field "next" and "previous". The "next" field will provide a URL formatted for the next 100 entries. All  you need to do is continually call the "next" url, add the results to the previous results, and wait for the "next" url to be null.
  • raj_Onshaperaj_Onshape Onshape Employees Posts: 110
    https://github.com/onshape-public/onshape-ts-client#readme

    has a sample that shows how to use this api to create a spreadsheet of all revisions created in your company
  • Martyn_GierlickiMartyn_Gierlicki Member, csevp Posts: 3 PRO

    @caden_armstrong - thanks for the reply. In principle, I understand. My API call request knowledge is beginner at best. 

    Using the 
    https://cad.onshape.com/glassworks/explorer/#/Revision/enumerateRevisions complier by adding our enterprise ID I can create a URL for the request, obviously limited to max 100 results. I am then using this "Request URL" within PowerQuery to return the "live" results into Excel. The intent would then be to compare this information to our sales/purchasing SQL database to ensure that revisions are at parity and to identify any irregularities.  

     Question: Can I build the “next” request into the “Request URL” or am I going to have to API call via a different means in Excel’s PowerQuery? 

Sign In or Register to comment.