Looking for our new API? Get started for free here.

Nexar
API

Overview


Getting Started

As of March 31, 2022 Octopart APIv3 will no longer be supported. As of June 30, 2022 this version will be completely disabled.

Octopart APIv3 and Nexar Legacy API are the easiest way for developers to access up-to-date pricing and availability information, datasheets, compliance documents and technical specs for electronic components from distributors and manufacturers around the world.

Using APIv3 and Nexar Legacy API, you can access stocking information, price breaks, lead times, minimum order quantities and much more information from over 100 distributors including Digi-Key, Mouser, Newark, Premier Farnell, Arrow, RS Components, Future Electronics, Grainger and many others. You can also access millions of datasheets and compliance documents for parts from over 4000 manufacturers.

Authentication

APIv3 does not require any usernames or passwords to use, however it does require a valid API key for every request. Register for your Nexar Legacy API key today.

To validate requests, simply pass your API key as a URL argument:

https://octopart.com/api/v3/parts/103cdb613d20cffb?apikey=EXAMPLE_KEY&pretty_print=true

How to Use

APIv3 and Nexar Legacy API REST are a REST API's that can be accessed by sending HTTP requests to the proper API endpoint from any programming language with HTTP support.

Since each endpoint is a url on the web you can access data from the API by using a command line program like curl, a programming language like Python or Ruby, or even by viewing the url in your browser.

For example, to search for a part by its mpn you can send a request to the /v3/parts/match endpoint:

https://octopart.com/api/v3/parts/match?apikey=EXAMPLE_KEY&queries=[{"mpn":"SN74S74N"}]&pretty_print=true

  • $ curl -G http://octopart.com/api/v3/parts/match \
       -d queries="[{\"mpn\":\"SN74S74N\"}]" \
       -d apikey=EXAMPLE_KEY \
       -d pretty_print=true
    
  • import json
    import urllib
    
    url = 'http://octopart.com/api/v3/parts/match?'
    url += '&queries=[{"mpn":"SN74S74N"}]'
    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']:
        for item in result['items']:
            print item['mpn']
    
  • require 'rubygems'
    require 'json'
    require 'net/http'
    
    url = 'http://octopart.com/api/v3/parts/match?'
    url += '&queries=' + URI.encode(JSON.generate([{:mpn => 'SN74S74N'}]))
    url += '&apikey=REPLACE_ME'
    
    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|
      result['items'].each do |part|
        puts part['mpn']
      end
    end
    
  • <script src="http://code.jquery.com/jquery-1.11.0.js"></script>
    <script>
        var url = 'http://octopart.com/api/v3/parts/match?';
        url += '&queries=[{"mpn":"SN74S74N"}]';
        url += '&apikey=REPLACE_ME';
        url += '&callback=?';
    
        $.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 HowToUse
        {
            public static void ExecuteSearch()
            {
                // -- your search query --
                var query = new List<dynamic>()
                {
                    new Dictionary<string, string>()
                    { { "mpn", "SN74S74N" } }
                };
    
                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"])
                {
                    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 HowToUse
        Public Sub ExecuteSearch()
            ' -- your search query --
            Dim query = New List(Of Dictionary(Of String, String))() From _
            { _
                New Dictionary(Of String, String)() From _
                {{"mpn", "SN74S74N"}} _
            }
    
            Dim octopartUrlBase As String = "http://octopart.com/api/v3"
            Dim octopartUrlEndpoint As String = "parts/match"
            Dim apiKey As String = HowToUse.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")
                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
    

Rate Limit

To maintain performance of the API there is a rate limit of 3 HTTP requests/second per IP address. If your application requires a higher rate limit please email us to inquire about volume pricing and service level agreements (support@nexar.com).

Parts and Offers

The Octopart database is organized in terms of unique physical parts. All distributor offers are grouped together by their corresponding physical part. Here is an example of a part object:

  
For a more detailed explanation of the object schemas, please see the Objects section of the REST API Reference Documentation.

Cross Domain Requests

APIv3 supports JSONP, which can be used by passing a callback parameter in the query string of the URL you are requesting.

  • <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': 'SN74LS245N'},
            {'mpn': '08055C104KAT2A'}
        ];
    
        var args = {
            queries: JSON.stringify(queries)
        };
    
        $.getJSON(url, args, function(response) {
            $.each(response, function(i, data) {
                console.log(data);
            });
        });
    </script>
    

HTTP Status Codes

REST APIv3 and Nexar Legacy API REST utilize the full range of HTTP/1.1 status codes. These are some common HTTP responses and their likely causes:

HTTP Status Likely cause
200 OK Your request was completed successfully
400 Bad Request Your request is missing an 'apikey' argument
403 Forbidden Your apikey is invalid
404 Not Found The resource you are accessing doesn't exist
429 Too Many Requests You have been blocked by the rate limiter
500 Internal Server Error Something went wrong server-side and we've been notified about the problem. In many cases, there was a problem with your request which wasn't handled properly by the server.
502 Bad Gateway Our app servers have crashed. This error happens extremely rarely. If you encounter it repeatedly please notify us ASAP.
503 Service Unavailable The service is down for maintenance and will be restored ASAP

Search

There are two basic ways to search for parts: BOM Matching and Parametric Search. The BOM matching interface allows developers to match parts by MPN or SKU while the parametric search interface allows searches by keywords, categories, specs, manufacturer and more. Although you can also use the parametric search interface to search for parts by part number, the BOM matching interface provides extra functionality such as the ability to search for up to 20 part numbers simultaneously.

BOM Matching

Using the "parts/match" method you can search for parts by manufacturer part number (mpn) or distributor part number (sku) and even limit your results to a particular manufacturer or distributor. You can also make up to 20 queries simultaneously which makes it very easy to do BOM matching:

  • 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
    

For a more detailed explanation of the "parts/match" method please see the parts/match section of the REST API Reference documentation. For a tutorial on how to parse a BOM, check out our BOM Quickstart.

Parametric Search

Using the "parts/search" method you can search for parts by keyword, manufacturer, category, part number or technical specs. You can also use the "parts/search" method to perform ranged searches on numeric attributes. Here's an example of how to search for parts by keyword:

  • 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
    

For a more detailed explanation of the "parts/match" method please see the parts/search section of the REST API Reference documentation. For a tutorial on how to use the search endpoint, check out our Search Tutorial.


Data

APIv3 and Nexar Legacy API REST give you access to Octopart's entire database of electronic part data. Pricing and availability data is included by default but all other types of data must be added to the request. The following is an overview of the different data types included in the API.

Pricing and Availability

Using APIv3 and Nexar Legacy API REST, you can access stocking information, price breaks, lead times, minimum order quantities and much more information from over 100 stocking distributors including Digi-Key, Mouser, Newark, Premier Farnell, Arrow, RS Components, Future Electronics, Grainger and many others. All of our pricing and availability data is included by default in every API response:

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

  
For a more detailed explanation of the properties available for each offer, please see the PartOffer schema section of the REST API Reference Documentation.

Datasheets

For performance reasons, datasheets are not included in API responses by default. To include datasheets 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

When a datasheet is available it will be attached to the part object it belongs to. Here is the result of the API request described above:

  

For more information on using the include url argument check out the Include Directives documentation.

Compliance Documents

For performance reasons, compliance documents are not included in API responses by default. To include compliance documents 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[]=compliance_documents

When a compliance document is available it will be attached to the part object it belongs to. Here is the result of the API request described above:

  

For more information on using the include url argument check out the Include Directives documentation.

3D Models

For perfomance reasons, 3D Models are not included in the API responses by default. To include 3D Models resources 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[]=cad_models

When a 3D Model is available it will be attached to the part object it belongs to. Here is the result of the API request described above:

  

For more information on using the include url argument check out the Include Directives documentation.

Descriptions

For performance reasons, part descriptions are not included in API responses by default. To include part descriptions 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[]=descriptions

When a description is available it will be attached to the part object it belongs to. Here is the result of the API request described above:

  

Technical Specs

For perfomance reasons, technical specs are not included in API responses by default. To include technical specs 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[]=specs

The technical spec values that are available for each part will be attached to the part object they belong to. Here is the result of the API request described above:

  
For a more detailed explanation of the specs property, please see the Notes: Parts.specs section of the REST API Reference Documentation.

Lifecycle Status

APIv3 and Nexar Legacy API REST return lifecycle status (e.g. "Active", "Obsolete") as part of the technical specs JSON object. To see a component's lifecycle status simply use the include url argument to add specs to the response:

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

And look for the lifecycle_status property in the specs 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 += "&include[]=specs"
    
    # NOTE: Use your API key here (https://octopart.com/api/register)
    url += '&apikey=REPLACE_ME'
    
    data = urllib.urlopen(url).read()
    response = json.loads(data)
    
    # print request time (in milliseconds)
    print "Response time: %s msec\n" % response['msec']
    
    # print mpn's
    for result in response['results']:
        print "Reference: %s" % result['reference']
        for item in result['items']:
            # get lifecycle status
            if 'lifecycle_status' in item['specs']:
                lifecycle_status = item['specs']['lifecycle_status']['value'][0]
            else:
                lifecycle_status = 'Unknown'
    
            brand_name = item['brand']['name']
            mpn = item['mpn']
            print "\t%s %s: %s" % (brand_name, mpn, lifecycle_status)
    
  • require 'rubygems'
    require 'json'
    require 'net/http'
    
    url = "http://octopart.com/api/v3/parts/match"
    url += "?include[]=specs"
    
    # NOTE: Use your API key here (https://octopart.com/api/register)
    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 "Response time: " + server_response['msec'].to_s() + " msec\n\n"
    
    # print mpn's
    server_response['results'].each do |result|
      puts "Reference: " + result['reference']
      result['items'].each do |part|
        if part['specs'].has_key?('lifecycle_status')
            lifecycle_status = part['specs']['lifecycle_status']['value'][0]
        else
            lifecycle_status = 'Unknown'
        end
    
        puts "\t" + part['brand']['name'] + part['mpn'] + ': ' + lifecycle_status
      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 += "?callback=?";
      url+= "&include[]=specs";
    
      // NOTE: Use your API key here (https://octopart.com/api/register)
      url += "&apikey=REPLACE_ME";
    
      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);
          
          $.each(response['results'][i]['items'], function(j, part) {
            var lifecycle_status;
            
            if (part.specs.lifecycle_status) {
              lifecycle_status = part.specs.lifecycle_status.value[0];
            } else {
              lifecycle_status = 'Unknown';
            }
            
            var s = "\t" + part['brand']['name'] + " " + part['mpn'];
            s += ": " + lifecycle_status;
            console.log(s);
          });
        });
      });
    </script>
    
  • namespace OctopartApi
    {
        using Newtonsoft.Json;
        using RestSharp;
        using System;
        using System.Collections.Generic;
        using System.Web.Script.Serialization;
    
        public static class LifeCycleStatus
        {
            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)
                            .AddParameter("include[]", "specs");
    
                // Perform the search and obtain results
                var data = client.Execute(req).Content;
                var response = JsonConvert.DeserializeObject<dynamic>(data);
    
                // Print mpn's
                foreach (var result in response["results"])
                {
                    Console.WriteLine("Reference: " + result["reference"]);
                    foreach (var item in result["items"])
                    {
                        // get lifecycle status
                        var lifecycle_status = "unknown";
                        if (item["specs"].Property("lifecycle_status") != null)
                            lifecycle_status = item["specs"]["lifecycle_status"]["value"][0];
                        var brand_name = item["brand"]["name"];
                        var mpn = item["mpn"];
                        Console.WriteLine(String.Format("\t{0} {1}: {2}", brand_name, mpn, lifecycle_status));
                    }
                }
            }
    
            // -- 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 LifeCycleStatus
    
        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 = LifeCycleStatus.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) _
                            .AddParameter("include[]", "specs")
    
            ' Perform the search and obtain results
            Dim data = client.Execute(req).Content
            Dim response = JsonConvert.DeserializeObject(data)
    
            ' Print mpn's
            For Each result In response("results")
                Console.WriteLine("Reference: " & result("reference"))
                For Each item In result("items")
                    ' get lifecycle status
                    Dim lifecycle_status As String = "unknown"
                    If (Not item("specs").Property("lifecycle_status") Is Nothing) Then
                        lifecycle_status = item("specs")("lifecycle_status")("value")(0)
                    End If
                    Dim brand_name = item("brand")("name")
                    Dim mpn = item("mpn")
                    Console.WriteLine(String.Format(vbTab & "0 1: 2", brand_name, mpn, lifecycle_status))
                Next
            Next
        End Sub
    
        ' -- your API key -- (https:'octopart.com/api/register)
        Private Const APIKEY As String = "REPLACE_ME"
    End Module
    

For a more detailed explanation of the specs property, please see the Notes: Parts.specs section of the REST API Reference Documentation.

Images

For perfomance reasons, part images are not included in API responses by default. To include part images 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[]=imagesets

When an image is available it will be attached to the part object it belongs to. Here is the result of the API request described above:

  

Categories

For performance reasons, the category uids that a part belongs to are not included in API responses by default. To include part category uids 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[]=category_uids

When a category mapping is available, the uid of the category will be attached to the part object it belongs to. Here is the result of the API request described above:

  

Reference Designs

For performance reasons, reference designs are not included in the API responses by default. To include part reference designs 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[]=reference_designs

When a reference design is available it will be attached to the part object it belongs to. Here is the result of the API request described above:

  

Data Coverage

For a deeper dive into API data coverage please view our Data Coverage page:


Tutorials

To dive deeper into the API try out these tutorials:


Client Libraries

For convenience here are some pre-built libraries for interacting with APIv3 and Nexar Legacy API REST:


Reference Documentation

For API object schemas and complete endpoint documentation please view our REST API Reference Documentation: