Skip to main content

pyoctopart

A simple Python client frontend to the Octopart public REST API.

For detailed API documentation, refer to the Octopart APIv2 documentation

This is a fork of Joe Baker’s work, and this fork is incompatible with Python 2 distributions!

You’ll find the sources of this project over https://github.com/guyzmo/pyoctopart

Usage

Install

just do:

python3 setup.py install

and 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 to pipy:

% pip install pyoctopart

Develop

if you just want to develop, you can do:

% buildout

which will download dependencies and deploy a python command in bin/:

% bin/python3
>>> from pyoctopart.octopart import Octopart
>>> o = Octopart.api(apikey="yourapikey")

You can run regression tests using:

% bin/test

Notes

API v3 conversion

At 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 as include[]=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 it include_datasheets, so for the Part model you have the following matches:

includes

include_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_models

Shows

show_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_models

Hides

hide_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_models

As a reference, check the include/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 tests

Authors

  • Forked by Bernard Guyzmo Pratz

  • Originally authored by Joe Baker

License

Licensed 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.

Metadata

Release files for pyoctopart 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pyoctopart 0.6.3
File Interpreter ABI Platform Actions
pyoctopart-0.6.3-py3.5.egg Legacy Egg format - - Details for pyoctopart-0.6.3-py3.5.egg

Release files / pyoctopart-0.6.3-py3.5.egg

Download URL pyoctopart-0.6.3-py3.5.egg
Size 24.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
b4d689f9451e942cded964cf43282da5d5437856263a84bfa5d2ff748682975d
BLAKE2b-256 checksum
How to use checksums
3cad1d0d6a7edff0664c808e274e2c672017a7f5c49b02f68395f2f3e6cd1a8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyoctopart 0.6.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.6.3 This release

1 release file No provenance

0.6.2

0.6.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page