-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyword search on Product #1
Comments
A quick question, but unfortunately opens a longer explanation: The short versionit is there but just depends on how you want to use it. The longer VersionThe lite version of the protocol wraps the swagger generated api, this can be seen in
All the digikey api's that have been implemented in https://github.com/auphofBSF/community-digikey-api-codegen-python-clients (Currently ProductInformation and OrderSupport ) will have all supported API calls in the generated python code. In this case the generated API is the relevant Digikey REST API doc for this keyword search is https://developer.digikey.com/products/product-information/partsearch/keywordsearch The documentation for the generated API python code can be viewed in the source once generated. If this is installed automatically it will be in the pip install locations """
Example of using finding documentation on python Digikey API calls
"""
import digikey_api_v3_lite as digiAPI
# SETUP the Digikey authentication see https://developer.digikey.com/documentation/organization#production
os.environ['DIGIKEY_CLIENT_ID'] = '<DIGIKEY_APPLICATION_ID>'
os.environ['DIGIKEY_CLIENT_SECRET'] = '<DIGIKEY_SECRET>'
os.environ['DIGIKEY_STORAGE_PATH'] = r'<PATH_TO_THE_TOKEN_CACHING_LOCATION>'
product_information_object = digiAPI.ProductInformation()
digikey_api_ProdInfo = product_information_object._api_instance
# list all methods of the generated_api that
print([method for method in dir(digikey_api_ProdInfo ) if '__' not in method])
# Should print the following
#['api_client', 'digi_reel_pricing', 'digi_reel_pricing_with_http_info', 'keyword_search', 'keyword_search_with_http_info', 'product_details', 'product_details_with_http_info', 'suggested_parts', 'suggested_parts_with_http_info']
# choose a particular method ie "keyword_search" and retrieve the generated doc's
print(digikey_api_ProdInfo.keyword_search.__doc__) I am taking the time to describe this as further implementations work needs to be done depending on specific use cases. I have just done some work recently on another API and have got myself more familiar with python decorators. I believe this Lite API can be a set of Decorators to automatically wrap the generated API's. This will reduce the amount of individual code to write and enable rapid integration of all the Digikey API's . I just notice there are now additional API's available [BOM, Taxonomy Search] Additionally python generated API doc set should be automatically generated by something like sphinx and be there to complement the Digikey JSON API documentation. I have raised this as an enhancement auphofBSF/community-digikey-api-codegen-python-clients#1 I am unable to do much more in the next week but may be able to look into some of this in the coming weeks. |
@lbrolliar asked in peeter123/digikey-api#3 (comment)
Quick question. Is there code for doing a keyword search to find the Digikey part number?
The text was updated successfully, but these errors were encountered: