mkb79 / Audible

A(Sync) Interface for internal Audible API written in pure Python.
https://audible.readthedocs.io
GNU Affero General Public License v3.0
314 stars 38 forks source link

Api request for Author Page #520

Closed lars-hoeck closed 2 weeks ago

lars-hoeck commented 3 weeks ago

Is your feature request related to a problem? Please describe. I'd like to access the author page and their description.

Describe the solution you'd like A new entry in the documentation how to access the author page

Additional context I would love to help with finding the endpoint for the author page, but I have no idea how to start with that (not my area of expertise).

mkb79 commented 3 weeks ago

Hi,

you can search for an author using the products endpoint. You are need the asin of the author.

Then you can make a get request to screens/audible-ios-author-detail/{asin of author: eg. B000AQ01G2}. The endpoint support the following params: author_asin, show_archived, title_source. An example for a full GET request target is https://api.audible.de/1.0/screens/audible-ios-author-detail/B000AQ01G2?author_asin=B000AQ01G2&show_archived=false&title_source=all.

lars-hoeck commented 3 weeks ago

Thanks for the fast reponse. I tried client.get("screens/audible-ios-author-detail/B000AQ01G2") and the URL you provided and both times i get "Not Found (404): 404 resource not found for page B000AQ01G2, marketplace AN7V1F1VY261K" But every other api call works without a problem.

Love this project. Would love to learn how to find these endpoint myself, any tips on resources and how to start?

mkb79 commented 2 weeks ago

For some unknown reason the endpoint need a specific header to be sent. I've need some time to find these out. The header is X-ADP-SW=43000458

This way a request looks like:

auth = Authenticator.from_file(…)

with Client(auth) as client:
    r = client.get(
        "screens/audible-ios-author-detail/B000AQ0842",
        params={
            "author_asin": "B000AQ0842",
            "show_archived": "false",
            "title_source": "all"
        },
        headers={
            "X-ADP-SW": "43000458"            
        }
    )
lars-hoeck commented 2 weeks ago

Thanks, it works. I checked the response and the header is in the reply in the tag appVersion. I tried a few thing and you can even put "0" in the header and the repsone looks fine(you get even more data). I couldnt find any informations about the author image, did you see a second request that happend for loading it?

mkb79 commented 2 weeks ago

I tried a few thing and you can even put "0" in the header and the repsone looks fine(you get even more data).

Thank you for this information.

I couldnt find any informations about the author image, did you see a second request that happend for loading it?

In my response I have an person_image_url entry. This is the url for the author. Do you don’t have these?

lars-hoeck commented 2 weeks ago

I tried the get request you posted but i dont see person_image_url, which is weird. But i tried using android instead of ios in the request with header "0" and i got a sligthly different result with a profile_image entry.

client.get(
        "screens/audible-android-author-detail/B000AQ0842",
        params={
            "author_asin": "B000AQ0842",
            "title_source": "all"
        },
        headers={
            "X-ADP-SW": "0"
        })
mkb79 commented 2 weeks ago

@lars-hoeck You are right. I does not have the person_image_url in my response on my PC. But the response in the iOS Audible app had it.

The origin request of the Audible app was:

GET /1.0/screens/audible-ios-author-detail/B000AQ0842?author_asin=B000AQ0842&show_archived=false&title_source=all HTTP/1.1
Host: api.audible.de
X-ADP-SW: 43000458
Accept: application/json
x-amz-access-token: Atna|[…redacted…]
X-ADP-Transport: WIFI
X-ADP-LTO: 120
Accept-Language: de-DE
X-Device-Type-Id: A2CZJZGLK2JJVM
device_idiom: phone
country-code: DEU
User-Agent: Audible, iPhone, 1458 (4.30), iPhone 15 Pro Max iPhone16,2, iOS, 18.0, Wifi
Accept-Encoding: gzip, deflate, br
currency-code: EUR
X-Amzn-RequestId: […redacted…]
X-ADP-Country: DE
Connection: keep-alive
Content-Type: application/json

Strange since the latest iOS Audible app is the using of a x-amz-access-token and the access token. In the past the app uses a RSA key to sign the request. But using an access token makes no difference in the response body on my PC. So maybe the reason for the missing author url are the missing other headers from above or something else?!

lars-hoeck commented 2 weeks ago

client.get( "screens/audible-android-author-detail/B000AQ0842", params={ "author_asin": "B000AQ0842", "title_source": "all" }, headers={ "X-ADP-SW": "0" })

I think you could be right about the header. I just tried the android enpoint without the header and get a response with informations but missing a lot of informations.

My issues is resolve. I use the android enpoint. If you figure anything out, let me know :)

P.S.: Still like to learn about reverse engeenering api request in apps if you have some pointer.

mkb79 commented 2 weeks ago

@lars-hoeck

I'm using two methods to discover API endpoints.

  1. Download the APK from Google store or other sources to your PC. Open the APK with jadx and unobfuscate the code. Now you can search the source code for endpoints and other stuff with jadx
  2. Record the traffic from the app using a mitm attack. On iOS it is relatively simple by using a specific app from the app store. On Android devices you need a rooted device to bypass cert pinning for some apps.