API-Octopart

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

# NAME

API::Octopart - Simple inteface for querying part status across vendors at octopart.com.

# SYNOPSIS

        my $o = API::Octopart->new(
                token => 'abcdefg-your-octopart-token-here',
                cache => "$ENV{HOME}/.octopart/cache",
                include_specs => 1,
                ua_debug => 1,
                query_limit => 10
                );

        # Query part stock:
        my %opts = (
                currency => 'USD',
                max_moq => 100,
                min_qty => 10,
                max_price => 4,
                #mfg => 'Murata',
        );
        print Dumper $o->get_part_stock_detail('RC0805FR-0710KL', %opts);
        print Dumper $o->get_part_stock_detail('GQM1555C2DR90BB01D', %opts);

# METHODS

- $o = API::Octopart->new(%opts) - Returns new Octopart object.

    Object Options (%opt):

    - token => 'abcdefg-your-octopart-token-here',

        This is your Octopart API token.  You could do something like this to read the token from a file:

                token => (sub { my $t = `cat ~/.octopart/token`; chomp $t; return $t})->(),

    - include\_specs => 1

        If you have a PRO account then you can include product specs:

    - cache => "$ENV{HOME}/.octopart/cache"

        An optional (but recommended) cache directory to minimize requests to Octopart:

    - cache\_age => 3

        The cache age (in days) before re-querying octopart.  Defaults to 30 days.

    - query\_limit: die if too many API requests are made.

        Defaults to no limit.  I exhasted 20,000 queries very quickly due to a bug!
        This might help with that, set to a reasonable limit while testing.

    - ua\_debug => 1

        User Agent debugging.  This is very verbose and provides API communication details.

    - json\_debug => 1

        JSON response debugging.  This is very verbose and dumps the Octopart response
        in JSON.

- $o->has\_stock($part, %opts) - Returns the number of items in stock

    $part: The model number of the part

    %opts: Optional filters. No defaults are specified, it will return all unless limited.

    - min\_qty => <n>    - Minimum stock quantity, per seller.

        If a sellerhas fewer than min\_qty parts in stock then the seller will be excluded.

    - max\_moq => <n>    - Maximum "minimum order quantity"

        This is the max MOQ you will accept as being in
        stock.  For example, a 5000-part reel might be more
        than you want for prototyping so set this to 10 or
        100.

    - seller => <regex> - Seller's name (regular expression)

        This is a regular expression so something like
        'Mouser|Digi-key' is valid.



( run in 1.417 second using v1.01-cache-2.11-cpan-39bf76dae61 )