trakt / api-help

Trakt API docs at https://trakt.docs.apiary.io
179 stars 7 forks source link

Get Share_link items from the api #468

Open hariperisetla opened 3 weeks ago

hariperisetla commented 3 weeks ago

I am trying to get the share_link data from the api. But this doesn't seem to be working. I don't see any relevant option in the api. I want to show the data from the share_link id or the generated share_link path id if possible so that I can share the data in the UI. Is there a way to do this? @rectifyer

rectifyer commented 3 weeks ago

Please post the API method you're using and more details on what is wrong. Are you trying to use the share_link to view list items? That is only a web link and the API isn't able to retrieve items using that link. If you can explain what you're trying to do more, maybe I'll have some ideas.

hariperisetla commented 3 weeks ago

I tried https://api.trakt.tv/users/id/lists/list_id and https://api.trakt.tv/users/id/lists/list_id/items but doesn't seem to be working without a access_token attached. I am trying to build a web app where the primary feature is to create a lists to be shareable to friends who are both authenticated and unauthenticated. As the options to create them are good and working. I am not sure how do I manage a shareable link to show in the app instead of going to trakt.tv everytime. Yes, I am using share_link

rectifyer commented 3 weeks ago

Please post the full API request and response so I can take a look.

hariperisetla commented 3 weeks ago

I am receiving the below responses for the share_link data.

Request with user's access_token:

const listsResponse = await fetch(
      `https://api.trakt.tv/users/${data.user.username}/lists`,
      {
        method: "GET",
        headers: {
          "Content-Type": "application/json",
          Authorization: `Bearer ${access_token}`,
          "trakt-api-version": 2,
          "trakt-api-key": process.env.CLIENT_ID,
        },
      }
    );

Response with user's access_token:

image

The below request is what I require so that I can display the share_link list/items to the user if they are not authenticated in my web UI instead of redirecting everytime to trakt.tv. But instead I am receiving a empty array Request without user's access_token:

const listsResponse = await fetch(
      `https://api.trakt.tv/users/${data.user.username}/lists`,
      {
        method: "GET",
        headers: {
          "Content-Type": "application/json",
          // Authorization: `Bearer ${access_token}`, -- Commented out
          "trakt-api-version": 2,
          "trakt-api-key": process.env.CLIENT_ID,
        },
      }
    );

Response without user's access_token:

image

Same thing is happening to: https://api.trakt.tv/users/id/lists/list_id

https://api.trakt.tv/users/id/lists/list_id/items

rectifyer commented 3 weeks ago

Seems like the user account is private, so OAuth is required to view it.

hariperisetla commented 3 weeks ago

image

I just checked and it is not private.

The flag is false: private: false