Giter Site home page Giter Site logo

mouser-api's Introduction

Mouser Python API

License: MIT Python Versions PyPI Style | Tests

Setup

Requirements

  • Tested with Python 3.8+
  • Dependencies: click and requests packages

Mouser API Keys

Mouser provides two separate API keys:

  • one for the cart and orders
  • one for part searches.

Go to Mouser's API hub to request the keys.

To store the keys, two options:

  • create two environmental variables MOUSER_ORDER_API_KEY and MOUSER_PART_API_KEY with the respective values of each key
  • create a file named mouser_api_keys.yaml with the order API key on the first line and the part API key on a second line.

โš ๏ธ Using the mouser_api_keys.yaml file method, make sure to run mouser commands in the same folder!

The keys will be automatically loaded for each API request.

Install

Pip

pip install mouser

Manually

  1. Create virtual environment and activate it
  2. Run pip install -r requirements.txt

Poetry

  1. Install poetry package: pip install poetry
  2. Run poetry install

Run

Pip

mouser

Manually

python mouser_cli.py

Poetry

poetry run mouser

Usage

This command line tool reflects the usage from Mouser's API structure documented here.
The first positional argument is the category of the request: cart (for MouserCart), order, history (for MouserOrderHistory) and search (for SearchAPI). The second argument is the type of operation from the list of operations for each category.

Run mouser --help for more information about the usage.

Examples

The examples below assume this package was installed using Pip (for more options, see above)

Part Number Search

mouser search partnumber --number XXX

Export order to CSV

mouser order get --number XXX --export

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.