Releases: KirianCaumes/Discogs-Marketplace-API-NodeJS
v1.7.0
DiscogsMarketplace
is no longer the default import fromdiscogs-marketplace-api-nodejs
. You can now import viaimport { DiscogsMarketplace } from 'discogs-marketplace-api-nodejs'
. This is a voluntary change (which I would have preferred to avoid) which, although counter-intuitive at first sight, allows easier use for projects not using a compiler like Babel or other. This is a long-discussed subject. Learn more: evanw/esbuild#1719 (comment)
v1.6.1
v1.6.0
- Removed Enumerations in favor of Union Types da49c36
- All the
Enumerations
have been removed in favor ofUnion Types
ECurrency
toCurrencyType
EFormatDescription
toFormatDescriptionType
EFormat
toFormatType
EFrom
toFromType
EGenre
toGenreType
ELang
toLangType
EMediaCondition
toConditionType
ESort
toSortType
EStyle
toStyleType
EType
toSearchTypeType
- All the
Interfaces
have been removed in favor ofTypes
IInput
toInputType
IYears
moved insideInputType
IOutputSuccess
toOutputSuccessType
IItem
moved insideOutputSuccessType
IOutputError
toOutputErrorType
See the updated examples in Readme if needed.
v1.5.2
IItem['from']
is nowIItem['country']
IItem['from']['countryName']
is nowIItem['country']['name']
IItem['from']['isoCountryName']
no longer existsIItem['from']['isoCountryCode']
is nowIItem['country']['code']
v1.5.1
- Fix ISO country code for Discogs Neutral Zone d7fa641
v1.5.0
- Going back to Axios instead of Playwright 1b0d774
Why going back to Axios?
I felt playwright might not be so fast after all for scrapring Discogs Marketplace data.
So, I deciced to run simples benchmarks to compare the speed of both Axios and Playwright in scraping Discogs.
Playwright
Script used
import { chromium as playwright } from 'playwright-chromium'
import UserAgent from 'user-agents'
import { appendFile, } from 'fs/promises'
let i = 0
while (i < 100) {
const startTime = performance.now()
const browser = await playwright.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] })
const browserContext = await browser.newContext({
userAgent: new UserAgent().toString(),
extraHTTPHeaders: {
'X-PJAX': 'true',
}
})
const browserPage = await browserContext.newPage()
await browserPage.route('**/*', route => (['stylesheet', 'image', 'media', 'font', 'script', 'texttrack', 'xhr', 'fetch', 'eventsource', 'websocket', 'manifest', 'other'].includes(route.request().resourceType()) ? route.abort() : route.continue()))
await browserPage.goto(
'https://www.discogs.com/sell/list?artist_id=244819&limit=250',
{ waitUntil: 'domcontentloaded' },
)
const data = await browserPage.evaluate(() => document.body?.outerHTML)
await browser.close()
const seconds = (performance.now() - startTime) / 1000
appendFile('./playwright.csv', seconds + ';' + data.split(' – ')[1].split(' ')[0].trim() + '\n')
await new Promise(resolve => setTimeout(resolve, 10000))
i++
}
Results
Time in seconds | Items found |
---|---|
2.8281213000006975 | 250 |
2.611003200000152 | 250 |
3.0781212000008673 | 250 |
2.607310800001025 | 250 |
2.5087123000007123 | 250 |
2.4988795999996363 | 250 |
2.5592793000005187 | 250 |
2.538930900000036 | 250 |
2.6876880999989807 | 250 |
2.769115800000727 | 250 |
2.6129470999985935 | 250 |
2.6213709000013767 | 250 |
2.7784430999998 | 250 |
2.4398559999987484 | 250 |
2.7510906999986617 | 250 |
2.6358964999988674 | 250 |
2.12591069999896 | 250 |
2.721387800000608 | 250 |
2.6945901999995114 | 250 |
2.7610843000002205 | 250 |
2.5013984000012277 | 250 |
2.5184021000005306 | 250 |
3.5409550000000745 | 250 |
2.430627999998629 | 250 |
2.3309579000007363 | 250 |
2.991063500000164 | 250 |
2.6285799000002443 | 250 |
2.47105189999938 | 250 |
2.6091964999996127 | 250 |
2.371077400000766 | 250 |
2.7387718000002206 | 250 |
2.9718466999996456 | 250 |
2.488381100000814 | 250 |
3.468860099999234 | 250 |
2.9008585000000893 | 250 |
2.8200613000001757 | 250 |
4.411006899999455 | 250 |
2.896196699999273 | 250 |
2.943042500000447 | 250 |
2.8721090000011027 | 250 |
2.6839635000005364 | 250 |
3.6356803999990226 | 250 |
3.2916871000006793 | 250 |
2.7893683000002056 | 250 |
2.5914793999996037 | 250 |
2.633349100001156 | 250 |
2.759259600000456 | 250 |
3.138656100001186 | 250 |
2.2509492999985814 | 250 |
2.72981780000031 | 250 |
2.191720499999821 | 250 |
2.758727300001308 | 250 |
3.720788200000301 | 250 |
2.801132400000468 | 250 |
2.4312095999997108 | 250 |
3.1909651000015438 | 250 |
2.749268899999559 | 250 |
2.869724700000137 | 250 |
3.0125439999997616 | 250 |
2.893207900000736 | 250 |
2.9083329000007363 | 250 |
3.831123900000006 | 250 |
2.9811385000012813 | 250 |
2.800856699999422 | 250 |
2.3108563999999316 | 250 |
2.5724037999995053 | 250 |
2.9297808999996633 | 250 |
2.7413737000003455 | 250 |
2.48878029999882 | 250 |
2.543326400000602 | 250 |
2.822659599998966 | 250 |
3.1445751999989153 | 250 |
2.971195100000128 | 250 |
2.632570799998939 | 250 |
2.817382199998945 | 250 |
2.435168400000781 | 250 |
2.4594431000016628 | 250 |
2.7104277999997137 | 250 |
2.951188000001013 | 250 |
3.008941399998963 | 250 |
3.1733924000002443 | 250 |
2.6011283999979495 | 250 |
3.221156599998474 | 250 |
2.6893564999997617 | 250 |
2.491585500001907 | 250 |
2.9116572999991477 | 250 |
Data collected with Axios
Script used
import axios from 'axios'
import UserAgent from 'user-agents'
import { appendFile, } from 'fs/promises'
let i = 0
while (i < 100) {
const startTime = performance.now()
const { data } = await axios.request({
url: 'https://www.discogs.com/sell/list?artist_id=244819&limit=250',
method: 'GET',
headers: {
'X-PJAX': 'true',
'User-Agent': new UserAgent().toString()
}
})
const seconds = (performance.now() - startTime) / 1000
appendFile('./axios.csv', seconds + ';' + data.split('– ')[1].split(' ')[0].trim() + '\n')
await new Promise(resolve => setTimeout(resolve, 10000))
i++
}
Results
Time in seconds | Items found |
---|---|
1.9066512000001967 | 250 |
1.998512499999255 | 250 |
2.379731000000611 | 250 |
2.2315949000008404 | 250 |
1.9258511999994516 | 250 |
2.4887839999999852 | 250 |
1.8522395999990404 | 250 |
1.6724539000000804 | 250 |
1.9503407000005246 | 250 |
2.0885287999995055 | 250 |
1.8969194000009448 | 250 |
1.8230587999988348 | 250 |
1.944128899998963 | 250 |
2.5177741000000387 | 250 |
1.4830501000005751 | 250 |
1.7304056000001728 | 250 |
1.8126294999998063 | 250 |
1.826300699999556 | 250 |
2.065066899999976 | 250 |
1.7623966000005602 | 250 |
2.392783399999142 | 250 |
1.7140494999997318 | 250 |
2.216130299998447 | 250 |
1.6735784999988974 | 250 |
2.096677300000563 | 250 |
1.9434116999991238 | 250 |
1.7624712000004947 | 250 |
2.1195131000000984 | 250 |
2.037354000000283 | 250 |
1.730019099999219 | 250 |
1.936639000000432 | 250 |
2.383682400001213 | 250 |
1.9091585000008344 | 250 |
1.693759600000456 | 250 |
1.7196654000002891 | 250 |
1.7422665999997407 | 250 |
2.294841199999675 | 250 |
1.8551716999989003 | 250 |
1.8695205999985338 | 250 |
1.916570900000632 | 250 |
1.825472900001332 | 250 |
2.136837799999863 | 250 |
2.6654023000001907 | 250 |
1.8740196000002325 | 250 |
2.1952791000008585 | 250 |
2.1193407000005244 | 250 |
1.8990168000012637 | 250 |
1.9507324000000954 | 250 |
1.628954399999231 | 250 |
2.0669475999996068 | 250 |
2.3613967000003906 | 250 |
2.20930169999972 | 250 |
2.021106100000441 | 250 |
1.5540830000005663 | 250 |
1.6791168999988586 | 250 |
1.7234141000006349 | 250 |
1.6065229000002146 | 250 |
1.4762700000014155 | 250 |
1.5473063999991863 | 250 |
1.8109605000000446 | 250 |
1.6033116999994963 | 250 |
1.9459402999989688 | 250 |
1.8405577000007034 | 250 |
1.640109300000593 | 250 |
1.8360155999995769 | 250 |
1.9551256000008435 | 250 |
2.207307600000873 | 250 |
1.9402102000005543 | 250 |
1.9434799000006169 | 250 |
2.1252729000002146 | 250 |
2.132797900000587 | 250 |
1.8620335000008346 | 250 |
1.7930312000010162 | 250 |
2.060403800001368 | 250 |
1.7157765999995171 | 250 |
1.9124442999996245 | 250 |
1.7509218999985605 | 250 |
1.9331002999991178 | 250 |
1.8458307000007481 | 250 |
1.9350213999990373 | 250 |
1.6717009999994188 | 250 |
2.1286761999987065 | 250 |
1.7032938000001012 | 250 |
1.5656253999993206 | 250 |
2.0154948999993505 | 250 |
1.865527199998498 | 250 |
1.8782666999995707 | 250 |
1.7716790999993681 | 250 |
2.0643387000001967 | 250 |
1.6173277000002564 | 250 |
2.1055513000003994 | 250 |
1.927204500000924 | 250 |
Conclusion
The average time for a request to process (excluding case with 25 results*) is:
- 2.790784721 seconds for Playwright
- 1.924005904 seconds for Axios
The median time for a request to process (excluding case with 25 results*) is:
- 2.7453213 seconds for Playwright
- 1.90790485 seconds for Axios
Averages are really close to medians, so there is no extreme value. The average is representative.
In average, Axios is faster than Playwright by 0.866778817 seconds.
That's why I choose to go back to Axios. If you do not agree with my decision, feel free to open an issue.
*Sometimes, when Discogs is overloaded, it only show 25 items instead of the number you wanted (250). These cases are not relevant.
v1.4.0
v1.3.9
- Rename field 'itemId' to 'id' ee3a9d0
v1.3.8
- Fix currency for JPY 1882b2e