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.
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:
importjsonimporturlliburl='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)printresponse['msec']# print mpn'sforresultinresponse['results']:foriteminresult['items']:printitem['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)putsserver_response['msec']# print mpn'sserver_response['results'].eachdo|result|result['items'].eachdo|part|putspart['mpn']endend
namespaceOctopartApi{usingNewtonsoft.Json;usingRestSharp;usingSystem;usingSystem.Collections.Generic;usingSystem.Web.Script.Serialization;publicstaticclassHowToUse{publicstaticvoidExecuteSearch(){// -- your search query --varquery=newList<dynamic>(){newDictionary<string,string>(){{"mpn","SN74S74N"}}};stringoctopartUrlBase="http://octopart.com/api/v3";stringoctopartUrlEndpoint="parts/match";stringapiKey=APIKEY;// Create the search requeststringqueryString=(newJavaScriptSerializer()).Serialize(query);varclient=newRestClient(octopartUrlBase);varreq=newRestRequest(octopartUrlEndpoint,Method.GET).AddParameter("apikey",apiKey).AddParameter("queries",queryString);// Perform the search and obtain resultsvardata=client.Execute(req).Content;varresponse=JsonConvert.DeserializeObject<dynamic>(data);// Print request time (in milliseconds)Console.WriteLine(response["msec"]);// Print mpn'sforeach(varresultinresponse["results"]){foreach(variteminresult["items"]){Console.WriteLine(item["mpn"]);}}}// -- your API key -- (https://octopart.com/api/register)privateconststringAPIKEY="REPLACE_ME";}}
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.
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:
importjsonimporturllibqueries=[{'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)printresponse['msec']# print mpn'sforresultinresponse['results']:print"Reference: %s"%result['reference']foriteminresult['items']:printitem['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)putsserver_response['msec']# print mpn'sserver_response['results'].eachdo|result|puts"Reference: "+result['reference']result['items'].eachdo|part|putspart['mpn']endend
namespaceOctopartApi{usingNewtonsoft.Json;usingRestSharp;usingSystem;usingSystem.Collections.Generic;usingSystem.Web.Script.Serialization;publicstaticclassPartsMatch{publicstaticvoidExecuteSearch(){// -- your search query --varquery=newList<dynamic>(){newDictionary<string,string>(){{"mpn","SN74S74N"},{"reference","line1"}},newDictionary<string,string>(){{"sku","67K1122"},{"reference","line2"}},newDictionary<string,string>(){{"mpn_or_sku","SN74S74N"},{"reference","line3"}},newDictionary<string,string>(){{"brand","Texas Instruments"},{"mpn","SN74S74N"},{"reference","line4"}}};stringoctopartUrlBase="http://octopart.com/api/v3";stringoctopartUrlEndpoint="parts/match";stringapiKey=APIKEY;// Create the search requeststringqueryString=(newJavaScriptSerializer()).Serialize(query);varclient=newRestClient(octopartUrlBase);varreq=newRestRequest(octopartUrlEndpoint,Method.GET).AddParameter("apikey",apiKey).AddParameter("queries",queryString);// Perform the search and obtain resultsvardata=client.Execute(req).Content;varresponse=JsonConvert.DeserializeObject<dynamic>(data);// Print request time (in milliseconds)Console.WriteLine(response["msec"]);// Print mpn'sforeach(varresultinresponse["results"]){Console.WriteLine("Reference: "+result["reference"]);foreach(variteminresult["items"]){Console.WriteLine(item["mpn"]);}}}// -- your API key -- (https://octopart.com/api/register)privateconststringAPIKEY="REPLACE_ME";}}
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:
importjsonimporturlliburl="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 hitsprintsearch_response['hits']# print resultsforresultinsearch_response['results']:part=result['item']# print matched partprint"%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"defto_query(hsh)hsh.map{|k,v|"#{k}=#{URI.encode(v.to_s)}"}.join("&")endparams={: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 hitsputssearch_response['hits']# print resultssearch_response['results'].eachdo|result|part=result['item']# print matched partputspart['brand']['name']+' - '+part['mpn']end
<script src="http://code.jquery.com/jquery-1.11.0.js"></script><script>varurl="http://octopart.com/api/v3/parts/search";url+="?callback=?";// NOTE: Use your API key here (https://octopart.com/api/register)url+="&apikey=REPLACE_ME";varargs={q:"solid state relay",start:0,limit:10};$.getJSON(url,args,function(search_response){// print original requestconsole.log(search_response['request']);// iterate through results$.each(search_response['results'],function(i,result){varpart=result['item'];// print matched part itemsconsole.log(part['brand']['name']+' - '+part['mpn']);});});</script>
namespaceOctopartApi{usingNewtonsoft.Json;usingRestSharp;usingSystem;publicstaticclassPartsSearch{publicstaticvoidExecuteSearch(){// -- your search query --stringquery="solid state relay";stringoctopartUrlBase="http://octopart.com/api/v3";stringoctopartUrlEndpoint="parts/search";stringapiKey=APIKEY;// Create the search requestvarclient=newRestClient(octopartUrlBase);varreq=newRestRequest(octopartUrlEndpoint,Method.GET).AddParameter("apikey",apiKey).AddParameter("q",query).AddParameter("start","0").AddParameter("limit","10");// Perform the search and obtain resultsvardata=client.Execute(req).Content;varsearch_response=JsonConvert.DeserializeObject<dynamic>(data);// Print number of hitsConsole.WriteLine(search_response["hits"]);// Print resultsforeach(varresultinsearch_response["results"]){varpart=result["item"];// Print matched partConsole.WriteLine(part["brand"]["name"]+" - "+part["mpn"]);}}// -- your API key -- (https://octopart.com/api/register)privateconststringAPIKEY="REPLACE_ME";}}
ImportsNewtonsoft.JsonImportsRestSharpImportsSystemPublicModulePartsSearchPublicSubExecuteSearch()' -- your search query --DimqueryAsString="solid state relay"DimoctopartUrlBaseAsString="http://octopart.com/api/v3"DimoctopartUrlEndpointAsString="parts/search"DimapiKeyAsString=PartsSearch.APIKEY' Create the search requestDimclient=NewRestClient(octopartUrlBase)Dimreq=NewRestRequest(octopartUrlEndpoint,Method.GET) _
.AddParameter("apikey",apiKey) _
.AddParameter("q",query) _
.AddParameter("start","0") _
.AddParameter("limit","10")' Perform the search and obtain resultsDimdata=client.Execute(req).ContentDimsearch_response=JsonConvert.DeserializeObject(data)' Print number of hitsConsole.WriteLine(search_response("hits"))' Print resultsForEachresultInsearch_response("results")Dimpart=result("item")' Print matched partConsole.WriteLine(part("brand")("name")&" - "&part("mpn"))NextEndSub' -- your API key -- (https:'octopart.com/api/register)PrivateConstAPIKEYAsString="REPLACE_ME"EndModule
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:
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:
For performance reasons, compliance documents are not included in API responses by default. To include compliance documents you can use the include url argument:
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:
For performance reasons, part descriptions are not included in API responses by default. To include part descriptions you can use the include url argument:
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:
And look for the lifecycle_status property in the specs object:
importjsonimporturllibqueries=[{'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'sforresultinresponse['results']:print"Reference: %s"%result['reference']foriteminresult['items']:# get lifecycle statusif'lifecycle_status'initem['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'sserver_response['results'].eachdo|result|puts"Reference: "+result['reference']result['items'].eachdo|part|ifpart['specs'].has_key?('lifecycle_status')lifecycle_status=part['specs']['lifecycle_status']['value'][0]elselifecycle_status='Unknown'endputs"\t"+part['brand']['name']+part['mpn']+': '+lifecycle_statusendend
<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>varurl="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";varqueries=[{'mpn':'SN74S74N','reference':'line1'},{'sku':'67K1122','reference':'line2'},{'mpn_or_sku':'SN74S74N','reference':'line3'},{'mpn':'SN74S74N','brand':'Texas Instruments','reference':'line4'}];varargs={queries:JSON.stringify(queries)};$.getJSON(url,args,function(response){varqueries=response['request']['queries'];$.each(queries,function(i,query){// print queryconsole.log(query);$.each(response['results'][i]['items'],function(j,part){varlifecycle_status;if(part.specs.lifecycle_status){lifecycle_status=part.specs.lifecycle_status.value[0];}else{lifecycle_status='Unknown';}vars="\t"+part['brand']['name']+" "+part['mpn'];s+=": "+lifecycle_status;console.log(s);});});});</script>
namespaceOctopartApi{usingNewtonsoft.Json;usingRestSharp;usingSystem;usingSystem.Collections.Generic;usingSystem.Web.Script.Serialization;publicstaticclassLifeCycleStatus{publicstaticvoidExecuteSearch(){// -- your search query --varquery=newList<dynamic>(){newDictionary<string,string>(){{"mpn","SN74S74N"},{"reference","line1"}},newDictionary<string,string>(){{"sku","67K1122"},{"reference","line2"}},newDictionary<string,string>(){{"mpn_or_sku","SN74S74N"},{"reference","line3"}},newDictionary<string,string>(){{"brand","Texas Instruments"},{"mpn","SN74S74N"},{"reference","line4"}}};stringoctopartUrlBase="http://octopart.com/api/v3";stringoctopartUrlEndpoint="parts/match";stringapiKey=APIKEY;// Create the search requeststringqueryString=(newJavaScriptSerializer()).Serialize(query);varclient=newRestClient(octopartUrlBase);varreq=newRestRequest(octopartUrlEndpoint,Method.GET).AddParameter("apikey",apiKey).AddParameter("queries",queryString).AddParameter("include[]","specs");// Perform the search and obtain resultsvardata=client.Execute(req).Content;varresponse=JsonConvert.DeserializeObject<dynamic>(data);// Print mpn'sforeach(varresultinresponse["results"]){Console.WriteLine("Reference: "+result["reference"]);foreach(variteminresult["items"]){// get lifecycle statusvarlifecycle_status="unknown";if(item["specs"].Property("lifecycle_status")!=null)lifecycle_status=item["specs"]["lifecycle_status"]["value"][0];varbrand_name=item["brand"]["name"];varmpn=item["mpn"];Console.WriteLine(String.Format("\t{0} {1}: {2}",brand_name,mpn,lifecycle_status));}}}// -- your API key -- (https://octopart.com/api/register)privateconststringAPIKEY="REPLACE_ME";}}
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:
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: