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

[Docs]: Please add usage examples. #195

Open
swasher opened this issue May 22, 2024 · 1 comment
Open

[Docs]: Please add usage examples. #195

swasher opened this issue May 22, 2024 · 1 comment
Assignees
Labels
documentation Issue is related to documentation

Comments

@swasher
Copy link

swasher commented May 22, 2024

What is the improvement or update to the Documentation you wish to see?

Hello, and thank you for sharing your work!
Can you add more usage examples for common scenarios? For example, search movie, add movie to list, add so on.
Thanks!

PS. For example, I can't understand how to call API3's (or API4's) methods, like account_mark_as_favorite. Do I need create instance of API4 class directly? Or in any other manner?

Does the docs page already exist? Please link to it.

No response

@swasher swasher added documentation Issue is related to documentation status:not-yet-viewed I haven't eeviewed the Feature or Bug yet labels May 22, 2024
@meisnate12
Copy link
Member

meisnate12 commented Sep 23, 2024

@swasher man im sorry i didnt see this until just now ill try and add more examples. but for you specific ask this is how to do it via the Object API.

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"
v4_access_token = "sohsnrfiemrsdvsavvt4h426GWEGW434gSgSdnjhcyuwbBYHBOSIYCBWgyNTYxNTY4OGQ5NTJjZCIsInN1YiI6IjVkMzM5ZmI0MmY4ZDAfdfdgegeGGregerfge34345BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIvfdvsdfveregrgqgfsfghjhOR0shmZZ_ZekFiuyl7o56921C0"

tmdb = TMDbAPIs(apikey, v4_access_token=v4_access_token)

print(tmdb.v4_authenticate())
input("Navigate to the URL and then hit enter when Authenticated")
tmdb.v4_approved()

movie = tmdb.movie(11) # TMDb Movie ID
movie.mark_as_favorite()

There are 2 ways to do every method one uses the Object API and the other uses the RAW API. There shouldn't really be a reason to use the RAW API in my opinion as everything can be done easier using the Object API.

Most methods that grab a list of data like movie/show lists, change lists, certification lists, and searches/discover are all direct methods under the main TMDbAPIs Object. Other methods that deal with for example a specific movie/show like Mark as Favorite are methods of the object they deal with. So first you need to use another method to get that object.

For example, there are three collections requests in the api (Details, Images, and Translations). By doing tmdbapis.collection(ID) you can get the collection object which has attributes containing all the info in Details as well as posters and backdrops from Images and translations from Translations.

Let me know if you have any more questions ill check back here to respond

@meisnate12 meisnate12 removed the status:not-yet-viewed I haven't eeviewed the Feature or Bug yet label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issue is related to documentation
Projects
None yet
Development

No branches or pull requests

2 participants