1.0.6 • Published 6 years ago

octopartjs v1.0.6

Weekly downloads
5
License
ISC
Repository
github
Last release
6 years ago

Octopart js

Nodejs library for Octopart API (V3) with callbacks

Powered by Octopart

const octopartjs = require('octopartjs');

octopartjs.apikey('API-KEY');

You can get your api key in the url: https://octopart.com/api/home

Endpoints

Based on the Octopart API reference (V3)

Brands

octopartjs.brands.uid()
octopartjs.brands.search()
octopartjs.brands.get_multi()

Categories

octopartjs.categories.uid()
octopartjs.categories.search()
octopartjs.categories.get_multi()

Parts

octopartjs.parts.uid()
octopartjs.parts.match()
octopartjs.parts.search()
octopartjs.parts.get_multi()

Sellers

octopartjs.seller.uid()
octopartjs.seller.search()
octopartjs.seller.get_multi()

Examples

Based on the Octopart API reference (V3)

Example with endpoint /brands/{uid}

var uid = '2239e3330e2df5fe';

octopartjs.brands.uid(uid, (err, body) =>{
   if(err){
     console.log(err);
   }else {
     console.log(body);
   }
});

Example with /brands/search

var args = {
   q: "Texas",
   start: 0,
   limit: 10
 };

octopartjs.brands.search(args, (err, body) =>{
  if(err){
    console.log(err);
    }else {
    console.log(body);
   }
});

Example with /brands/get_multi

var args = {
 uid: [
   "2239e3330e2df5fe",
   "c4f105fbe7591336"
 ]
};

octopartjs.brands.get_multi(args, (err, body) =>{
 if(err){
   console.log(err);
 }else {
   console.log(body);
 }
});

Example with /parts/match

var queries = [
  {'mpn': 'SN74S74N', 'reference': 'line1'},
  {'sku': '67K1122', 'reference': 'line2'},
  {'mpn_or_sku': 'SN74S74N', 'reference': 'line3'},
  {'mpn': 'SN74S74N', 'brand': 'Texas Instruments', 'reference': 'line4'}
];

var args = {
  queries: JSON.stringify(queries)
};

octopartjs.parts.match(args, (err, body) =>{
  if(err){
    console.log(err);
  }else {
    for(i in body){
      console.log(body);
    }
  }
});

Example with /parts/search

var args = {
  q: "lm350",
  start: 0,
  limit: 10
};

octopartjs.parts.search(args, (err, body) =>{
  if(err){
    console.log(err);
  }else{
    console.log(body);
  }
})
1.0.6

6 years ago

1.0.5

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago