Catalog PyPI
PACKAGE EXPLORERView in registry

42api

PyPI

Object-oriented Python client for the 42 School API (api.intra.42.fr)

4242school42staffapiclientintraintra42
Versions collected1
Direct dependencies2From release 0.1.3
Last observed20 Oct, 15:40 UTC

README

Version 0.1.3 documentation

42api

An object-oriented Python client for the 42 School API (api.intra.42.fr) that handles OAuth2 authentication, request pacing, and pagination for you, so you can work with typed resources instead of raw JSON and HTTP plumbing.

  • Sync and async — Client and AsyncClient share one codebase and the same interface.
  • Typed models — resources are Pydantic v2 models with IDE-friendly autocomplete.
  • Automatic rate limiting — requests are paced to stay under 42's limits; 429s are retried with backoff automatically.
  • Lazy pagination — iterate a query and it walks every page for you.

Install

uv add 42api
# or: pip install 42api

Usage

from intra42 import Client

with Client(client_id="...", client_secret="...") as client:
    user = client.users.get("jdoe")
    print(user.login, user.email)

    for user in client.users.filter(primary_campus_id=1).sort("-pool_year"):
        print(user.login)

Async is the same shape:

import asyncio
from intra42 import AsyncClient


async def main() -> None:
    async with AsyncClient(client_id="...", client_secret="...") as client:
        user = await client.users.get("jdoe")
        async for user in client.users.filter(primary_campus_id=1).sort("-pool_year"):
            print(user.login)


asyncio.run(main())

Fetched instances expose their nested resources directly — no need to build the scoped path yourself:

campus = client.campuses.get(1)
for event in campus.events:  # GET /campus/1/events
    print(event.name)

user = client.users.get("jdoe")
for cu in user.campus_users:  # GET /users/jdoe/campus_users
    print(cu.campus_id, cu.is_primary)

These (campus.events, campus.users, user.events, user.campus_users) are only available on instances fetched via a client — a manually constructed model raises a clear RuntimeError if accessed.

Get your client_id/client_secret by registering an app at https://profile.intra.42.fr/oauth/applications. This library uses the client credentials flow, so it accesses the API as your app rather than as a specific logged-in user.

Errors

All errors subclass intra42.FortyTwoAPIError, with subclasses for common HTTP statuses: AuthenticationError (401), PermissionDeniedError (403), NotFoundError (404), ValidationError (422), RateLimitError (429, only raised once the built-in retry budget is exhausted), ServerError (5xx), and NetworkError (connection/timeout failures).

Status

Early-stage: currently covers users, accreditations, campuses, campus_users, cursus, events, exams, locations, projects, and projects_users (exams, locations, and projects_users each include their graph analytics endpoint). More resources are added incrementally on top of the same client/model/query-builder pattern. The api with restricted access are not implemented currently.

Development

Uses uv for dependency management.

uv sync                                               # install dependencies
uv run pytest                                         # run tests
uv run ruff check . && uv run ruff format --check .   # lint
uv run mypy                                           # type check

The sync client (intra42._sync) is generated from the async client (intra42._async) via unasync — edit the async source and regenerate:

uv run python scripts/unasync_generate.py            # regenerate
uv run python scripts/unasync_generate.py --check    # verify no drift (CI)

License

MIT

Downloads & popularity

15downloads
1-day window · source-reported counts20 Oct 2026
17788.50
2026-09-07: 124 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-07–2026-09-072026-09-08: 6 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-08–2026-09-082026-09-09: 5 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-09–2026-09-092026-09-10: 83 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-10–2026-09-102026-09-11: 2 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-11–2026-09-112026-09-12: 6 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-12–2026-09-122026-09-13: 2 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-13–2026-09-132026-09-14: 2 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-14–2026-09-142026-09-15: 2 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-15–2026-09-152026-09-16: 8 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-16–2026-09-162026-09-17: 6 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-17–2026-09-172026-09-18: 11 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-18–2026-09-182026-09-20: 2 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-20–2026-09-202026-09-21: 5 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-21–2026-09-212026-09-23: 4 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-23–2026-09-232026-09-24: 177 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-24–2026-09-242026-09-25: 8 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-25–2026-09-252026-09-26: 7 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-26–2026-09-262026-09-27: 18 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-27–2026-09-272026-09-28: 8 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-28–2026-09-282026-09-29: 17 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-29–2026-09-292026-09-30: 15 · observed 2026-10-21T10:18:53.7310721Z · period 2026-09-30–2026-09-302026-10-01: 10 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-01–2026-10-012026-10-02: 7 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-02–2026-10-022026-10-03: 9 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-03–2026-10-032026-10-04: 12 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-04–2026-10-042026-10-05: 14 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-05–2026-10-052026-10-06: 10 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-06–2026-10-062026-10-07: 8 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-07–2026-10-072026-10-08: 21 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-08–2026-10-082026-10-09: 10 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-09–2026-10-092026-10-10: 9 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-10–2026-10-102026-10-11: 13 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-11–2026-10-112026-10-12: 8 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-12–2026-10-122026-10-13: 8 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-13–2026-10-132026-10-14: 8 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-14–2026-10-142026-10-15: 8 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-15–2026-10-152026-10-16: 8 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-16–2026-10-162026-10-17: 23 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-17–2026-10-172026-10-18: 11 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-18–2026-10-182026-10-19: 9 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-19–2026-10-192026-10-20: 15 · observed 2026-10-21T10:18:53.7310721Z · period 2026-10-20–2026-10-20
7 Sept20 Oct

pypistats · 42 observations shown. Missing days are unknown. Source category: overall: without mirrors.

View observed values
Date / source periodValueObserved at
2026-10-20 – 2026-10-20152026-10-21T10:18:53.7310721Z
2026-10-19 – 2026-10-1992026-10-21T10:18:53.7310721Z
2026-10-18 – 2026-10-18112026-10-21T10:18:53.7310721Z
2026-10-17 – 2026-10-17232026-10-21T10:18:53.7310721Z
2026-10-16 – 2026-10-1682026-10-21T10:18:53.7310721Z
2026-10-15 – 2026-10-1582026-10-21T10:18:53.7310721Z
2026-10-14 – 2026-10-1482026-10-21T10:18:53.7310721Z
2026-10-13 – 2026-10-1382026-10-21T10:18:53.7310721Z
2026-10-12 – 2026-10-1282026-10-21T10:18:53.7310721Z
2026-10-11 – 2026-10-11132026-10-21T10:18:53.7310721Z
2026-10-10 – 2026-10-1092026-10-21T10:18:53.7310721Z
2026-10-09 – 2026-10-09102026-10-21T10:18:53.7310721Z
2026-10-08 – 2026-10-08212026-10-21T10:18:53.7310721Z
2026-10-07 – 2026-10-0782026-10-21T10:18:53.7310721Z
2026-10-06 – 2026-10-06102026-10-21T10:18:53.7310721Z
2026-10-05 – 2026-10-05142026-10-21T10:18:53.7310721Z
2026-10-04 – 2026-10-04122026-10-21T10:18:53.7310721Z
2026-10-03 – 2026-10-0392026-10-21T10:18:53.7310721Z
2026-10-02 – 2026-10-0272026-10-21T10:18:53.7310721Z
2026-10-01 – 2026-10-01102026-10-21T10:18:53.7310721Z
2026-09-30 – 2026-09-30152026-10-21T10:18:53.7310721Z
2026-09-29 – 2026-09-29172026-10-21T10:18:53.7310721Z
2026-09-28 – 2026-09-2882026-10-21T10:18:53.7310721Z
2026-09-27 – 2026-09-27182026-10-21T10:18:53.7310721Z
2026-09-26 – 2026-09-2672026-10-21T10:18:53.7310721Z
2026-09-25 – 2026-09-2582026-10-21T10:18:53.7310721Z
2026-09-24 – 2026-09-241772026-10-21T10:18:53.7310721Z
2026-09-23 – 2026-09-2342026-10-21T10:18:53.7310721Z
2026-09-21 – 2026-09-2152026-10-21T10:18:53.7310721Z
2026-09-20 – 2026-09-2022026-10-21T10:18:53.7310721Z
2026-09-18 – 2026-09-18112026-10-21T10:18:53.7310721Z
2026-09-17 – 2026-09-1762026-10-21T10:18:53.7310721Z
2026-09-16 – 2026-09-1682026-10-21T10:18:53.7310721Z
2026-09-15 – 2026-09-1522026-10-21T10:18:53.7310721Z
2026-09-14 – 2026-09-1422026-10-21T10:18:53.7310721Z
2026-09-13 – 2026-09-1322026-10-21T10:18:53.7310721Z
2026-09-12 – 2026-09-1262026-10-21T10:18:53.7310721Z
2026-09-11 – 2026-09-1122026-10-21T10:18:53.7310721Z
2026-09-10 – 2026-09-10832026-10-21T10:18:53.7310721Z
2026-09-09 – 2026-09-0952026-10-21T10:18:53.7310721Z
2026-09-08 – 2026-09-0862026-10-21T10:18:53.7310721Z
2026-09-07 – 2026-09-071242026-10-21T10:18:53.7310721Z

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.324 Sept 20262

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
shadowaker/42api

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 15:40 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:281277bac8f444ccd107c113c8fdb9f4247532add05d1124bcbd85b3fb22a2f9