Package: pyoctopart
A simple Python client frontend to the Octopart public REST API.For detailed API documentation, refer to theOctopart APIv2
documentationThis is a fork ofJoe
Baker’s work, and
this fork isincompatiblewith Python 2 distributions!You’ll find the sources of this project overhttps://github.com/guyzmo/pyoctopartUsageInstalljust do:python3 setup.py installand it’ll be available from your python REPL:% python3
>>> from pyoctopart.octopart import Octopart
>>> o = Octopart.api(apikey="yourapikey")when the lib will be considered stable enough, I’ll upload it topipy:% pip install pyoctopartDevelopif you just want to develop, you can do:% buildoutwhich will download dependencies and deploy a python command inbin/:% bin/python3
>>> from pyoctopart.octopart import Octopart
>>> o = Octopart.api(apikey="yourapikey")You can run regression tests using:% bin/testNotesAPI v3 conversionAt the time being only three methods have been switched to the new API:parts_search()
parts_match()
parts_get()And the tests will need to be updated. Those methods are the only one
being used in the`pyparts<https://github.com/guyzmo/pyparts>`_
project, though.method/argument syntax (for API v3)A number of arguments in the v3 API are using syntax that are not
compatible with python’s syntax, such asinclude[]=datasheets. To
enforce argument’s type checking and stay compatible with the API, the
arguments are converted as booleans replacing the assignment with an
underscore, making itinclude_datasheets, so for thePartmodel
you have the following matches:includesinclude_short_description     → include[]=short_description
include_datasheets            → include[]=datasheets
include_compliance_documents  → include[]=compliante_documents
include_descriptions          → include[]=descriptions
include_imagesets             → include[]=imagesets
include_specs                 → include[]=specs
include_category_uids         → include[]=category_uids
include_external_links        → include[]=external_links
include_reference_designs     → include[]=reference_designs
include_cad_models            → include[]=cad_modelsShowsshow_uid                      → show[]=uid
show_mpn                      → show[]=mpn
show_manufacturer             → show[]=manufacturer
show_brand                    → show[]=brand
show_octopart_url             → show[]=octopart_url
show_offers                   → show[]=offers
show_broker_listings          → show[]=broker_listings
show_short_description        → show[]=short_description
show_datasheets               → show[]=datasheets
show_compliance_documents     → show[]=compliante_documents
show_descriptions             → show[]=descriptions
show_imagesets                → show[]=imagesets
show_specs                    → show[]=specs
show_category_uids            → show[]=category_uids
show_external_links           → show[]=external_links
show_reference_designs        → show[]=reference_designs
show_cad_models               → show[]=cad_modelsHideshide_uid                      → hide[]=uid
hide_mpn                      → hide[]=mpn
hide_manufacturer             → hide[]=manufacturer
hide_brand                    → hide[]=brand
hide_octopart_url             → hide[]=octopart_url
hide_offers                   → hide[]=offers
hide_broker_listings          → hide[]=broker_listings
hide_short_description        → hide[]=short_description
hide_datasheets               → hide[]=datasheets
hide_compliance_documents     → hide[]=compliante_documents
hide_descriptions             → hide[]=descriptions
hide_imagesets                → hide[]=imagesets
hide_specs                    → hide[]=specs
hide_category_uids            → hide[]=category_uids
hide_external_links           → hide[]=external_links
hide_reference_designs        → hide[]=reference_designs
hide_cad_models               → hide[]=cad_modelsAs a reference, check theinclude/show/hide directives sections of the
manual.method/argument syntax (for API v2)There are a number of arguments in the Octopart API documentation which
contain periods in their names. When passing these arguments from
Python, substitute an underscore for any periods.Similarly, substitute underscores for backslashes in method names.For example:>>> o = Octopart()
>>> o.parts_get(1881614252472, optimize.hide_datasheets=True)
SyntaxError: keyword can't be an expression

Instead, pass the argument as:
>>> o.parts_get(1881614252472, optimize_hide_datasheets=True)The library will perform the translation internally.Roadmap[x] switch to python 3[x] create buildout build[x] use function annotations[o] switch to v3 API[ ] improve and fix testsAuthorsForked by BernardGuyzmoPratzOriginally authored by Joe BakerLicenseLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.