Octopart
API

REST API Reference (V3)


The Octopart API is a REST API that's easy to query in any programming environment. The following is the full documentation for the REST API including schemas for the response and query objects as well as documentation for the REST endpoints. If you have any questions please chat with us at our Developer Forum or send us an email (api@octopart.com).


Object Schemas

The following are the schemas for the data objects returned by the API (e.g. brands, manufacturers, parts, offers, sellers):

Asset schema:

Property Description Example Empty Value
url The url of the asset "http://octopart.com/XXXX" n/a
mimetype The asset's mimetype "application/pdf" n/a
metadata Asset metadata (depends on mimetype) See notes: Asset.metadata n/a

Attribution schema:

Property Description Example Empty Value
sources List of source objects [<Source object>] []
first_acquired ISO 8601 formatted time when data was acquired "2016-12-09T19:49:00Z" null

Brand schema:

Property Description Example Empty Value
uid 64-bit unique identifier "3c8cfd861098eb4b" n/a
name The brand's display name "Texas Instruments" n/a
homepage_url The brand's homepage url "http://example.com" null

BrokerListing schema:

Property Description Example Empty Value
seller Object representing the seller <Seller object> n/a
listing_url URL for listing "http://octopart.com/redirect/XXXX" null
octopart_rfq_url URL for generating RFQ through Octopart "http://octopart.com/rfq/XXXX" null

CADModel schema (inherits from Asset)

Property Description Example Empty Value
url The url of the asset "http://octopart.com/XXXX" n/a
mimetype The asset's mimetype "application/pdf" n/a
metadata Asset metadata (depends on mimetype) See notes: Asset.metadata n/a
attribution Information about the data source <Attribution object> n/a

Category schema:

Property Description Example Empty Value
uid 64-bit unique identifier "b62d7b27870d6dea" n/a
name The category node's name "Capacitors" n/a
parent_uid 64-bit unique identifier of parent category node "ab34663e9a1770f3" null
children_uids JSON array of children uid's ["d9ed14e7e8cc022a", "41398c33764e9afe"] []
ancestor_uids JSON array of ancestor uid's with parent ordered last ["55da98d064fd8e1d", "ab34663e9a1770f3"] []
ancestor_names JSON array of ancestor node names ["Electronic Parts", "Passive Components"] []
num_parts Number of parts categorized in category node 1000000 null
imagesets Hidden by default (See Include Directives) [<ImageSet object>] []

ComplianceDocument schema (inherits from Asset)

Property Description Example Empty Value
url The url of the asset "http://octopart.com/XXXX" n/a
mimetype The asset's mimetype "application/pdf" n/a
metadata Asset metadata (depends on mimetype) See notes: Asset.metadata n/a
subtypes List of document classifications See notes: ComplianceDocument.subtypes []
attribution Information about the data source <Attribution object> n/a

Datasheet schema (inherits from Asset)

Property Description Example Empty Value
url The url of the asset "http://octopart.com/XXXX" n/a
mimetype The asset's mimetype "application/pdf" n/a
metadata Asset metadata (depends on mimetype) See notes: Asset.metadata n/a
attribution Information about the data source <Attribution object> n/a

Description schema:

Property Description Example Empty Value
value The value of the description "The TLC274AID is a precision ..." n/a
attribution Information about the data source <Attribution object> n/a

ExternalLinks schema:

Property Description Example Empty Value
product_url The url of the Manufacturer's part detail page "http://example.com/XXXX" null
freesample_url The url of the Manufacturer's free sample page "http://example.com/XXXX" null
evalkit_url The url of the Manufacturer's eval kit page "http://example.com/XXXX" null

ImageSet schema:

Property Description Example Empty Value
swatch_image Asset object representing the image <Asset object> null
small_image Asset object representing the image <Asset object> null
medium_image Asset object representing the image <Asset object> null
large_image Asset object representing the image <Asset object> null
attribution Information about the data source <Attribution object> n/a

Manufacturer schema:

Property Description Example Empty Value
uid 64-bit unique identifier "a6e363e98ef77524" n/a
name The manufacturer's display name "Texas Instruments Inc." n/a
homepage_url The manufacturer's homepage url "http://example.com" null

Part schema:

Property Description Example Empty Value
uid 64-bit unique identifier "e7392c64ca2538fe" n/a
mpn The manufacturer part number "SN74S74N" n/a
manufacturer Object representing the manufacturer <Manufacturer object> n/a
brand Object representing the brand <Brand object> n/a
octopart_url The url of the Octopart part detail page "http://octopart.com/XXXX" n/a
external_links Hidden by default (See Include Directives) <ExternalLinks object> n/a
Pricing and Availability
offers List of offer objects [<PartOffer object>] []
broker_listings Hidden by default (See Include Directives) <BrokerListing object> []
Descriptions and Images
short_description Hidden by default (See Include Directives) "CAP THIN FILM 0.3PF 16V 01005" null
descriptions Hidden by default (See Include Directives) [<Description object>] []
imagesets Hidden by default (See Include Directives) [<ImageSet object>] []
Documents and Files
datasheets Hidden by default (See Include Directives) [<Datasheet object>] []
compliance_documents Hidden by default (See Include Directives) [<ComplianceDocument object>] []
reference_designs Hidden by default (See Include Directives) [<ReferenceDesign object>] []
cad_models Hidden by default (See Include Directives) [<CADModel object>] []
Technical Specs
specs Hidden by default (See Include Directives) See notes: Part.specs {}
category_uids Hidden by default (See Include Directives) ["8ffd42f7bed8543a", "7a48b7424b6aa18f"] []

PartOffer schema:

Property Description Example Empty Value
sku The seller's part number "67K1122" n/a
seller Object representing the seller <Seller object> n/a
eligible_region The (ISO 3166-1 alpha-2) or (ISO 3166-2) code indicating the geo-political region(s) for which offer is valid "US-NY" null
product_url URL for seller landing page "http://octopart.com/redirect/XXXX" null
octopart_rfq_url URL for generating RFQ through Octopart "http://octopart.com/rfq/XXXX" null
prices Dictionary mapping currencies to lists of (Break, Price) tuples See notes: PartOffer.prices n/a
in_stock_quantity Number of parts seller has available See notes: PartOffer.in_stock_quantity n/a
on_order_quantity Number of parts on order from factory 2000 null
on_order_eta ISO 8601 formatted ETA of order from factory "2016-12-20T12:00:00Z" null
factory_lead_days Number of days to acquire parts from factory 42 null
factory_order_multiple Order multiple for factory orders 1000 null
order_multiple Number of items which must be ordered together See notes: PartOffer.order_multiple null
moq Minimum order quantity 100 null
packaging Form of offer packaging (e.g. reel, tape) See notes: PartOffer.packaging null
is_authorized True if seller is authorized by manufacturer See notes: PartOffer.is_authorized n/a
last_updated ISO 8601 formatted time when offer was last updated by the seller "2016-12-09T19:49:00Z" n/a

SpecValue schema:

Property Description Example Empty Value
value The value of the product property ["5.0"] []
min_value The minimum value (if ranged quantitative value) "2.2" null
max_value The maximum value (if ranged quantitative value) "10.8" null
display_value Value and unit as a string, formatted for humans "170 mV" ""
metadata Spec metadata information <SpecMetadata object> n/a
attribution Information about the data source <Attribution object> n/a

ReferenceDesign schema (inherits from Asset)

Property Description Example Empty Value
url The url of the asset "http://octopart.com/XXXX" n/a
mimetype The asset's mimetype "application/pdf" n/a
metadata Asset metadata (depends on mimetype) See notes: Asset.metadata n/a
title Title of design document "TMS320C55x Reference Guide" []
description Description of design document contents "The C55x is a fixed-point digital signal..." []
attribution Information about the data source <Attribution object> n/a

Seller schema:

Property Description Example Empty Value
uid 64-bit unique identifier "4a258f2f6a2199e2" n/a
name The seller's display name "Newark" n/a
homepage_url The seller's homepage url "http://example.com" null
display_flag ISO 3166 alpha-2 country code for display flag "US" null
has_ecommerce Whether seller has e-commerce true null

Source schema:

Property Description Example Empty Value
uid 64-bit unique identifier "4a258f2f6a2199e2" n/a
name The source's display name "Newark" n/a

SpecMetadata schema:

Property Description Example Empty Value
key Immutable identifier of property in Part.specs object "input_voltage" n/a
name The name of the product property "Input Voltage" n/a
datatype string|integer|decimal "integer" n/a
unit UnitOfMeasurement object <UnitOfMeasurement object> null

UnitOfMeasurement schema:

Property Description Example Empty Value
name The name of the unit of measurement "Ohms" n/a
symbol The symbol of the unit of measurement "Ω" null

Response Schemas

The following are the schemas for the response objects returned by the API (e.g. search responses, part match responses):

PartsMatchRequest schema:

Property Description Example Empty Value
queries List of queries [<PartsMatchQuery object>] []
exact_only Match on non-alphanumeric characters in part numbers true false

PartsMatchQuery schema:

Property Description Example Empty Value
q Free-form keyword query "TI SN74S74N" ""
mpn MPN search filter (See notes: Part Number Filters) "SN74S74N" null
brand Brand search filter "Texas Instruments" null
sku SKU search filter (See notes: Part Number Filters) "67K1122" null
seller Seller search filter "Newark" null
mpn_or_sku MPN or SKU search filter (See notes: Part Number Filters) "SN74S74N" null
start Ordinal position of first returned item 0 0
limit Maximum number of items to return 20 3
reference Arbitrary string for identifying results "line1" null

PartsMatchResponse schema:

Property Description Example Empty Value
request The original request <PartsMatchRequest object> n/a
results List of query results [<PartsMatchResult object>] n/a
msec The server response time in milliseconds 234 n/a

PartsMatchResult schema:

Property Description Example Empty Value
items List of matched parts [<Part object>] []
hits Total number of matched items 2 null
reference Reference string specified in query "line1" null
error Error message (if applicable) "Missing search filters" null

SearchRequest schema:

Property Description Example Empty Value
q Free-form keyword string "texas" ""
start Ordinal position of first result 0 0
limit Maximum number of results to return 10 10
sortby Comma separated list of (fieldname, fieldorder) pairs "avg_price asc, score desc" "score desc"
filter See: Search Documentation n/a
facet See: Search Documentation n/a
stats See: Search Documentation n/a

SearchResponse schema:

Property Description Example Empty Value
request The original request <SearchRequest object> n/a
results List of search results [<SearchResult object>] []
hits Total number of matched items 10332 n/a
msec The server response time in milliseconds 234 n/a
facet_results See: Search Documentation n/a
stats_results See: Search Documentation n/a
spec_metadata See: Search Documentation n/a

SearchResult schema:

Property Description Example Empty Value
item A matched object (e.g. a brand) <Brand object> n/a

SearchFacetResult schema:

Property Description Example Empty Value
facets List of value/count JSON objects [{"value": "Red", "count": 10}] []
missing Number of items in result set without a property value 1432 n/a
spec_drilldown_rank Rank in specs drilldown (useful for ordering filter options) 3 null

SearchStatsResult schema:

Property Description Example Empty Value
min Minimum value of the property in result set "0.123" null
max Maximum value of the property in result set "4.567" null
mean Mean value of the property in result set "3.456" null
stddev Standard deviation of the property values in result set "2.345" null
count Number of non-null property values in result set 102 n/a
missing Number of items in result set without a property value 1432 n/a
spec_drilldown_rank Rank in specs drilldown (useful for ordering filter options) 3 null

Error Schemas

The following are the schemas for the response objecs returned by the API in case of a client error (HTTP 4XX) or a server error (HTTP 5XX):

ClientErrorResponse schema:

Property Description Example Empty Value
message Message associated with 4XX HTTP response "Blocked by rate limiter" null

ServerErrorResponse schema:

Property Description Example Empty Value
message Message associated with 5XX HTTP response "Service down for maintenance" null

Endpoints

The Octopart API can be accessed by sending HTTP requests to the following HTTP endpoints:

/brands

Methods Path Description
GET /brands/{uid} Fetch a brand by primary key
GET /brands/search Search across brands
GET /brands/get_multi Fetch multiple brands
    • This method returns individual brands by primary key. The fetch key for a brand is its 'uid'.

      See Universal URL Arguments.

      This method returns a <Brand object>.

      • import json
        import urllib
        
        url = 'http://octopart.com/api/v3/brands/2239e3330e2df5fe'
        url += "?apikey=REPLACE_ME"
        
        data = urllib.urlopen(url).read()
        brand = json.loads(data)
        
        # print name
        print brand['name']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/brands/2239e3330e2df5fe"
        url += "?apikey=REPLACE_ME"
        
        resp = Net::HTTP.get_response(URI.parse(url))
        brand = JSON.parse(resp.body)
        
        # print name
        puts brand['name']
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/brands/2239e3330e2df5fe";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            $.getJSON(url, function(brand) {
                // print name
                console.log(brand['name']);
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class BrandsGet
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string id = "2239e3330e2df5fe";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "brands/{id}";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddUrlSegment("id", id);
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var brand = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print the brand display name
                    Console.WriteLine(brand["name"]);
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module BrandsGet
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim id As String = "2239e3330e2df5fe"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "brands/{id}"
                Dim apiKey As String = BrandsGet.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddUrlSegment("id", id)
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim brand = JsonConvert.DeserializeObject(data)
        
                ' Print the brand display name
                Console.WriteLine(brand("name"))
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: Brand was fetched successfuly
      • 404 Not Found: The brand does not exist

    • This method allows searching across brands by keyword. This is the ideal method to use to go from a brand alias or keyword to a Octopart brand instance

      Argument Datatype Default
      q string ""
      start integer 0
      limit integer 10
      sortby string "score desc"
      filter[fields][<fieldname>][] string ""
      filter[queries][] string ""
      facet[fields][<fieldname>][include] boolean false
      facet[fields][<fieldname>][exclude_filter] boolean false
      facet[fields][<fieldname>][start] integer 0
      facet[fields][<fieldname>][limit] integer 10
      facet[queries][] string ""
      stats[<fieldname>][include] boolean false
      stats[<fieldname>][exclude_filter] boolean false
      • q
        Full-text query string
      • start
        Ordinal position of first result. First position is 0. Maximum is 1000.
      • limit
        Maximum number of results to return. Default is 10. Maximum is 100.
      • sortby
        Comma separated list of (fieldname, fieldorder) pairs
      • filter[fields][<fieldname>][]
        Attribute (fieldname/fieldvalue) pair to filter results on
      • filter[queries][]
        Arbitrary filter query string
      • facet[fields][<fieldname>][include]
        If specified, perform faceting on given <fieldname>
      • facet[fields][<fieldname>][exclude_filter]
        If specified, remove <fieldname> from filters when calculating facets for <fieldname>
      • facet[fields][<fieldname>][start]
        Ordinal position of first facet to return. First position is 0. Maximum is 1000.
      • facet[fields][<fieldname>][limit]
        Number of facets to return. Default is 10. Maximum is 100.
      • facet[queries][]
        Arbitrary filter query string to facet on
      • stats[<fieldname>][include]
        If specified, calculate statistics for <fieldname
      • stats[<fieldname>][exclude_filter]
        If specified, remove <fieldname> from filters when calculating statistics for <fieldname>

      See Universal URL Arguments.

      Fieldname Description
      name Brand name

      This method returns a <SearchResponse object>.

      • import json
        import urllib
        
        url = "http://octopart.com/api/v3/brands/search"
        url += "?apikey=REPLACE_ME"
        
        args = [
           ('q', 'texas'),
           ('start', 0),
           ('limit', 10)
           ]
        
        url += '&' + urllib.urlencode(args)
        
        data = urllib.urlopen(url).read()
        search_response = json.loads(data)
        
        # print number of hits
        print search_response['hits']
        
        # print results
        for result in search_response['results']:
           # print matched brand
           print result['item']['name']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/brands/search"
        url += "?apikey=REPLACE_ME"
        
        def to_query(hsh)
          hsh.map {|k, v| "#{k}=#{URI.encode(v.to_s)}"}.join("&")
        end
        
        params = {
          :q =>"texas",
          :start => 0,
          :limit => 10
        }
        
        url += "&" + to_query(params)
        
        resp = Net::HTTP.get_response(URI.parse(url))
        search_response = JSON.parse(resp.body)
        
        # print number of hits
        puts search_response['hits']
        
        # print results
        search_response['results'].each do |result|
          # print matched brand
          puts result['item']['name']
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/brands/search";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            var args = {
                q: "texas",
                start: 0,
                limit: 10
            };
        
            $.getJSON(url, args, function(search_response) {
                // print original request
                console.log(search_response['request']);
        
                // iterate through results
                $.each(search_response['results'], function(i, result){
                    // print matched brand items
                    console.log(result['item']['name']);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class BrandsSearch
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string query = "texas";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "brands/search";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddParameter("q", query)
                                .AddParameter("start", "0")
                                .AddParameter("limit", "10");
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var search_response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print the number of hits
                    Console.WriteLine(search_response["hits"]);
        
                    // Print results
                    foreach (var result in search_response["results"])
                    {
                        // Print matched brand
                        Console.WriteLine(result["item"]["name"]);
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module BrandsSearch
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim query As String = "texas"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "brands/search"
                Dim apiKey As String = BrandsSearch.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddParameter("q", query) _
                                .AddParameter("start", "0") _
                                .AddParameter("limit", "10")
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim search_response = JsonConvert.DeserializeObject(data)
        
                ' Print the number of hits
                Console.WriteLine(search_response("hits"))
        
                ' Print results
                For Each result In search_response("results")
                    ' Print matched brand
                    Console.WriteLine(result("item")("name"))
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: The request was fetched successfuly
      • 400 Bad Request: The request failed validation

    • This endpoint returns multiple brands simultaneously by primary key. The fetch key for each brand is its 'uid'.

      Argument Datatype Default
      uid[] string None
      • uid[]
        The uid for an individual brand. Append multiple url arguments to fetch multiple brands (up to 20).

      See Universal URL Arguments.

      This method returns a JSON object mapping uids to <Brand objects>.

      • import json
        import urllib
        
        url = 'http://octopart.com/api/v3/brands/get_multi'
        url += "?apikey=REPLACE_ME"
        
        args = [
           ('uid[]', '2239e3330e2df5fe'),
           ('uid[]', 'c4f105fbe7591336')
           ]
        
        url += "&" + urllib.urlencode(args)
        
        data = urllib.urlopen(url).read()
        server_response = json.loads(data)
        
        # print brand display names
        for (uid, brand) in server_response.items():
           print brand['name']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/brands/get_multi"
        url += "?apikey=REPLACE_ME"
        
        uids = [
                "2239e3330e2df5fe",
                "c4f105fbe7591336"
               ]
        
        urlargs = []
        uids.each do |uid|
          urlargs.push("uid[]=" + uid)
        end
        
        url += "&" + urlargs.join("&")
        
        resp = Net::HTTP.get_response(URI.parse(url))
        server_response = JSON.parse(resp.body)
        
        # print names
        server_response.keys.each do |key|
          puts server_response[key]['name']
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/brands/get_multi";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            var args = {
                uid: [
                    "2239e3330e2df5fe",
                    "c4f105fbe7591336"
                ]
            };
        
            $.getJSON(url, args, function(brand) {
                // iterate through brands
                $.each(brands, function(uid, brand){
                    // print matched brand items
                    console.log(brand['name']);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class BrandsGetMulti
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string id1 = "2239e3330e2df5fe";
                    string id2 = "c4f105fbe7591336";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEntpoint = "brands/get_multi";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEntpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddParameter("uid[]", id1)
                                .AddParameter("uid[]", id2);
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var server_response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print the brand display names
                    foreach (var uid in server_response)
                    {
                        Console.WriteLine(uid.Value["name"]);
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module BrandsGetMulti
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim id1 As String = "2239e3330e2df5fe"
                Dim id2 As String = "c4f105fbe7591336"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEntpoint As String = "brands/get_multi"
                Dim apiKey As String = BrandsGetMulti.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEntpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddParameter("uid[]", id1) _
                                .AddParameter("uid[]", id2)
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim server_response = JsonConvert.DeserializeObject(data)
        
                ' Print the brand display names
                For Each uid In server_response
                    Console.WriteLine(uid.Value.GetValue("name"))
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: The request was completed successfuly

/categories

Methods Path Description
GET /categories/{uid} Fetch a category by its primary key
GET /categories/search Search across categories
GET /categories/get_multi Fetch multiple categories simultaneously
    • This method returns invividual category nodes by primary key. The fetch key for a category is its 'uid'.

      See Universal URL Arguments.

      This method returns a <Category object>

      • import json
        import urllib
        
        url = 'http://octopart.com/api/v3/categories/87a44aaeb6be5c63'
        url += "?apikey=REPLACE_ME"
        
        data = urllib.urlopen(url).read()
        category = json.loads(data)
        
        # print name
        print category['name']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/categories/87a44aaeb6be5c63"
        url += "?apikey=REPLACE_ME"
        
        resp = Net::HTTP.get_response(URI.parse(url))
        category = JSON.parse(resp.body)
        
        # print name
        puts category['name']
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/categories/87a44aaeb6be5c63";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            $.getJSON(url, function(category) {
                // print name
                console.log(category['name']);
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class CategoriesGet
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string id = "87a44aaeb6be5c63";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "categories/{id}";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddUrlSegment("id", id);
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var category = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print name
                    Console.WriteLine(category["name"]);
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module CategoriesGet
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim id As String = "87a44aaeb6be5c63"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "categories/{id}"
                Dim apiKey As String = CategoriesGet.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddUrlSegment("id", id)
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim category = JsonConvert.DeserializeObject(data)
        
                ' Print name
                Console.WriteLine(category("name"))
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: Category was fetched successfuly
      • 404 Not Found: The category does not exist

    • This method allows searching across categories by keyword.

      Argument Datatype Default
      q string ""
      start integer 0
      limit integer 10
      sortby string "score desc"
      filter[fields][<fieldname>][] string ""
      filter[queries][] string ""
      facet[fields][<fieldname>][include] boolean false
      facet[fields][<fieldname>][exclude_filter] boolean false
      facet[fields][<fieldname>][start] integer 0
      facet[fields][<fieldname>][limit] integer 10
      facet[queries][] string ""
      stats[<fieldname>][include] boolean false
      stats[<fieldname>][exclude_filter] boolean false
      • q
        Full-text query string
      • start
        Ordinal position of first result. First position is 0. Maximum is 1000.
      • limit
        Maximum number of results to return. Default is 10. Maximum is 100.
      • sortby
        Comma separated list of (fieldname, fieldorder) pairs
      • filter[fields][<fieldname>][]
        Attribute (fieldname/fieldvalue) pair to filter results on
      • filter[queries][]
        Arbitrary filter query string
      • facet[fields][<fieldname>][include]
        If specified, perform faceting on given <fieldname>
      • facet[fields][<fieldname>][exclude_filter]
        If specified, remove <fieldname> from filters when calculating facets for <fieldname>
      • facet[fields][<fieldname>][start]
        Ordinal position of first facet to return. First position is 0. Maximum is 1000.
      • facet[fields][<fieldname>][limit]
        Number of facets to return. Default is 10. Maximum is 100.
      • facet[queries][]
        Arbitrary filter query string to facet on
      • stats[<fieldname>][include]
        If specified, calculate statistics for <fieldname
      • stats[<fieldname>][exclude_filter]
        If specified, remove <fieldname> from filters when calculating statistics for <fieldname>

      See Universal URL Arguments.

      Fieldname Description
      name Category node name
      parent_uid Category node parent uid
      ancestor_uids Category node ancestor uid's

      This method returns a <SearchResponse object>.

      • import json
        import urllib
        
        url = "http://octopart.com/api/v3/categories/search"
        url += "?apikey=REPLACE_ME"
        
        args = [
           ('q', 'semiconductors'),
           ('start', 0),
           ('limit', 10)
           ]
        
        url += '&' + urllib.urlencode(args)
        
        data = urllib.urlopen(url).read()
        search_response = json.loads(data)
        
        # print number of hits
        print search_response['hits']
        
        # print results
        for result in search_response['results']:
           # print matched category
           print result['item']['name']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/categories/search"
        url += "?apikey=REPLACE_ME"
        
        def to_query(hsh)
          hsh.map {|k, v| "#{k}=#{URI.encode(v.to_s)}"}.join("&")
        end
        
        params = {
          :q => "semiconductors",
          :start => 0,
          :limit => 10
        }
        
        url += "&" + to_query(params)
        
        resp = Net::HTTP.get_response(URI.parse(url))
        search_response = JSON.parse(resp.body)
        
        # print number of hits
        puts search_response['hits']
        
        # print results
        search_response['results'].each do |result|
          # print matched category
          puts result['item']['name']
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/categories/search";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            var args = {
                q: "semiconductors",
                start: 0,
                limit: 10
            };
        
            $.getJSON(url, args, function(search_response) {
                // print original request
                console.log(search_response['request']);
        
                // iterate through results
                $.each(search_response['results'], function(i, result){
                    // print matched category items
                    console.log(result['item']['name']);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class CategoriesSearch
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string query = "semiconductors";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "categories/search";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddParameter("q", query)
                                .AddParameter("start", "0")
                                .AddParameter("limit", "10");
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var search_response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print the number of hits
                    Console.WriteLine(search_response["hits"]);
        
                    // Print results
                    foreach (var result in search_response["results"])
                    {
                        // Print matched category
                        Console.WriteLine(result["item"]["name"]);
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module CategoriesSearch
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim query As String = "semiconductors"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "categories/search"
                Dim apiKey As String = CategoriesSearch.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddParameter("q", query) _
                                .AddParameter("start", "0") _
                                .AddParameter("limit", "10")
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim search_response = JsonConvert.DeserializeObject(data)
        
                ' Print the number of hits
                Console.WriteLine(search_response("hits"))
        
                ' Print results
                For Each result In search_response("results")
                    ' Print matched category
                    Console.WriteLine(result("item")("name"))
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: The request was completed successfuly
      • 400 Bad Request: The request failed validation

    • This endpoint returns multiple categories simultaneously by primary key. The fetch key for each category is its 'uid'. Missing categories will also be missing from the response list.

      Argument Datatype Default
      uid[] string None
      • uid[]
        The uid for an individual category. Append multiple url arguments to fetch multiple categories (up to 20).

      See Universal URL Arguments.

      This method returns a JSON object mapping uids to <Category object>.

      • import json
        import urllib
        
        url = 'http://octopart.com/api/v3/categories/get_multi'
        url += "?apikey=REPLACE_ME"
        
        args = [
           ('uid[]', '3b27f62d0a3ae0e0'),
           ('uid[]', '9e07530daf1645c0')
           ]
        
        url += "&" + urllib.urlencode(args)
        
        data = urllib.urlopen(url).read()
        server_response = json.loads(data)
        
        # print category display names
        for (uid, category) in server_response.items():
           print category['name']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/categories/get_multi"
        url += "?apikey=REPLACE_ME"
        
        uids = [
                "3b27f62d0a3ae0e0",
                "9e07530daf1645c0"
               ]
        
        urlargs = []
        uids.each do |uid|
          urlargs.push("uid[]=" + uid)
        end
        
        url += "&" + urlargs.join("&")
        
        resp = Net::HTTP.get_response(URI.parse(url))
        server_response = JSON.parse(resp.body)
        
        # print names
        server_response.keys.each do |key|
          puts server_response[key]['name']
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/categories/get_multi";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            var args = {
                uid: [
                    "3b27f62d0a3ae0e0",
                    "9e07530daf1645c0"
                ]
            };
        
            $.getJSON(url, args, function(brand) {
                // iterate through categories
                $.each(categories, function(uid, category){
                    // print matched category items
                    console.log(category['name']);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class CategoriesGetMulti
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string id1 = "3b27f62d0a3ae0e0";
                    string id2 = "9e07530daf1645c0";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "categories/get_multi";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddParameter("uid[]", id1)
                                .AddParameter("uid[]", id2);
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var server_response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print the category display names
                    foreach (var uid in server_response)
                    {
                        Console.WriteLine(uid.Value["name"]);
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module CategoriesGetMulti
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim id1 As String = "3b27f62d0a3ae0e0"
                Dim id2 As String = "9e07530daf1645c0"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "categories/get_multi"
                Dim apiKey As String = CategoriesGetMulti.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddParameter("uid[]", id1) _
                                .AddParameter("uid[]", id2)
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim server_response = JsonConvert.DeserializeObject(data)
        
                ' Print the category display names
                For Each uid In server_response
                    Console.WriteLine(uid.Value.GetValue("name"))
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: Request was completed successfuly

/parts

Methods Path Description
GET /parts/{uid} Fetch a part by its primary key
GET /parts/match Match a list of parts by MPN or SKU
GET /parts/search Search across parts
GET /parts/get_multi Fetch multiple parts simultaneously
    • This method returns individual parts by primary key. The fetch key for a part is its 'uid'.

      See Universal URL Arguments.

      This method returns a <Part object>.

      • import json
        import urllib
        
        url = 'http://octopart.com/api/v3/parts/103cdb613d20cffb'
        url += '?apikey=REPLACE_ME'
        
        data = urllib.urlopen(url).read()
        response = json.loads(data)
        
        # print brand, mpn
        print response['brand']['name']
        print response['mpn']
        
        # print offers
        for offer in response['offers']:
            print offer['seller']['name']
            print offer['sku']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/parts/103cdb613d20cffb"
        url += '?apikey=REPLACE_ME'
        
        resp = Net::HTTP.get_response(URI.parse(url))
        part = JSON.parse(resp.body)
        
        # print brand, mpn
        puts part['brand']['name']
        puts part['mpn']
        
        # print offers
        part['offers'].each do |offer|
          puts offer['seller']['name']
          puts offer['sku']
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/parts/103cdb613d20cffb";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            $.getJSON(url, function(response) {
                // print brand, mpn
                console.log(response['brand']['name']);
                console.log(response['mpn']);
        
                // print offers
                $.each(response['offers'], function(i, offer) {
                    console.log(offer['seller']['name']);
                    console.log(offer['sku']);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class PartsGet
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string id = "103cdb613d20cffb";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "parts/{id}";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddUrlSegment("id", id);
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print brand, mpn
                    Console.WriteLine(response["brand"]["name"]);
                    Console.WriteLine(response["mpn"]);
        
                    // Print offers
                    foreach (var offer in response["offers"])
                    {
                        Console.WriteLine(offer["seller"]["name"]);
                        Console.WriteLine(offer["sku"]);
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module PartsGet
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim id As String = "103cdb613d20cffb"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "parts/{id}"
                Dim apiKey As String = PartsGet.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddUrlSegment("id", id)
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim response = JsonConvert.DeserializeObject(data)
        
                ' Print brand, mpn
                Console.WriteLine(response("brand")("name"))
                Console.WriteLine(response("mpn"))
        
                ' Print offers
                For Each offer In response("offers")
                    Console.WriteLine(offer("seller")("name"))
                    Console.WriteLine(offer("sku"))
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: Part was fetched successfuly
      • 404 Not Found: The part does not exist

    • This method returns parts matched by MPN/SKU filter. It also accepts brand and seller filters as well. This is the ideal method to match a list of parts (e.g. a BOM) to the Octopart parts database.

      Argument Datatype Default
      queries string "[]"
      exact_only boolean false
      • queries
        JSON encoded list of PartsMatchQuery objects. Maximum value of 'limit' argument is 20, and maximum 'start' + 'limit' is 100. The maximum number of queries per request is 20.
      • exact_only
        If specified, match non-alphanumeric characters in MPNs and SKUs

      See Universal URL Arguments.

      This method returns a <PartsMatchResponse object>.

      • import json
        import urllib
        
        queries = [
            {'mpn': 'SN74S74N',
             'reference': 'line1'},
            {'sku': '67K1122',
             'reference': 'line2'},
            {'mpn_or_sku': 'SN74S74N',
             'reference': 'line3'},
            {'brand': 'Texas Instruments',
             'mpn': 'SN74S74N',
             'reference': 'line4'}
            ]
        
        url = 'http://octopart.com/api/v3/parts/match?queries=%s' \
            % urllib.quote(json.dumps(queries))
        url += '&apikey=REPLACE_ME'
        
        data = urllib.urlopen(url).read()
        response = json.loads(data)
        
        # print request time (in milliseconds)
        print response['msec']
        
        # print mpn's
        for result in response['results']:
            print "Reference: %s" % result['reference']
            for item in result['items']:
                print item['mpn']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/parts/match"
        url += "?apikey=REPLACE_ME"
        
        queries = [
                   {:mpn => "SN74S74N", :reference => "line1"},
                   {:sku => "67K1122", :reference => "line2"},
                   {:mpn_or_sku => "SN74S74N", :reference =>"line3"},
                   {:brand => "Texas Instruments", :mpn => "SN74S74N",
                     :reference => "line4"}
                  ]
        
        url += "&queries=" + URI.encode(JSON.generate(queries))
        
        resp = Net::HTTP.get_response(URI.parse(url))
        server_response = JSON.parse(resp.body)
        
        # print request time (in milliseconds)
        puts server_response['msec']
        
        # print mpn's
        server_response['results'].each do |result|
          puts "Reference: " + result['reference']
          result['items'].each do |part|
            puts part['mpn']
          end
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/parts/match";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            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)
            };
        
            $.getJSON(url, args, function(response){
                var queries = response['request']['queries'];
                $.each(queries, function(i, query) {
                    // print query
                    console.log(query);
                    
                    // print corresponding result
                    console.log(response['results'][i]);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
            using System.Collections.Generic;
            using System.Web.Script.Serialization;
        
            public static class PartsMatch
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    var query = new List<dynamic>()
                    {
                        new Dictionary<string, string>()
                        { { "mpn", "SN74S74N" },
                          { "reference", "line1" } },
                        new Dictionary<string, string>()
                        { { "sku", "67K1122" },
                          { "reference", "line2" } },
                        new Dictionary<string, string>()
                        { { "mpn_or_sku", "SN74S74N" },
                          { "reference", "line3" } },
                        new Dictionary<string, string>()
                        { { "brand", "Texas Instruments" },
                          { "mpn", "SN74S74N" },
                          { "reference", "line4" } }
                    };
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "parts/match";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    string queryString = (new JavaScriptSerializer()).Serialize(query);
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddParameter("queries", queryString);
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print request time (in milliseconds)
                    Console.WriteLine(response["msec"]);
        
                    // Print mpn's
                    foreach (var result in response["results"])
                    {
                        Console.WriteLine("Reference: " + result["reference"]);
                        foreach (var item in result["items"])
                        {
                            Console.WriteLine(item["mpn"]);
                        }
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        Imports System.Collections.Generic
        Imports System.Web.Script.Serialization
        
        Public Module PartsMatch
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim query = New List(Of Dictionary(Of String, String))() From _
                { _
                    New Dictionary(Of String, String)() From _
                    {{"mpn", "SN74S74N"}, _
                        {"reference", "line1"}}, _
                    New Dictionary(Of String, String)() From _
                    {{"sku", "67K1122"}, _
                        {"reference", "line2"}}, _
                    New Dictionary(Of String, String)() From _
                    {{"mpn_or_sku", "SN74S74N"}, _
                        {"reference", "line3"}}, _
                    New Dictionary(Of String, String)() From _
                    {{"brand", "Texas Instruments"}, _
                        {"mpn", "SN74S74N"}, _
                        {"reference", "line4"}} _
                }
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "parts/match"
                Dim apiKey As String = PartsMatch.APIKEY
        
                ' Create the search request
                Dim queryString = (New JavaScriptSerializer()).Serialize(query)
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddParameter("queries", queryString)
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim response = JsonConvert.DeserializeObject(data)
        
                ' Print request time (in milliseconds)
                Console.WriteLine(response("msec"))
        
                ' Print mpn's
                For Each result In response("results")
                    Console.WriteLine("Reference: " & result("reference"))
                    For Each item In result("items")
                        Console.WriteLine(item("mpn"))
                    Next
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: Request was completed successfuly
      • 400 Bad Request: JSON parsing error

    • This method allows searching across parts by keyword. or technical specs. This is the ideal method to use to filter parts by manufacturer or to perform a parametric search.

      Argument Datatype Default
      q string ""
      start integer 0
      limit integer 10
      sortby string "score desc"
      filter[fields][<fieldname>][] string ""
      filter[queries][] string ""
      facet[fields][<fieldname>][include] boolean false
      facet[fields][<fieldname>][exclude_filter] boolean false
      facet[fields][<fieldname>][start] integer 0
      facet[fields][<fieldname>][limit] integer 10
      facet[queries][] string ""
      stats[<fieldname>][include] boolean false
      stats[<fieldname>][exclude_filter] boolean false
      spec_drilldown[include] boolean false
      spec_drilldown[exclude_filter] boolean false
      spec_drilldown[limit] integer 10
      • q
        Full-text query string
      • start
        Ordinal position of first result. First position is 0. Maximum is 1000.
      • limit
        Maximum number of results to return. Default is 10. Maximum is 100.
      • sortby
        Comma separated list of (fieldname, fieldorder) pairs
      • filter[fields][<fieldname>][]
        Attribute (fieldname/fieldvalue) pair to filter results on
      • filter[queries][]
        Arbitrary filter query string
      • facet[fields][<fieldname>][include]
        If specified, perform faceting on given <fieldname>
      • facet[fields][<fieldname>][exclude_filter]
        If specified, remove <fieldname> from filters when calculating facets for <fieldname>
      • facet[fields][<fieldname>][start]
        Ordinal position of first facet to return. First position is 0. Maximum is 1000.
      • facet[fields][<fieldname>][limit]
        Number of facets to return. Default is 10. Maximum is 100.
      • facet[queries][]
        Arbitrary filter query string to facet on
      • stats[<fieldname>][include]
        If specified, calculate statistics for <fieldname
      • stats[<fieldname>][exclude_filter]
        If specified, remove <fieldname> from filters when calculating statistics for <fieldname>
      • spec_drilldown[include]
        If specified, perform drilldown
      • spec_drilldown[exclude_filter]
        If specified, remove <fieldname> from filters when calculating statistics for <fieldname>
      • spec_drilldown[limit]
        Number of facets to return for each field. Default is 10. Maximum is 100.

      See Universal URL Arguments.

      Fieldname Description
      mpn Manufacturer part number
      brand.name Manufacturer brand name
      offers.sku Distributor SKU
      offers.seller.name Distributor name
      descriptions.value Description text value
      specs.*.value Technical specs value property
      specs.*.min_value Technical specs min_value property
      specs.*.max_value Technical specs max_value property
      category_uids Category uid's

      This method returns a <SearchResponse object>.

      • import json
        import urllib
        
        url = "http://octopart.com/api/v3/parts/search"
        
        # NOTE: Use your API key here (https://octopart.com/api/register)
        url += "?apikey=REPLACE_ME" 
        
        args = [
           ('q', 'solid state relay'),
           ('start', 0),
           ('limit', 10)
           ]
        
        url += '&' + urllib.urlencode(args)
        
        data = urllib.urlopen(url).read()
        search_response = json.loads(data)
        
        # print number of hits
        print search_response['hits']
        
        # print results
        for result in search_response['results']:
           part = result['item']
        
           # print matched part
           print "%s - %s" % (part['brand']['name'], part['mpn'])
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/parts/search"
        
        # NOTE: Use your API key here (https://octopart.com/api/register)
        url += "?apikey=REPLACE_ME"
        
        def to_query(hsh)
          hsh.map {|k, v| "#{k}=#{URI.encode(v.to_s)}"}.join("&")
        end
        
        params = {
          :q =>"solid state relay",
          :start => 0,
          :limit => 10
        }
        
        url += "&" + to_query(params)
        
        resp = Net::HTTP.get_response(URI.parse(url))
        search_response = JSON.parse(resp.body)
        
        # print number of hits
        puts search_response['hits']
        
        # print results
        search_response['results'].each do |result|
          part = result['item']
        
          # print matched part
          puts part['brand']['name'] + ' - ' + part['mpn']
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/parts/search";
            url += "?callback=?";
        
            // NOTE: Use your API key here (https://octopart.com/api/register)
            url += "&apikey=REPLACE_ME";
        
            var args = {
                q: "solid state relay",
                start: 0,
                limit: 10
            };
        
            $.getJSON(url, args, function(search_response) {
                // print original request
                console.log(search_response['request']);
        
                // iterate through results
                $.each(search_response['results'], function(i, result){
                    var part = result['item'];
        
                    // print matched part items
                    console.log(part['brand']['name'] + ' - ' + part['mpn']);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class PartsSearch
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string query = "solid state relay";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "parts/search";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddParameter("q", query)
                                .AddParameter("start", "0")
                                .AddParameter("limit", "10");
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var search_response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print number of hits
                    Console.WriteLine(search_response["hits"]);
        
                    // Print results
                    foreach (var result in search_response["results"])
                    {
                        var part = result["item"];
                        
                        // Print matched part
                        Console.WriteLine(part["brand"]["name"] + " - " + part["mpn"]);
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module PartsSearch
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim query As String = "solid state relay"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "parts/search"
                Dim apiKey As String = PartsSearch.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddParameter("q", query) _
                                .AddParameter("start", "0") _
                                .AddParameter("limit", "10")
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim search_response = JsonConvert.DeserializeObject(data)
        
                ' Print number of hits
                Console.WriteLine(search_response("hits"))
        
                ' Print results
                For Each result In search_response("results")
                    Dim part = result("item")
                    ' Print matched part
                    Console.WriteLine(part("brand")("name") & " - " & part("mpn"))
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: The request was completed successfuly
      • 400 Bad Request: The request failed validation

    • This endpoint returns multiple parts simultaneously by primary key. The fetch key for each part is its 'uid'. Missing parts will also be missing from the response list.

      Argument Datatype Default
      uid[] string None
      • uid[]
        The uid for an individual part. Append multiple url arguments to fetch multiple parts (up to 20).

      See Universal URL Arguments.

      This method returns a JSON object mapping uids to <Part objects>.

      • import json
        import urllib
        
        url = 'http://octopart.com/api/v3/parts/get_multi?'
        url += '?apikey=REPLACE_ME'
        
        args = [
           ('uid[]', '103cdb613d20cffb'),
           ('uid[]', '2a68e3620f0cf5af')
           ]
        
        url += "&" + urllib.urlencode(args)
        
        data = urllib.urlopen(url).read()
        server_response = json.loads(data)
        
        # print brands, mpn's
        for (uid, part) in server_response.items():
           print part['brand']['name']
           print part['mpn']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/parts/get_multi"
        url += "?apikey=REPLACE_ME"
        
        uids = [
           "103cdb613d20cffb",
           "2a68e3620f0cf5af"
           ]
        
        urlargs = []
        uids.each do |uid|
           urlargs.push("uid[]=" + uid)
        end
        
        url += "&" + urlargs.join("&")
        
        resp = Net::HTTP.get_response(URI.parse(url))
        server_response = JSON.parse(resp.body)
        
        # print brands and mpn's
        server_response.keys.each do |key|
           puts server_response[key]['brand']['name']
           puts server_response[key]['mpn']
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/parts/get_multi";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            var args = {
                uid: [
                    "103cdb613d20cffb",
                    "2a68e3620f0cf5af"
                ]
            };
        
            $.getJSON(url, args, function(parts) {
                // iterate through parts
                $.each(parts, function(i, part) {
                    console.log(part['brand']['name']);
                    console.log(part['mpn']);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class PartsGetMulti
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string id1 = "103cdb613d20cffb";
                    string id2 = "2a68e3620f0cf5af";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "parts/get_multi";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddParameter("uid[]", id1)
                                .AddParameter("uid[]", id2);
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var server_response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print brands, mpn's
                    foreach (var part in server_response)
                    {
                        Console.WriteLine(part.Value["brand"]["name"]);
                        Console.WriteLine(part.Value["mpn"]);
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module PartsGetMulti
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim id1 As String = "103cdb613d20cffb"
                Dim id2 As String = "2a68e3620f0cf5af"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "parts/get_multi"
                Dim apiKey As String = PartsGetMulti.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddParameter("uid[]", id1) _
                                .AddParameter("uid[]", id2)
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim server_response = JsonConvert.DeserializeObject(data)
        
                ' Print brands, mpn's
                For Each part In server_response
                    Console.WriteLine(part.Value.GetValue("brand").GetValue("name"))
                    Console.WriteLine(part.Value.GetValue("mpn"))
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: Request was completed successfuly

/sellers

Methods Path Description
GET /sellers/{uid} Fetch a seller by its primary key
GET /sellers/search Search across sellers
GET /sellers/get_multi Fetch multiple sellers
    • This method returns individual sellers by primary key. The fetch key for a seller is its 'uid'

      See Universal URL Arguments.

      This method returns a <Seller object>.

      • import json
        import urllib
        
        url = "http://octopart.com/api/v3/sellers/d294179ef2900153"
        url += "?apikey=REPLACE_ME"
        
        data = urllib.urlopen(url).read()
        seller = json.loads(data)
        
        # print name
        print seller['name']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/sellers/d294179ef2900153"
        url += "?apikey=REPLACE_ME"
        
        resp = Net::HTTP.get_response(URI.parse(url))
        seller = JSON.parse(resp.body)
        
        # print name
        puts seller['name']
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/sellers/d294179ef2900153";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            $.getJSON(url, function(seller) {
                // print name
                console.log(seller['name']);
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class SellersGet
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string id = "d294179ef2900153";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "sellers/{id}";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddUrlSegment("id", id);
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var seller = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print name
                    Console.WriteLine(seller["name"]);
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module SellersGet
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim id As String = "d294179ef2900153"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "sellers/{id}"
                Dim apiKey As String = SellersGet.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddUrlSegment("id", id)
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim seller = JsonConvert.DeserializeObject(data)
        
                ' Print name
                Console.WriteLine(seller("name"))
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: Seller was fetched successfuly
      • 404 Not Found: The seller does not exist

    • This method allows searching across sellers by keyword. This is the ideal method to use to go from a seller alias or keyword to a Octopart seller instance

      Argument Datatype Default
      q string ""
      start integer 0
      limit integer 10
      sortby string "score desc"
      filter[fields][<fieldname>][] string ""
      filter[queries][] string ""
      facet[fields][<fieldname>][include] boolean false
      facet[fields][<fieldname>][exclude_filter] boolean false
      facet[fields][<fieldname>][start] integer 0
      facet[fields][<fieldname>][limit] integer 10
      facet[queries][] string ""
      stats[<fieldname>][include] boolean false
      stats[<fieldname>][exclude_filter] boolean false
      • q
        Full-text query string
      • start
        Ordinal position of first result. First position is 0. Maximum is 1000.
      • limit
        Maximum number of results to return. Default is 10. Maximum is 100.
      • sortby
        Comma separated list of (fieldname, fieldorder) pairs
      • filter[fields][<fieldname>][]
        Attribute (fieldname/fieldvalue) pair to filter results on
      • filter[queries][]
        Arbitrary filter query string
      • facet[fields][<fieldname>][include]
        If specified, perform faceting on given <fieldname>
      • facet[fields][<fieldname>][exclude_filter]
        If specified, remove <fieldname> from filters when calculating facets for <fieldname>
      • facet[fields][<fieldname>][start]
        Ordinal position of first facet to return. First position is 0. Maximum is 1000.
      • facet[fields][<fieldname>][limit]
        Number of facets to return. Default is 10. Maximum is 100.
      • facet[queries][]
        Arbitrary filter query string to facet on
      • stats[<fieldname>][include]
        If specified, calculate statistics for <fieldname
      • stats[<fieldname>][exclude_filter]
        If specified, remove <fieldname> from filters when calculating statistics for <fieldname>

      See Universal URL Arguments.

      Fieldname Description
      name Brand name

      This method returns a <SearchResponse object>.

      • import json
        import urllib
        
        url = 'http://octopart.com/api/v3/sellers/search'
        url += '?apikey=REPLACE_ME'
        
        args = [
           ('q', 'newark'),
           ('start', 0),
           ('limit', 10)
           ]
        
        url += "&" + urllib.urlencode(args)
        
        data = urllib.urlopen(url).read()
        search_response = json.loads(data)
        
        # print number of hits
        print search_response['hits']
        
        # print results
        for result in search_response['results']:
           # print matched seller
           print result['item']['name']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/sellers/search"
        url += "?apikey=REPLACE_ME"
        
        def to_query(hsh)
          hsh.map {|k, v| "#{k}=#{URI.encode(v.to_s)}"}.join("&")
        end
        
        params = {
          :q =>"newark",
          :start => 0,
          :limit => 10
        }
        
        url += "&" + to_query(params)
        
        resp = Net::HTTP.get_response(URI.parse(url))
        search_response = JSON.parse(resp.body)
        
        # print number of hits
        puts search_response['hits']
        
        # print results
        search_response['results'].each do |result|
          # print matched seller
          puts result['item']['name']
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/sellers/search";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            var args = {
                q: "newark",
                start: 0,
                limit: 10
            };
        
            $.getJSON(url, args, function(search_response) {
                // print original request
                console.log(search_response['request']);
        
                // iterate through results
                $.each(search_response['results'], function(i, result){
                    // print matched seller items
                    console.log(result['item']['name']);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class SellersSearch
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string query = "newark";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "sellers/search";
                    string apiKey = APIKEY;
                    
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddParameter("q", query)
                                .AddParameter("start", "0")
                                .AddParameter("limit", "10");
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var search_response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print the number of hits
                    Console.WriteLine(search_response["hits"]);
        
                    // Print results
                    foreach (var result in search_response["results"])
                    {
                        // Print matched seller
                        Console.WriteLine(result["item"]["name"]);
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module SellersSearch
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim query As String = "newark"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "sellers/search"
                Dim apiKey As String = SellersSearch.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddParameter("q", query) _
                                .AddParameter("start", "0") _
                                .AddParameter("limit", "10")
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim search_response = JsonConvert.DeserializeObject(data)
        
                ' Print the number of hits
                Console.WriteLine(search_response("hits"))
        
                ' Print results
                For Each result In search_response("results")
                    ' Print matched seller
                    Console.WriteLine(result("item")("name"))
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: The request was completed successfuly
      • 400 Bad Request: The request failed validation

    • This endpoint returns multiple sellers simultaneously by primary key. The fetch key for each seller is its 'uid'.

      Argument Datatype Default
      uid[] string None
      • uid[]
        The key for an individual seller. Append multiple url arguments to fetch multiple sellers (up to 20).

      See Universal URL Arguments.

      This method returns a JSON object mapping uids to <Seller objects>.

      • import json
        import urllib
        
        url = "http://octopart.com/api/v3/sellers/get_multi"
        url += "?apikey=REPLACE_ME"
        
        args = [
           ('uid[]', 'd294179ef2900153'),
           ('uid[]', '2c3be9310496fffc')
           ]
        
        url += "&" + urllib.urlencode(args)
        
        data = urllib.urlopen(url).read()
        server_response = json.loads(data)
        
        # print seller display names
        for (uid, seller) in server_response.items():
           print seller['name']
        
      • require 'rubygems'
        require 'json'
        require 'net/http'
        
        url = "http://octopart.com/api/v3/sellers/get_multi"
        url += "?apikey=REPLACE_ME"
        
        uids = [
           "d294179ef2900153",
           "2c3be9310496fffc"
           ]
        
        urlargs = []
        uids.each do |uid|
           urlargs.push("uid[]=" + uid)
        end
        
        url += "&" + urlargs.join("&")
        
        resp = Net::HTTP.get_response(URI.parse(url))
        server_response = JSON.parse(resp.body)
        
        # print names
        server_response.keys.each do |key|
           puts server_response[key]['name']
        end
        
      • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
        <script>
            var url = "http://octopart.com/api/v3/sellers/get_multi";
            url += "?apikey=REPLACE_ME";
            url += "&callback=?";
        
            var args = {
                uid: [
                    "d294179ef2900153",
                    "2c3be9310496fffc"
                ]
            };
        
            $.getJSON(url, args, function(sellers) {
                // iterate through sellers
                $.each(sellers, function(i, seller){
                    // print matched seller items
                    console.log(seller['name']);
                });
            });
        </script>
        
      • namespace OctopartApi
        {
            using Newtonsoft.Json;
            using RestSharp;
            using System;
        
            public static class SellersGetMulti
            {
                public static void ExecuteSearch()
                {
                    // -- your search query --
                    string id1 = "d294179ef2900153";
                    string id2 = "2c3be9310496fffc";
        
                    string octopartUrlBase = "http://octopart.com/api/v3";
                    string octopartUrlEndpoint = "sellers/get_multi";
                    string apiKey = APIKEY;
        
                    // Create the search request
                    var client = new RestClient(octopartUrlBase);
                    var req = new RestRequest(octopartUrlEndpoint, Method.GET)
                                .AddParameter("apikey", apiKey)
                                .AddParameter("uid[]", id1)
                                .AddParameter("uid[]", id2);
        
                    // Perform the search and obtain results
                    var data = client.Execute(req).Content;
                    var server_response = JsonConvert.DeserializeObject<dynamic>(data);
        
                    // Print the seller display names
                    foreach (var uid in server_response)
                    {
                        Console.WriteLine(uid.Value["name"]);
                    }
                }
        
                // -- your API key -- (https://octopart.com/api/register)
                private const string APIKEY = "REPLACE_ME";
            }
        }
        
      • Imports Newtonsoft.Json
        Imports RestSharp
        Imports System
        
        Public Module SellersGetMulti
            Public Sub ExecuteSearch()
                ' -- your search query --
                Dim id1 As String = "d294179ef2900153"
                Dim id2 As String = "2c3be9310496fffc"
        
                Dim octopartUrlBase As String = "http://octopart.com/api/v3"
                Dim octopartUrlEndpoint As String = "sellers/get_multi"
                Dim apiKey As String = SellersGetMulti.APIKEY
        
                ' Create the search request
                Dim client = New RestClient(octopartUrlBase)
                Dim req = New RestRequest(octopartUrlEndpoint, Method.GET) _
                                .AddParameter("apikey", apiKey) _
                                .AddParameter("uid[]", id1) _
                                .AddParameter("uid[]", id2)
        
                ' Perform the search and obtain results
                Dim data = client.Execute(req).Content
                Dim server_response = JsonConvert.DeserializeObject(data)
        
                ' Print the seller display names
                For Each uid In server_response
                    Console.WriteLine(uid.Value.GetValue("name"))
                Next
            End Sub
        
            ' -- your API key -- (https:'octopart.com/api/register)
            Private Const APIKEY As String = "REPLACE_ME"
        End Module
        
    • These are some common HTTP responses and their likely causes:

      • 200 OK: The request was completed successfuly


Include Directives

For performance reasons, some types of data are not included in API response objects by default (e.g. datasheets). To add missing data you can use the include url argument:

$ curl -G https://octopart.com/api/v3/parts/match \
   -d queries="[{\"mpn\":\"SN74S74N\"}]" \
   -d apikey=EXAMPLE_KEY \
   -d pretty_print=true \
   -d include[]=datasheets \
   -d include[]=compliance_documents

More generally, here are the rules for using the include directive:

  • The general strategy is to use url arguments of the form:

    &include[]=<fieldname>

  • To include multiple fields you can chain together include directives:

    &include[]=<fieldname1>&include[]=<fieldname2>

The following include directives can be used with the parts collection:

URL Argument Description
include[]=short_description Add short description to part objects
include[]=datasheets Add datasheets to part objects
include[]=compliance_documents Add compliance documents to part objects
include[]=descriptions Add descriptions to part objects
include[]=imagesets Add images to part objects
include[]=specs Add technical specs to part objects
include[]=category_uids Add category uids to part objects
include[]=external_links Add external links to part objects
include[]=reference_designs Add reference designs to part objects
include[]=cad_models Add 3D models to part objects

Show/Hide Directives

Show/hide directives are url arguments that you can use to control the size of API response objects by only requesting the fields you need. For example, to only show MPNs and manufacturer brand names for each part matched in a parts/match request:

$ curl -G https://octopart.com/api/v3/parts/match \
   -d queries='[{"mpn":"SN74S74N"}]' \
   -d apikey=EXAMPLE_KEY \
   -d pretty_print=true \
   -d show[]=mpn \
   -d show[]=brand.name

More generally, here are the rules for using show/hide directives:

  • The general strategy is to use url arguments of the form:

    &show[]=<fieldname1>&hide[]=<fieldname2>

  • To show/hide multiple fields you can chain together directives:

    &show[]=<fieldname1>&show[]=<fieldname2>

  • When you use show directives, all other fields are automatically hidden by default:

    &show[]=mpn&show[]=brand.name

  • When you use use show and hide directives together, show directives are applied first:

    &show[]=mpn&show[]=offers&hide[]=offers.seller.display_flag


Slice Directives

For more fine-grained control over API response sizes you can use the slice url argument to perform slice operations on JSON arrays. For example, to only show the first five offers for each part matched in a parts/match request:

$ curl -G https://octopart.com/api/v3/parts/match \
   -d queries='[{"mpn":"SN74S74N"}]' \
   -d apikey=EXAMPLE_KEY \
   -d pretty_print=true \
   -d slice[offers]=[0:5]

More generally, here are the rules for using the slice directive:

  • The general strategy is to use url arguments of the form:

    &slice[<fieldname>]=[<index1>:<index2>]

  • To slice multiple fields you can chain together slice directives:

    &slice[<fieldname1>]=[<index1>:<index2>]&slice[<fieldname2>]=[<index1>:<index2>]


Search Documentation

Each Octopart API search endpoint exposes advanced search functionality that can be used to implement useful search features such as parametric search. The following is reference documentation for the search endpoints. For a more narrative approach please read our Search Tutorial.

URL Arguments

The following are the URL arguments available to each search endpoint:

Argument Datatype Default
q string ""
start integer 0
limit integer 10
sortby string "score desc"
filter[fields][<fieldname>][] string ""
filter[queries][] string ""
facet[fields][<fieldname>][include] boolean false
facet[fields][<fieldname>][exclude_filter] boolean false
facet[fields][<fieldname>][start] integer 0
facet[fields][<fieldname>][limit] integer 10
facet[queries][] string ""
stats[<fieldname>][include] boolean false
stats[<fieldname>][exclude_filter] boolean false
  • q
    Full-text query string
  • start
    Ordinal position of first result. First position is 0. Maximum is 1000.
  • limit
    Maximum number of results to return. Default is 10. Maximum is 100.
  • sortby
    Comma separated list of (fieldname, fieldorder) pairs
  • filter[fields][<fieldname>][]
    Attribute (fieldname/fieldvalue) pair to filter results on
  • filter[queries][]
    Arbitrary filter query string
  • facet[fields][<fieldname>][include]
    If specified, perform faceting on given <fieldname>
  • facet[fields][<fieldname>][exclude_filter]
    If specified, remove <fieldname> from filters when calculating facets for <fieldname>
  • facet[fields][<fieldname>][start]
    Ordinal position of first facet to return. First position is 0. Maximum is 1000.
  • facet[fields][<fieldname>][limit]
    Number of facets to return. Default is 10. Maximum is 100.
  • facet[queries][]
    Arbitrary filter query string to facet on
  • stats[<fieldname>][include]
    If specified, calculate statistics for <fieldname
  • stats[<fieldname>][exclude_filter]
    If specified, remove <fieldname> from filters when calculating statistics for <fieldname>

Fieldnames

Several of the endpoint url arguments use a variable referred to as <fieldname>. Fieldnames are dot-separated property names which can be used to reference nested property values. For example, to filter on parts sold by Newark you can use the offer.seller.name fieldname:

&filter[fields][offers.seller.name][]=Newark

Other examples of commonly fieldnames used in the parts/search endpoint are manufacturer brand names (brand.name) and technical specs (e.g. specs.capacitance.value).

For a more narrative overview of fieldnames please visit the Fieldnames Section of the Search Tutorial.

Search Filters

The simplest way to filter search results is to add (fieldname, fieldvalue) pairs using the filter[fields] url argument:

&filter[fields][<fieldname1>][]=<fieldvalue1>

Multple arguments for the same fieldname will be OR'd together:

&filter[fields][<fieldname1>][]=<fieldvalue1A>&filter[fields][<fieldname1>][]=<fieldvalue1B>

Arguments for different fieldnames will be AND'd together:

&filter[fields][<fieldname1>][]=<fieldvalue1>&filter[fields][<fieldname2>][]=<fieldvalue2>

One thing to note is that the filter[fields] argument treats all filtervalues literally. It doesn't accept wildcards or any other search directives.

For low-level control over search filters you can use filter query syntax (see below) and the filter[queries] url argument:

&filter[queries][]=<filterquery>

Filter queries can also be AND'd together using multiple url arguments:

&filter[queries][]=<filterquery1>&filter[queries][]=<filterquery2>

For a narrative introduction to search filters please visit the Filtering Section of the Search Tutorial.

Full-text query syntax

The full-text query field (q) accepts the following operators:

Description Full-text query syntax
Phrase Match "keyword1 keyword2"
Negative Boolean Operator -keyword1 keyword2
Multiple-letter wildcards part*ber *art*umb* partnum*
Single-letter wildcards part?umber ?artnum?er partnumb??

Please note that multiple-letter wildcards and single-letter wildcards are only applied against part number fields (see Notes: Part Number Filters).

For a narrative introduction to keyword search using full-text queries please visit the Keyword Search section of the Search Tutorial.

Filter query syntax

Filter queries can be made up of the following elements:

Description Filter query syntax
Single Terms fieldname:val
Multiple Terms fieldname:(val1 val2)
Phrase Match fieldname:"val1 val2"
Multiple-letter Wildcards fieldname:val*
Single-letter Wildcards fieldname:va?
Ranged Search (inclusive) fieldname:[min_val TO max_val]
Ranged Search (exclusive) fieldname:{min_val to max_val}
Ranged Search (unbounded) fieldname:[min_val TO *]
Boolean Operators query1 OR query2
Nested Queries (query1 AND query2) OR (query3 AND query4)

For a narrative introduction to filter queries please visit the Filter Queries section of the Search Tutorial.

Reserved characters

To use any of the characters which function as operators without treating them as operators, you should escape them with a leading backslash. For example, to search for an MPN that contains parentheses, like 123(456), write your query as mpn:123\(456\).

The reserved characters for filter queries are ( ) " * ? [ ] { } : \ plus whitespace.

Faceting

Facets give developers an easy way to implement guided search interfaces by allowing users to "preview" the filters that are available within a given result set. For example, you can narrow your part search to LEDs and then facet on "color" to see how many "Red", "Green", and "Yellow" LEDs match in the set.

Facet Fields

The simplest way to facet search results is by specifing a <fieldname> to facet on using the facet[fields] url argument:

$ curl -G https://octopart.com/api/v3/parts/match \
   -d q=solid+state+relay \
   -d limit=0 \
   -d apikey=REPLACE_ME \
   -d pretty_print=true \
   -d facet[fields][brand.name][include]=true

More generally, here are the rules for faceting on fields:

  • The general strategy is to use url arguments of the form:

    &facet[fields][<fieldname>][include]=true

  • To facet on multiple fields you can chain together url arguments:

    &facet[fields][<fieldname1>][include]=true&facet[fields][<fieldname2>][include]=true

  • To page through the facet results you can use the start/limit arguments:

    &facet[fields][<fieldname>][start]=10&facet[fields][<fieldname>][limit]=20

And here's an example of a facet_results JSON object in the SearchResponse when a facet field request is made:


    "facet_results": {
        "fields": {
            "brand.name": {
                "facets": [
                    {"value": "Crydom", "count": 4304},
                    {"value": "Omron", "count": 3233},
                    {"value": "Panasonic", "count": 2785}
                ]
            }
        },
        "queries": {}
    }
    

Facet Queries

To facet on a specific filter value you can use the facet[queries] url argument which accepts filters defined using the filter query syntax (see above):

$ curl -G https://octopart.com/api/v3/parts/match \
   -d q=solid+state+relay \
   -d limit=0 \
   -d apikey=REPLACE_ME \
   -d pretty_print=true \
   -d facet[queries][]=brand.name:Crydom

More generally, here are the rules for faceting on filter queries:

  • The general strategy is to use url arguments of the form:

    &facet[queries][]=<filterquery>

  • To facet on multiple filter queries you can chain together url arguments:

    &facet[queries][]=<filterquery1>&facet[queries][]=<filterquery2>

And here's an example of a facet_results JSON object in the SearchResponse when a facet query request is made:


    "facet_results": {
        "fields": {},
        "queries": {
            "brand.name:Crydom": 4304
        }
    }
    

Statistics

To calculate statistics for a given field (e.g. min, max stddev) you can specify the <fieldname> and use the stats url argument:

More generally, here are the rules for calculating stats on fields:

  • The general strategy is to use url arguments of the form:

    &stats[<fieldname>][include]=true

  • To calculate stats for multiple fields you can chain together url arguments:

    &stats[<fieldname1>][include]=true&stats[<fieldname2>][include]=true

And here's an example of a facet_results JSON object in the SearchResponse when a facet field request is made:


    "stats_results": {
        "specs.load_current.value": {
            "stats": {
                "min": 1.0,
                "max": 6.0,
                "mean": 3.0,
                "stddev": 2.6457,
                "count": 3
                }
            }
        }
    }
    

Search Tutorial

For a guided overview of the Octopart API search interface please see the Search Tutorial.


Universal URL Arguments

Argument Datatype Default
callback string none
pretty_print boolean false
suppress_status_codes boolean false
  • callback
    The name of the callback function to wrap the result.
  • pretty_print
    Format the result in a more human-readable way. Default is false.
  • suppress_status_codes
    Return all responses with HTTP 200 OK status code - even errors.

Notes

Asset.metadata

The metadata attribute attached to Asset instances is a JSON object whose schema depends on the value of mimetype. These are the following supported values of mimetype along with their and the associated metadata object:

  • application/pdf:

    
        "metadata": {
            "size_bytes" : 97030,
            "num_pages": 2,
            "date_created": "2013-03-20",
            "last_modified" "2013-06-01"
        }
        
  • text/csv:

    
        "metadata": {
            "size_bytes" : 97030,
            "date_created": "2013-03-20",
            "last_modified" "2013-06-01"
        }
        
  • image/gif, image/jpeg, image/png:

    
        "metadata": {
            "width": 90,
            "height": 125
        }
        

ComplianceDocument.subtypes

The subtypes attribute attached to ComplianceDocument instances contains a JSON array of classifications for the document. These are the possible values:

  • "rohs_statement"
  • "reach_statement"
  • "materials_sheet"
  • "conflict_mineral_statement"

Part.specs

The specs attribute attached to Part instances is a JSON object mapping attribute keys (e.g. "voltage_rating_dc") to SpecValue instances.

It's important to note that all value properties of SpecValue objects are JSON arrays. The reason for this is to accomodate multi-valued attributes such as power supplies with multiple output voltages:

  
    "specs": {
        "case_package": {
            "__class__": "SpecValue",
            "value": ["0806"],
            "min_value": null,
            "max_value": null,
            "metadata": {
                "key": "case_package",
                "name": "Case/Package",
                "type": "qualitative",
                "unit": null
                },
            "attribution": {
                "__class__": "Attribution",
                "sources": [
                    {
                        "__class__": "Source",
                        "uid": "4a258f2f6a2199e2",
                        "name": "Newark"
                    }
                ],
                "first_acquired": "2012-04-22T10:18:00Z"
            }
        },
        "capacitance": {
            "__class__": "SpecValue",
            "value": ["10.0"],
            "min_value": null,
            "max_value": null,
            "metadata": {
                "key": "capacitance",
                "name": "Capacitance",
                "type": "quantitative",
                "unit": {
                    "__class__": "UnitOfMeasurement",
                    "name": "Microfarads",
                    "symbol": "μF"
                },
            "attribution": {
                "__class__": "Attribution",
                "sources": [
                    {
                        "__class__": "Source",
                        "uid": "4a258f2f6a2199e2",
                        "name": "Newark"
                    }
                ],
                "first_acquired": "2013-01-16T22:10:00Z"
            }
        }
    }
  

PartOffer.prices

The prices attribute attached to PartOffer instances is a JSON object mapping currencies to a JSON array of (Break, Price) tuples:

  
    "prices": {
        "USD": [
            [1, "1.99000"],
            [100, "1.89000"],
            [1000, "1.40500"]
        ],
        "EUR": [
            [1, "1.53000"],
            [100, "1.45000"],
            [1000, "1.08350"]
        ]
    }
  

Note that prices are decimal types with a precision of 5 and are encoded in JSON as strings. In order to perform a mathematical operation on a price you will have to convert it to a native numeric type in your language.

PartOffer.in_stock_quantity

The in_stock_quantity attribute attached to PartOffer objects indicates the number of parts the seller has in stock ready for shipment. Negative numbers are used to indicate the following conditions:

  • -1: Non-stocked (seller is not currently stocking the product)
  • -2: Yes (seller has the product in stock but has not reported the quantity)
  • -3: Unknown (seller has not indicated whether or not they have parts in stock)
  • -4: RFQ

PartOffer.order_multiple

The order_multiple attribute attached to PartOffer objects indicates the quantity multiple of the offer. For example, if order_multiple is 100, then the seller will only sell product in quantities of 100, 200, 300, 400, etc.

PartOffer.packaging

The packaging attribute attached to PartOffer objects indicates the physical packaging that the product is offered in. These are the most common values for the packaging attribute:

Value Description
"Ammo" Continuous strip of cut tape
"Ammo Pack"
"Bag"
"Box"
"Bulk" Individual components packaged in a bag
"Cut Tape" On a tape cut off from a reel
"Custom Reel" Custom quantity tape in reel format
"Kit
"Magazine"
"Rail"
"Tape & Box"
"Tape & Reel" On a tape wound around a reel directly from manufacturer
"Tape & Reel (7 in.)" Standard reel with 7 inch diameter
"Tape & Reel (13 in.)" Standard reel with 13 inch diameter
"Tray" Physically separated on a tray
"Tube" Line of components in plastic tube
"Spool"
"Strip"
"Waffle"

PartOffer.is_authorized

The is_authorized attribute attached to PartOffer objects indicates whether or not the seller is authorized by the manufacturer to sell the product.

If the manufacturer has provided us with a list of authorized sellers we use that list exlusively to indicate the authorized status of the offer. Otherwise, we use the seller's ECIA (Electronic Components Industry Association) membership to indicate whether or not the offer is authorized.

If a seller is not a member of the ECIA they must provide us with evidence of authorization in order for their offers to be listed as authorized.

Part Number Filters

To assist developers trying to do partial part number matches, the mpn, sku, and mpn_or_sku filter arguments to the parts/match endpoint accepts wildcards.

There are two types of wildcards, asterisks ('*') and question marks ('?'). Asterisks will match any number of characters while questions marks will match exactly one character. To escape an asterisk or a question mark in a part number you can use the backslash character (e.g. "\*").

Wildcards can be used anywhere within as well as before and after a part number. There is no limit to the number of wildcards that can be used but there must be at least three characters present in the query e.g. ("S*7*N").

Talk to Us!

Questions? Feedback?
Leave us a note and we will respond ASAP.

Thanks! We'll get back to you.