Skip to main content

🎓 PDDIKTI API Python Library

Codacy Badge python3.x Version Downloads Author License

An unofficial Python wrapper for the Indonesian Higher Education Database (PDDIKTI, Kemdiktisaintek).

pddiktipy gives you a clean, typed interface to student, lecturer, university, and study-program data from PDDIKTI, with connection pooling, retries, validation, and comprehensive error handling.

📋 Table of Contents

🚀 Features

  • 70+ endpoints: search, details, statistics, and visualizations
  • Full type hints for good editor support
  • Robust error handling with custom exceptions and input validation
  • Context manager support for clean resource management
  • Connection pooling & retries out of the box
  • Transparent AES-256 decryption for the encrypted search endpoint

📦 Installation

pip install pddiktipy

To let the client read the Cloudflare clearance cookie from your local browser automatically (see below), install the optional extra:

pip install "pddiktipy[auto]"

🚨 Cloudflare access (read this first)

The upstream API (https://pddikti.kemdiktisaintek.go.id/api) is protected by a Cloudflare Turnstile challenge. A plain HTTP client always receives 403, so api() with no arguments will not work on its own. Only a real browser can pass the challenge. Even automated browsers (Selenium/Playwright) are blocked.

You therefore need to supply Cloudflare clearance in one of three ways.

Option A: auto cookie (easiest, on your own machine)

pip install "pddiktipy[auto]"
  1. Open https://pddikti.kemdiktisaintek.go.id in Chrome or Edge and complete the "Verify you are human" check once.
  2. Run your code. The client reads the cf_clearance cookie for you:
from pddiktipy import api

with api(auto_cookie=True) as client:
    print(client.get_pt_count())   # {'status': 'success', 'data': {'jumlah': 4416}}

Option B: paste the cookie manually (works on servers or other machines)

  1. Open the site in your browser and pass the check.
  2. Open DevTools (F12) → Application → Cookies → select the site → copy the value of cf_clearance.
  3. In DevTools → Network, click any request → Headers → copy the User-Agent (the cookie is bound to it).
from pddiktipy import api

client = api(
    cf_clearance="PASTE_CF_CLEARANCE_HERE",
    user_agent="PASTE_YOUR_BROWSER_USER_AGENT_HERE",
)
print(client.get_pt_count())

Option C: run your own solver proxy (most stable for production)

Point base_url at a service that solves Cloudflare for you (for example a FlareSolverr-backed proxy that forwards to the PDDIKTI upstream):

from pddiktipy import api

client = api(base_url="http://localhost:8080/api")
print(client.get_pt_count())

Note: cf_clearance is bound to your IP and User-Agent and expires after ~30 minutes. For long-running, unattended use, prefer Option C.

⚡ Quick Start

from pddiktipy import api
from pprint import pprint

# See "Cloudflare access" above for how to provide clearance.
with api(auto_cookie=True) as client:
    # Search across all categories (payload is decrypted for you)
    results = client.search_all("Universitas Diponegoro")
    pprint(results)

    # Search a specific category
    students = client.search_mahasiswa("Ilham Riski Wibowo")
    pprint(students)

    # Aggregate statistics
    print(client.get_pt_count())          # number of universities
    print(client.get_mahasiswa_count())   # number of students

A runnable example lives in examples/quickstart.py.

⚠️ Error Handling

By default, API methods log and return None on failure rather than raising, so everyday calls stay simple:

with api(auto_cookie=True) as client:
    result = client.search_mahasiswa("")   # invalid keyword -> logs and returns None
    if result is None:
        print("No result / request failed")

The lower-level exceptions are still available if you build on top of the helper:

from pddiktipy.exceptions import (
    ValidationError, APIConnectionError, APITimeoutError,
    APIRateLimitError, APIResponseError, PDDIKTIError,
)

If the upstream returns a Cloudflare challenge, the client raises an APIResponseError whose message explains exactly how to supply clearance.

📚 Documentation

➡️ API Documentation: every method, with parameters, examples, and response field descriptions.

📋 Requirements

  • Python 3.7+
  • requests
  • cryptography
  • browser_cookie3 (optional, only for auto_cookie=True)

🧪 Testing

🧪 Testing Guide: how to run the test suite.

Offline tests (no network) can be run directly:

python -m pytest tests/test_crypto_and_endpoints.py -q

🤝 Contributing

🤝 Contributing Guide: how to contribute.

📄 License

Distributed under the MIT License.


📞 Support & Contact

⭐ If this library helps your project, please consider starring it on GitHub!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pddiktipy-2.1.1.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pddiktipy-2.1.1-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file pddiktipy-2.1.1.tar.gz.

File metadata

  • Download URL: pddiktipy-2.1.1.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for pddiktipy-2.1.1.tar.gz
Algorithm Hash digest
SHA256 5b8393d8b83351ff32ea21a0c9815aa46dd643840cab0379a50d20bcedf5e544
MD5 2f3782616f28c370e3874e15ba78726c
BLAKE2b-256 e72b1777f7a5b9387dbff46075d9b00ae2c5f2f68d97fc3f1253ef951e10da32

See more details on using hashes here.

File details

Details for the file pddiktipy-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: pddiktipy-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for pddiktipy-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa1ac71bb94169fec8d0b82341ad7e9d03b6727d82ceb474a0704610f7b1f307
MD5 34c95a719db6e19e5610cbbbe676de36
BLAKE2b-256 f59bea9a453725d4aaf2de4d5bb2238262c4ecca73d49d3b1f8da467832ae17a

See more details on using hashes here.

Release history Release notifications | RSS feed

2.1.3

2 files

2.1.2

2 files

This release

2.1.1 This release

2 files

2.1.0

2 files

2.0.6

2 files

2.0.5.post1

2 files

2.0.5

2 files

2.0.4

2 files

2.0.3

2 files

2.0.0

2 files

1.0.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page