A Python client library for the 42 School API
Project description
42 Client
A Python client library for the 42 School API that simplifies authentication and data retrieval.
Features
- Easy authentication with 42 API
- Convenient methods for fetching users, projects, locations, and more
- Built-in request handling and error management
- Type hints support
- Customizable request parameters
Installation
From PyPI (recommended)
# Using pip
pip install fortytwo-client
# Using uv (recommended)
uv add fortytwo-client
From source
git clone https://github.com/lucas-ht/fortytwo-client.git
cd fortytwo-client
uv sync
Development installation
git clone https://github.com/lucas-ht/fortytwo-client.git
cd fortytwo-client
uv sync --group dev
Quick Start
1. Get your API credentials
First, you need to create an application on the 42 API to get your client ID and secret.
2. Basic usage
from fortytwo import FortyTwoClient, FortyTwoConfig
# Configure the client
config = FortyTwoConfig(
...
)
# Create client instance
client = FortyTwoClient(config)
# Fetch user information
user = client.users.get_by_id(user_id=12345)
print(f"User: {user['login']}")
3. Advanced usage with custom parameters
from fortytwo import parameter
...
# Use custom parameters for filtering and pagination
user = client.users.get_all(
# Use the filter by login parameter to fetch user by login
parameter.UserParameters.Filter.by_login("example")
)
Authentication
The client handles OAuth2 authentication automatically. Simply provide your client credentials in the configuration.
Examples
See the example/ directory for more detailed usage examples:
fetch_user.py- Fetching user informationfetch_projects.py- Working with projectsfetch_location.py- Location data retrieval
Documentation
For detailed documentation on each resource type:
- Resources Overview - General resource documentation
License
MIT License - see the LICENSE file for details.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fortytwo_client-2.1.0.tar.gz.
File metadata
- Download URL: fortytwo_client-2.1.0.tar.gz
- Upload date:
- Size: 40.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea47c94c1fa9f24f5eaca5bff07802f0f322b6833ae0daa2234d216998514e6
|
|
| MD5 |
b12320c258630bf28c70b9d97705f7d7
|
|
| BLAKE2b-256 |
7bf8beba886fc667beefa9224c0aa62cc7f69b1248400c336d6293e7702f733c
|
File details
Details for the file fortytwo_client-2.1.0-py3-none-any.whl.
File metadata
- Download URL: fortytwo_client-2.1.0-py3-none-any.whl
- Upload date:
- Size: 48.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89968cf3c3bdb8b0d5571a481a0f688816a12c5fba1ad58d16c6ab9da5b5ae76
|
|
| MD5 |
25cea774d17792987a055139d4908d36
|
|
| BLAKE2b-256 |
1bb73815aa179de58a27941a43d3a713ab17f57e13db0e154768d361ebe5ec51
|