1. Home
  2. Kodi

Kodi Developer Tips: How to Create and Implement a Trakt API Key for Your Add-on

Kodi has long held the position of being one of the best open-source media center apps around. The ease with which anyone can create extensions for the software makes it even more attractive, as well. Kodi add-on developers can go from idea to testable prototype in a single afternoon, even if they have little experience with coding or app development.

Services like Trakt give add-on developers instant access to a massive database of information about TV shows and movies. Not only can you use them to pull in show titles and episode information, but Trakt offers an option to grab user data along with it, meaning you can add a “popular” or “user rated” section to your extension in an instant. Best of all, the only thing you need to do to get started with Trakt is to snag an API key and paste it into your project. We’ll walk you through the entire process below, complete with links and samples.

Stay Private and Secure with a VPN

The Kodi software environment is completely safe and legal to use. Some of the add-ons you can install aren’t bound by those same rules, however, which has caused increased scrutiny over the last few years. Content creators have shut down certain add-ons, and ISPs are known to throttle Kodi users at random. Even if your add-on is completely legitimate, the moment you fire up Kodi you could be at risk.

The best way to protect yourself from these kinds of dangers is to use a reliable virtual private network. VPNs encrypt data before it leaves your device, making it difficult or outright impossible for anyone to see which sites you’re visiting or which Kodi streams you download. VPNs also obscure your identity and location, restoring both privacy and anonymity to your online experience, and helping to break through ISP throttles and censorship barriers.

The Best VPN for Kodi – IPVanish

How to Create and Implement a Trakt API Key for Your Add-on - IPVanish

IPVanish has all the right features to make it one of the best VPNs to use with Kodi. It’s an incredibly fast service, to start with, offering over 950 servers in 60 different countries for fast, low-lag connections around the world. You also get an incredible amount of security with strong 256-bit AES encryption, DNS leak protection, and an automatic kill switch for all devices. Combine that with a zero-logging policy on all traffic and absolutely no restrictions on torrent downloads or P2P content and you’ve got the perfect recipe for a reliable and private VPN for all your online needs, including Kodi streams!

IPVanish offers a 7-day money back guarantee which means you have a week to test it risk-free. Please note that Addictive Tips readers can save a massive 60% here on the IPVanish annual plan, taking the monthly price down to only $4.87/mo.

Before You Get Started

Trakt is an incredibly useful service for both Kodi developers and casual streamers. Dozens of add-ons make use of the data it provides, and getting things set up for your own release is easier than you might expect. Before you jump in, however, take a look at the information below so you know exactly what you’re getting into.

Kodi Trakt API - Trakt website - 1

What Does Trakt Do?

Trakt.tv has a simple mission: collect lots of interesting information about what TV shows and movies people are watching. It starts with simple stuff like show names, runtimes, and genre details. On top of that are numbers relating to ratings, popularity among users, IMDB scores, and lots more. Most add-on developers don’t use every piece of content provided by Trakt. If you do, though, you’ll be providing lots of great data to make your release more useful than ever.

Some of the statistics and metadata Trakt scrapes includes the following:

  • Box art and splash images, both fan-made and official.
  • Data on actors, directors, writers, producers, and so on.
  • Episode names, numbers, and genre information.
  • Metadata translated into several languages.
  • The show’s full title and original air date.
  • User ratings and critic review scores.

What Are API Keys?

API stands for application programming interface, and the keys are simple strings of numbers and letters used to identify an application trying to access a service. If you were building an add-on for Facebook, for example, you might need API keys to help identify the add-on with the external site, otherwise no data would ever be transmitted.

Is Trakt Safe and Legal?

Both legal and safe, yes. Trakt doesn’t provide any content, just metadata. You can use it to get show names and episode information, but never the videos themselves. One thing worth noting is that Trakt does keep track of your video watching habits (hence the name). Information is submitted to the service’s database anonymously and is only used to increase the amount of info Trakt can offer. Your privacy isn’t really at risk, and neither is the privacy of your add-on’s users.

How to Create a Trakt.tv API Key

The Trakt.tv service is an incredibly useful tool for Kodi developers. Using it gives you instant access to a massive database of information, enough to turn your add-on into a genuinely useful piece of software. Creating and adding the API key is a surprisingly simple process, as well. Follow the guide below and you’ll be deploying in no time!

Kodi Trakt API - Trakt register - 2

Step 1 – Register with Trakt.tv

Before you can even register with the Trakt API site, you’ll need to create an account with Trakt.tv. Signup only takes a few seconds and is completely free. Be sure to use account details associated with your Kodi developer name or add-on title, for consistency.

Step 2 – Using the API Page

With account details in hand, go to Trakt.tv’s API application page and sign in. From here you’ll be asked to fill in some basic information about your add-on, everything from the name to a short description and site URL. You can leave the icon blank for now, but everything else needs to be taken care of. Once you’ve finished, scroll down and click “save app”.

Kodi Trakt API - Addon screen - 3

Step 3 – Save Your Details

Once you’ve signed up and created your app’s page, Trakt will direct you to an API methods page with a few key pieces of information. The one you’ll be most concerned with is Client ID and Client Secret, two strings of numbers and letters that serve as your API keys. Copy and save each one somewhere safe, you’ll need to enter both keys into your application.

How to Use the Trakt API Key in Your Kodi Add-on

Once you’ve generated and saved your API key, it’s time to put it to work. This process will vary depending on your development preferences. Below we’ve outlined one of the easier and more common methods for creating Kodi add-ons, the Jen Template. Follow the instructions to customize and insert your API key and your code will be up and running in no time.

Step 1 – Get the Jen Template

Visit the Jen Template page on github, the official home of the project’s ongoing development. Click the green button in the top right that says “clone or download”, then download the zip file. Extract it into its own folder, preferably on your desktop, then get ready to dive in.

Kodi Trakt API - XML editor - 4

Step 2 – Edit Addon.xml

Look inside the folder you just created titled plugin.video.jen-master. In the top level you’ll see a file named addon.xml. Open this file using your favorite code editor (or notepad, in a pinch). At the top you’ll see a line that looks similar to the text below. You’ll need to make a few edits to this line. Only change the capitalized text and the # signs, and make sure to avoid using spaces and non-standard characters.

<addon id=”plugin.video.YOUR ADDON HERE” name=”YOUR ADDON’S NAME” version=”#.#.#” provider-name=”DEVELOPER NAME”>

When complete, the line should look something like this, with your details in place of ours, of course:

<addon id=”plugin.video.addictivetips” name=”AddictiveTips” version=”1.4″ provider-name=”addictivetipscreator”>

Now scroll down a bit and look for lines 19 and 21. They mark the add-ons summary and long description. Replace the text in caps below with text relating to your own project.

<summary lang=”en”>ADDON SUMMARY</summary>
<description lang=”en”>LONG ADDON DESCRIPTION</description>

There may be additional lines in this section referring to other languages. You can remove them or leave them blank for now, they’re intended for translations and aren’t necessary at the moment.

Save the addon.xml file, you’re done editing it for now.

Step 3 – Edit Default.py

Now it’s time to insert the actual API key. Look for the file named default.py in the same directory as the addon.xml file above. Open it in your code editor, then scroll down to lines 27 and 28. They should look something like this:

__builtin__.trakt_client_id = “” # trakt client id
__builtin__.trakt_client_secret = “” # trakt client secret

Insert the appropriate code copied from the Trakt website between the quotation marks. For example:

__builtin__.trakt_client_id = “123456789012345678901234567890” # trakt client id

Both lines should have the right keys in place now. Save your changes and exit the file.

Step 4 – Edit Settings.xml

Now it’s time to finish customizing the template so it reflects your add-on’s design. Inside the jen-master folder you’ll see another folder labeled “resources”. Go inside and look for the settings.xml file. Open it in your editor, then scroll down to around line 27. You should see the following line repeated a few times in this section:

action=”RunPlugin(plugin://plugin.video.jen/?mode=ScraperSettings)”/>

The part that says plugin.video.jen is where we’re focusing. Change the text to reflect the same name you added to addon.xml. For example, ours might look like this:

action=”RunPlugin(plugin://plugin.video.addictivetips/?mode=ScraperSettings)”/>

Make the same changes on lines 27, 31, and 36, then save the file and exit.

Step 5 – Rename the Folder

You’re just about done! With the API key from Trakt inserted and the other necessary customizations made, all you need to do is rename the folder and you’re ready to test things out. Save and exit all the files you were editing, then go back to the original folder you made called “plugin.video.jen-master”. Change this name to reflect the one you entered into addon.xml, followed by the version number. Using our example above, the file would now be named:

plugin.video.addictivetips.1.4.zip

And now you’re ready to go! Try installing your add-on to Kodi and it should work just fine.

More Add-on Customizations

The Jen Template is a fantastic framework for just about any Kodi add-on. Plugging in the API key from Trakt is just one of the many steps you can take to give your creation life. Below are a few more suggestions to follow to help brand your add-on and make it your own.

Use a Custom Icon

When browsing through Kodi you may notice an icon that appears in the top left of the screen. This shows up whenever you highlight an add-on, and it’s easy to include with your Jen Template. Simply create a 256×256 PNG file, preferably one with no text or Kodi branding, then copy it to the top level of your folder. Name it icon.png and you’re set!

Include a Fan Art Banner

Similar to the icon above, fan art is a splash-style background that shows up behind selection text in Kodi. It can be related to your add-on branding, but most creators prefer to release banners related to the content their add-on offers. If you’re focusing on HD movies, for example, you might pick a popular film and create some artwork based around that theme. To add fan art banners, just make a 1280×720 JPG image, name it fanart.jpg, then stick it in the top level folder of your add-on.

Add Translations

English is pretty much the default for most of Kodi’s content, as it’s the most widely used language on the web. Just about everything in the Kodi community is designed with translations in mind, however. It’s a good idea to add at least a few basic language options into your project. Kodi users are eager to contribute translations for basic terms and descriptions.

The Jen Template makes it easy to add different languages. All you have to do is take the translated text and paste it to your addon.xml file using the same process as described above. You’ll see sections marked with phrases “lang=he”, “lang=fr”, or “lang=de”, all of which point to languages users can select when launching Kodi.

Conclusion

Trakt is an incredibly useful tool for both Kodi add-on developers and TV fans alike. Using it means instant access to a wealth of information, far more than most other TV database services. It also means you’re helping to contribute to the project, which makes it better for everyone. Adding a Trakt API to your project is a quick and painless process, too, with no complicated sign-ups or code segments to handle. Had a good experience using Trakt.tv in the past? Share your comments below!

Don't miss this great deal

Leave a comment