API-Octopart
view release on metacpan or search on metacpan
rebuild-manifest.sh
redist.sh
remake.sh
repod.sh
t/00-load.t
t/manifest.t
t/pod-coverage.t
t/pod.t
xt/boilerplate.t
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Data::Dumper" : "2.167",
"Digest::MD5" : "2.55",
"JSON" : "2.97001",
"LWP::Protocol::https" : "6.07",
"LWP::UserAgent" : "6.34",
"perl" : "5.010"
}
},
"test" : {
"requires" : {
"Test::More" : "0"
}
}
"bugtracker" : {
"web" : "https://github.com/KJ7LNW/perl-API-Octopart/issues"
},
"homepage" : "https://github.com/KJ7LNW/perl-API-Octopart",
"repository" : {
"type" : "git",
"web" : "https://github.com/KJ7LNW/perl-API-Octopart.git"
}
},
"version" : 1.003,
"x_serialization_backend" : "JSON::PP version 2.97001"
}
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: API-Octopart
no_index:
directory:
- t
- inc
requires:
Data::Dumper: '2.167'
Digest::MD5: '2.55'
JSON: '2.97001'
LWP::Protocol::https: '6.07'
LWP::UserAgent: '6.34'
perl: '5.010'
resources:
bugtracker: https://github.com/KJ7LNW/perl-API-Octopart/issues
homepage: https://github.com/KJ7LNW/perl-API-Octopart
repository: https://github.com/KJ7LNW/perl-API-Octopart.git
version: 1.003
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
Makefile.PL view on Meta::CPAN
#x_IRC => 'irc://irc.perl.org/#maybe-someday?',
},
},
TEST_REQUIRES => {
'Test::More' => '0',
},
PREREQ_PM => {
'LWP::Protocol::https' => '0',
'Data::Dumper' => '2.167',
'Digest::MD5' => '2.55',
'JSON' => '2.97001',
'LWP::Protocol::https' => '6.07',
'LWP::UserAgent' => '6.34',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'API-Octopart-*' },
);
# Compatibility with old versions of ExtUtils::MakeMaker
unless (eval { ExtUtils::MakeMaker->VERSION('6.64'); 1 }) {
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.
'voltagerating_dc_' => '150V',
'width' => '1.25mm',
...
}
},
...
]
- $o->octo\_query($q) - Queries the Octopart API
Return the JSON response structure as a perl ARRAY/HASH given a query meeting Octopart's
API specification.
- $o->octo\_query\_count() - Return the number of API calls so far.
- $o->query\_part\_detail($part)
Return the JSON response structure as a perl ARRAY/HASH given a part search term
shown as "$part". This function calls $o->octo\_query() with a query from Octopart's
"Basic Example" so you can easily lookup a specific part number. The has\_stock()
and get\_part\_stock\_detail() methods use this query internally.
# SEE ALSO
[https://octopart.com/](https://octopart.com/), [https://octopart.com/api](https://octopart.com/api)
# ATTRIBUTION
'JSON::PP' => '2.97001',
'JSON::PP::Boolean' => '2.97001',
'LWP::Authen::Basic' => '6.34',
'LWP::Authen::Digest' => '6.34',
'LWP::Authen::Ntlm' => '6.34',
'LWP::Protocol::cpan' => '6.34',
'LWP::Protocol::data' => '6.34',
'LWP::Protocol::file' => '6.34',
'LWP::Protocol::ftp' => '6.34',
'LWP::Protocol::gopher' => '6.34',
'LWP::Protocol::http' => '6.34',
'LWP::Protocol::loopback' => '6.34',
lib/API/Octopart.pm view on Meta::CPAN
# respective owners and no grant or license is provided thereof.
#
package API::Octopart;
$VERSION = 1.003;
use 5.010;
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use Digest::MD5 qw(md5_hex);
use Data::Dumper;
=head1 NAME
API::Octopart - Simple inteface for querying part status across vendors at octopart.com.
=head1 SYNOPSIS
lib/API/Octopart.pm view on Meta::CPAN
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.
=item * ua_debug => 1
User Agent debugging. This is very verbose and provides API communication details.
=item * json_debug => 1
JSON response debugging. This is very verbose and dumps the Octopart response
in JSON.
=back
=cut
our %valid_opts = map { $_ => 1 } qw/token include_specs cache cache_age ua_debug query_limit json_debug/;
sub new
{
my ($class, %args) = @_;
lib/API/Octopart.pm view on Meta::CPAN
my ($self, $part, %opts) = @_;
my $p = $self->query_part_detail($part);
return $self->_parse_part_stock($p, %opts);
}
=item * $o->octo_query($q) - Queries the Octopart API
Return the JSON response structure as a perl ARRAY/HASH given a query meeting Octopart's
API specification.
=cut
sub octo_query
{
my ($self, $q) = @_;
my $part = shift;
lib/API/Octopart.pm view on Meta::CPAN
=cut
sub octo_query_count
{
my $self = shift;
return $self->{api_queries};
}
=item * $o->query_part_detail($part)
Return the JSON response structure as a perl ARRAY/HASH given a part search term
shown as "$part". This function calls $o->octo_query() with a query from Octopart's
"Basic Example" so you can easily lookup a specific part number. The has_stock()
and get_part_stock_detail() methods use this query internally.
=cut
sub query_part_detail
{
my ($self, $part) = @_;
#!/bin/sh
set -e
[ -e Makefile ] && make distclean || true
perl Makefile.PL
find lib -name '*.pm' | xargs scandeps.pl -R | \
perl -MJSON -le '
undef $/;
%d=eval(<STDIN>);
%i=do("./ignoredeps");
$j=JSON::from_json(`cat MYMETA.json`);
foreach (sort keys(%d)) {
$missing .= "'\''$_'\'' => '\''0'\'',\t# $d{$_}\n" if !defined($j->{prereqs}{runtime}{requires}{$_}) && !defined($i{$_})
}
if ($missing) {
print "\nMissing deps:\n(\n$missing)\n" ;
exit 1
}
'
( run in 1.108 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )