Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LCSC Info Provider using their public API #526

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

meganukebmp
Copy link
Contributor

Recently at the lab I work at, we needed an inventory management system. PartDB fit that role very nicely, great software btw. However a lot of our components for the various projects we work on came from the LCSC supplier. As such we had to find them on the other info suppliers manually and it was taking a lot of time. Our current workflow involves scanning the product tag with a barcode scanner and obtaining the vendor-supplied product id from there and plugging it into the info supplier search. LCSC has some components that we couldn't find in the other suppliers and also would have taken too long to manually import the thousands of parts we needed, as such we took the effort to implement LCSC's public API.

This API is used by the current LCSC frontend (javascript) to query their backend and then populate the UI. As it currently stands their official javascript frontend makes MORE API calls per search (it does a call for every character entered into the searchbox) than this PartDB implementation.

Currently all data fields are obtainable from LCSC except for part availability (if it's discontinued or whatnot) since LCSC does not provide this information on their storefront either. This includes pictures, datasheets, footprints, parameters and more.

Both plaintext and LCSC product numbers are supported.

Examples:
image
image
image
image

@jbtronics
Copy link
Member

Thank you. I will try it out later. But seems good from a first glimpse.

However I will add some configuration option, to enable/disable this provider, so that administrators can choose which part providers they wanna use.

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

Attention: 98 lines in your changes are missing coverage. Please review.

Comparison is base (49034fa) 60.25% compared to head (e3e562a) 59.95%.

Files Patch % Lines
...ices/InfoProviderSystem/Providers/LCSCProvider.php 16.94% 98 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #526      +/-   ##
============================================
- Coverage     60.25%   59.95%   -0.31%     
- Complexity     5337     5365      +28     
============================================
  Files           494      495       +1     
  Lines         17843    17961     +118     
============================================
+ Hits          10752    10769      +17     
- Misses         7091     7192     +101     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jbtronics jbtronics merged commit e3e562a into Part-DB:master Feb 22, 2024
9 of 10 checks passed
@jbtronics
Copy link
Member

I have added this configuration possibility and improved the parameter parsing, so that values like 4V~6V get parsed as filterable numeric range instead of a simple text value.

@jbtronics
Copy link
Member

I have also implemented a possibility to configure the currency to retrieve the price informations from LCSC in (possible via passing a cookie value).

Whats not fully clear is the discount value and whether it should be used for final price calculations. The online shop shows lower prices then the productPrice field from the API. The real value can be calculated using the given discount value.

Im not sure if these discounts are permenant and part of a marketing strategy or just temporary. In the first case it might be a good idea, to use the discounted value as price info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants