Query Match to restriction result from Digi-key by Python

181 views
Skip to first unread message

ligi Chen

unread,
Feb 3, 2016, 10:19:15 AM2/3/16
to Octopart API
Hi Experts,

Basically, I follow the tutorial : https://octopart.com/api/docs/v3/bom-quickstart to build my own script, but one thing that I want to do different is that I specifically want to restrict my search result to Digi-key.

Therefore, I thought I should add 'seller' : 'Digi-key' as one of the search criteria.

    queries.append({'mpn_or_sku': line_item['Part Number'],
                    'reference': len(line_items) - 1,
                    'seller': 'Digi-Key',
                    'limit' : 1})

However, it doesn't work at all. When I look into the response and result, the seller information is still "Null"

Anyone has come across this issue before?

Thanks,
Frank

andres

unread,
Feb 3, 2016, 10:39:10 AM2/3/16
to Octopart API
Hi Frank,

Hmm... that's strange. The value of offers.seller should never be null. Can you provide an example request where the seller is null?

Andres

ligi Chen

unread,
Feb 4, 2016, 6:03:35 AM2/4/16
to Octopart API
Hi Andres,

Yes, please see the attachment for the sample code I used. It is built on python version 2.7.11

Thanks,
Frank
BoM-Matching_CSV_Loop.py

Andres Morey

unread,
Feb 4, 2016, 6:28:45 PM2/4/16
to octopa...@googlegroups.com
Hi Frank,

I can see the code but it pulls queries from the file 1234.csv which isn't attached. It looks like you are using the /parts/match endpoint with the 'mpn_or_sku' argument. Can you send me the 'mpn_or_sku' value which is returning a null seller?

Thanks,

Andres


--

---
You received this message because you are subscribed to the Google Groups "Octopart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to octopart-api...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ligi Chen

unread,
Feb 4, 2016, 10:27:04 PM2/4/16
to Octopart API
Hi Andres,

The csv also attached. One thing I would like to clarify here is that it's not the return response that doesn't include the seller information but the request I send to the seller information is null, such as the following:
Kindly you can refer to the attached csv to run and test at your end. Thanks so much!

KeyboardInterrupt
>>> print data
{
    "__class__": "PartsMatchResponse",
    "msec": 58,
    "request": {
        "__class__": "PartsMatchRequest",
        "exact_only": false,
        "queries": [
            {
                "__class__": "PartsMatchQuery",
                "brand": null,
                "limit": 1,
                "mpn": null,
                "mpn_or_sku": "SN74AHC14PW",
                "q": "",
                "reference": 4,
                "seller": null,
                "sku": null,
                "start": 0
            }

Thanks,
Frank
1234.csv

ligi Chen

unread,
Feb 10, 2016, 12:27:25 PM2/10/16
to Octopart API
Hi Andres,

Sorry to bring this up again. But after reviewing my code, do you have any idea what might be the cause?

Thanks,
Frank
Reply all
Reply to author
Forward
0 new messages