How to use Octopart API

846 views
Skip to first unread message

helloworld

unread,
Mar 29, 2012, 2:41:55 AM3/29/12
to Octopart API
I am building an eCommerce website and was planning to use Octopart
API. I am kind of lost as from where to start implementation. I was
planing to at least extract one record and do something with it than
plan for dealing with all the results. Please if someone can put light
on it that will be great. Thank you in advance

andres

unread,
Mar 29, 2012, 9:02:45 AM3/29/12
to octopa...@googlegroups.com
Hi,

What language are you using to query the Octopart API? I've attached an example html file that uses jQuery to make a simple API request.

Andres
example.html

Ankur Kasliwal

unread,
Mar 29, 2012, 9:12:09 AM3/29/12
to octopa...@googlegroups.com
Hey,
       I am using JavaScript to do that and want response to come back in JSON form. So can you please provide an example accordingly. Also attached document is not getting opened.
--
Sincerely,

Ankur Kasliwal
MS in CS, Northeastern University

andres

unread,
Mar 29, 2012, 9:19:05 AM3/29/12
to octopa...@googlegroups.com
Hi Ankur,

The API returns all responses in JSON format. Here is the example document available at a publicly accessible url:

Please let me know how else I can help!

Andres

Ankur Kasliwal

unread,
Mar 29, 2012, 9:24:41 AM3/29/12
to octopa...@googlegroups.com
Hi Thank you for replying but I am still not able to open that link. All responses in JSON that is great but to send response the code which i need to write will be in JavaScript right and also one more thing can you also provide the hierarchy structure in which result will come that is root element with all child elements contain in it and so on.

Regards,
Ankur

Andres Morey

unread,
Mar 29, 2012, 9:33:34 AM3/29/12
to octopa...@googlegroups.com
Hi Ankur,

Why can't you open the link? If you click on the link it should result in a JavaScript alert that says "66464", which is the number of hits in the example query.

To view the source code of the example, just look at the HTML source of that url.

Here is the schema for the response object:

If you want to loop through the results and print the manufacturer/mpn you can do this:

$.each(response.results, function(i, result){
    alert(result.item.manufacturer.displayname + ' ' + result.item.mpn);
});

Andres

ankur.ka...@gmail.com

unread,
Mar 29, 2012, 9:35:10 AM3/29/12
to octopa...@googlegroups.com
Thank you for the help will try doing that if some problem occurs will ask for help.
From: Andres Morey <and...@octopart.com>
Date: Thu, 29 Mar 2012 09:33:34 -0400
Subject: Re: [octopart-api] Re: How to use Octopart API

Ankur Kasliwal

unread,
Mar 30, 2012, 3:57:21 PM3/30/12
to octopa...@googlegroups.com
Hey,
       I don't know why but this is not working for me. Can you please help.

Andres Morey

unread,
Mar 30, 2012, 3:59:39 PM3/30/12
to octopa...@googlegroups.com
Can you explain what isn't working? If you take me through the process of what you are doing and what you are expecting then I can help you.

Andres

Ankur Kasliwal

unread,
Mar 30, 2012, 4:06:55 PM3/30/12
to octopa...@googlegroups.com
Hey,
       I am building an eCommerce website for learning purpose and like the JSON response your API gives. But I am not able to understand how to use your API because I used this method to send request

       $.ajax({
                    url: requestURL,
                    dataType: "jsonp",
                    success: processSearchResult
                }); .
It is working for other API which I had tried but not for yours so please can you help.

Andres Morey

unread,
Mar 30, 2012, 4:08:52 PM3/30/12
to octopa...@googlegroups.com
Try this:

$.getJSON(requestURL,
                 {},
                 processSearchResult);

Andres

Ankur Kasliwal

unread,
Mar 30, 2012, 4:10:25 PM3/30/12
to octopa...@googlegroups.com
I will try doing that
Reply all
Reply to author
Forward
0 new messages