Getting Started - Seluj78/IntraPy GitHub Wiki

Getting Started

To get started, You'll first need to install the package. You can either clone it to have it locally or use the easy way and install it with pip. To do so, just type pip install IntraPy in your favorite terminal.

Once installed, You'll need to create a settings.ini file. This file shall be structure like so :

[settings]
APP_UID=XXX
APP_SECRET=XXX
TOKEN_FILE=YYY

With the XXX replaced by the UID and SECRET provided by 42. And YYY corresponding to the path/filename where you want your app token to be stored. Can be anywhere. I would recommend just using .app_token to make troubleshooting easy

Please note that the UID and SECRET in the settings.ini.example file are the result of my head smashing the keyboard, and not any real auth token of any kind

Once that file is created, simply import the package main file IntraPy and call the main class to initialize it

from IntraPy import IntraPy

api = IntraPy.IntraPy()

On a side note, this init function is also called when calling the other classes.

This function will send a request to https://api.intra.42.fr/oauth/token to get the token from the api and store it. It will also write it to TOKEN_FILE so that if init is called later again, it doesnt have to request again a new token but simply use the one in the file.

One done, you can simply start using the functions related to the endpoints.

from IntraPy.achievement_handler.achievements import Achievements

acc = Achievements()

a = acc.get_achievements()
print(a)

This will print all the achievements

Note that options can be passed to the functions. A simple example is the boolean pretty. By default set to false, if set to true, when printed, the results will be formatted