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: Find document by Part Number

Björn_RüeggBjörn_Rüegg Member Posts: 2
How can i find a document by a provided part number? How would an api call look like?
thanks for any information


  • matthew_mueller537matthew_mueller537 Member, Simulation EVP Posts: 18 EDU
    Hello. This Github hosted python notebook should give a general solution using API keys - search for a list of documents, then search for all parts in each document for a matching part number. https://colab.research.google.com/github/PTC-Education/PTC-API-Playground/blob/main/Search_Documents_for_Part_ID.ipynb
  • shawn_crockershawn_crocker Member, OS Professional Posts: 561 PRO
    I too am trying to figure out why my api calls only seem to be returning results of items that have the rawQuery string in there name.  I am struggling to get the search endpoint to include results from name and from part number.  In the onshape search, if you type in a part number, the search results include items that have the search term in there name and in there part number.  Do you know how to do this with the API?

    PS the link you provided was way over my head.
  • matthew_mueller537matthew_mueller537 Member, Simulation EVP Posts: 18 EDU
    @shawn_crocker sorry I missed this message. The getDocuments API isn't as granular as the native Onshape search and I'm not aware of any way to search for a document by part number directly through the API. The code I shared first defines a function to get all of the parts in a document, then gets a list of 20 document ID's for a user, then gets all of the parts from each of the documents and checks if the part number you're searching for matches any of the part numbers in the document. So you can do what you want algorithmically with the API, but it will take multiple API's strung together.
  • shawn_crockershawn_crocker Member, OS Professional Posts: 561 PRO
    Thank you.  I forgot I had left this question.  I have found a solution.  I the "rawQuery" parameter in the body of the request I use this syntax:


    Seems that this returns all documents that contain the text in "partNumber" in there name or part number meta data.  Doesn't seem to look inside of the description meta data which is strange.  In fact, I have found when looking at the native onshape search query in the browser URL, all the parameters shown there work when used in the rawQuery parameter.  Only difference is, everything is separated by a ":" and they need to be in pairs which is probably obvious.  I also use ":state:RELEASED:type:assembly" after my part number and search properly filters out for those parameters.
Sign In or Register to comment.