Bandcamp-API icon indicating copy to clipboard operation
Bandcamp-API copied to clipboard

Additional information on "older_than_token" for item based endpoints

Open Peter200lx opened this issue 6 years ago • 2 comments

https://github.com/michaelherger/Bandcamp-API/blob/7c30cfc67543e4ad681b98f8e196c3597c3e3bdb/data/bandcamp.yaml#L946-L954

This is merely discoveries from analysis of API responses on my own collection. The older_than_token is broken up into 5 parts separated by : Example partial response from api/fancollection/1/collection_items {"items": [{:

            "tralbum_type": "a",
            "purchased": "06 Feb 2017 02:16:28 GMT",
            "tralbum_id": 3314754897,
            "token": "1486347388:3314754897:a:2:",

Here's my understanding of the 5 parts:

  1. Unix epoch timestamp of when fan "purchased" this item.
  2. "tralbum_id" of the item in question
  3. "trablum_type" of the item in question
  4. ~Monotonically~ increasing index of items past initial set on users fan page (index can jump values)
  5. ?Unused?

Specifically related to api/fancollection/1/collection_items:

  1. The timestamp and id are not necessary and can be left blank ::...
  2. The tralbum_type is required to not be empty, but any value is fine ::foo:...
  3. The index value is the only important part for this handler 3.1. Any index value that is not a positive whole number is ignored and treated as an empty value, aka start at the first value you can give. (::foo:: or ::foo:bar: says start with the first item, ::foo:50: says start with the 51st item) 3.2. This unfortunately means you can't get the extended information about the initial 45 items set on the users fan page (apart from something like automating swapping the first and section 45 item chunks)

Peter200lx avatar May 06 '18 21:05 Peter200lx

First brush it looks like token for /api/fancollection/1/wishlist_items follows the pattern of /collection_items. However the 5 fields are:

  1. Unix epoch timestamp of when fan "added" this item
  2. "tralbum_id" of the item in question
  3. "trablum_type" of the item in question
  4. ?Unused?
  5. ?Unused?

In this case it appears that the first three fields are all important for getting consistent responses.

From <div id="pagedata" data-blob="{JSON HERE}"> on your fan page look for .wishlist_data.last_token.

Peter200lx avatar May 07 '18 06:05 Peter200lx

Specifically related to api/fancollection/1/collection_items:

  1. The timestamp and id are not necessary and can be left blank ::...
  2. The tralbum_type is required to not be empty, but any value is fine ::foo:...
  3. The index value is the only important part for this handler 3.1. Any index value that is not a positive whole number is ignored and treated as an empty value, aka start at the first value you can give. (::foo:: or ::foo:bar: says start with the first item, ::foo:50: says start with the 51st item) 3.2. This unfortunately means you can't get the extended information about the initial 45 items set on the users fan page (apart from something like automating swapping the first and section 45 item chunks)

Using this as a starting point, I was able to get an entire collection (matching the listed collection size) by setting older_than_token to f"{int(time.time())}::a::" (in Python).

nmwodarz avatar Feb 06 '23 01:02 nmwodarz