API Documentation
  • INFORMATION
  • API Version 1.00000220323

    API Last Update 10 April 2025

    Welcome to the modula API Documentation!
    This guide will walk you through everything you need to register, configure, and develop your app to seamlessly integrate with modula’s Eco-System.


    By using Modula’s APIs, you can allow users to authenticate, retrieve user data, and interact with the platform in a secure and scalable way.



    1. Getting Started

    1.1 What is Modula API?

    Modula API is a RESTful API that allows developers to integrate their applications with Modula, a dynamic and customizable digital platform.
    Through Modula API, you can:

  • Authenticate users with OAuth 2.0-based authentication.
  • Access user data (such as profile details).
  • Integrate external tools and services with the Modula ecosystem.
  • 1.2 API Features
  • 🔑 OAuth 2.0 Authentication – Secure login system for users.
  • 📊 User Data Access – Retrieve profile details via API.
  • 🔄 Token-Based Authentication – Temporary access tokens for enhanced security.
  • 🔐 Permissions & Security – Ensure data privacy and restricted access.




  • 2. App Registration

    2.1 Why Register an App?
    To access Modula’s API, your application must be registered in the Modula Developer Dashboard.

    This process provides you with:
  • App ID – A unique identifier for your app.
  • App Secret – A private key used for secure API access.
    2.2 How to Register an App.
        Go to the Modula Developer Dashboard:
  • Visit Modula Developer Portal.


  •     Create a New App:
  • Click on Create App and enter the required details.


  •     Obtain App Credentials:
  • After registration, you will receive an App Id & App Secret.

  • 🔹 Keep your App Secret confidential – never expose it in frontend code or public repositories.



    3. Authentication: Log in With Modula

    3.1 Overview
        The Log in With Modula system allows users to:
  • Log into your app securely using their Modula account.
  • Authorize your app to access their profile information.

  •     There are two types of authentication scenarios:
  • Basic Authentication – Users log in without granting extra permissions.
  • Extended Authentication – Users log in and authorize data sharing.


  • 3.2 OAuth Login Flow
        To initiate the login process, direct users to the following URL
    <a href="https://modula.digital/api/oauth?app_id=YOUR_APP_ID">connect with modula</a>


        When a user clicks this link:
    1. They are redirected to Modula’s OAuth authorization page.
    2. After approving the request, Modula sends them back to your redirect URL with an auth_key


        Example Redirect URL:
    https://mydomain.com/my_redirect_url.php?auth_key=AUTH_KEY

    📌 Important Notes:

  • auth_key is valid for one-time use only.
  • If the key is used or expires, the user must log in again.
  • 4. Getting an Access Token

    4.1 Why Do You Need an Access Token?
        Once a user logs in and provides authorization, you must exchange the auth_key access token.

        The access token is required to:
  • Retrieve user profile details.
  • Authenticate API requests.
  • 4.2 Requesting an Access Token
        To generate an access token, make an HTTP GET request to the following endpoint:
                <?php
                $app_id = "YOUR_APP_ID"; // your app id
                $app_secret = "YOUR_APP_SECRET"; // your app secret
                $auth_key = $_GET['auth_key']; // the returned auth key from previous step
    
                $get = file_get_contents("https://modula.digital/api/authorize?app_id=$app_id&app_secret=$app_secret&auth_key=$auth_key");
    
                $json = json_decode($get, true);
                if(!empty($json['access_token'])) {
                    $access_token = $json['access_token']; // your access token
                }
                ?>                                                                                                
                                

    📌 Access Token Expiry:

  • The token is valid for 1 hour.
  • Once expired, the user must log in again to generate a new one.
  • 5. API Endpoints

    5.1 Overview of Available Endpoints
    Endpoint Description Method
    /api/get_user_info

    Retrieve user profile information

    GET

    5.2 Retrieve User Info
       Request Format
    To fetch user details, send a GET request to:
    https://modula.digital/api/get_user_info?access_token=YOUR_ACCESS_TOKEN
    Example Code
    if (!empty($json['access_token'])) {
        $access_token = $json['access_token']; // Your access token
        $get = file_get_contents("https://modula.digital/api/get_user_info?access_token=$access_token");
        $user_info = json_decode($get, true);
    }
    5.3 API Response Format
    A successful request returns a JSON object with the user’s profile information:
    {
      "user_info": {
        "user_id": "12345",
        "user_name": "john_doe",
        "user_email": "john.doe@example.com",
        "user_firstname": "John",
        "user_lastname": "Doe",
        "user_gender": "Male",
        "user_birthdate": "1990-05-15",
        "user_picture": "https://modula.digital/uploads/profile123.jpg",
        "user_cover": "https://modula.digital/uploads/cover123.jpg",
        "user_registered": "2022-10-01",
        "user_verified": "1",
        "user_relationship": "Single",
        "user_biography": "Web developer & tech enthusiast.",
        "user_website": "https://johndoe.dev"
      }
    }
                          

    6. Security & Best Practices

    6.1 Secure Your App Credentials
  • Never expose your App Secretin client-side code.
  • Store credentials securely on your server.
  • 6.2 Use HTTPS for API Requests
  • Always use HTTPS to protect data transmission.
  • 6.3 Handle Expired Tokens Gracefully
  • Notify users when their session expires.
  • Redirect them to log in again when necessary.
  • 7. Troubleshooting & Support

    7.1 Common Issues & Fixes
    Issue Solution
    auth_key expired or invalid

    Request a new one by logging in again.

    access_tokenexpired

    Reauthenticate the user.

    403 Forbidden ERROR

    Ensure your App ID and Secret are correct.

    User data is empty or missing

    Check if the user granted permission.

    7.2 Need Help?
        For additional support, visit:
    🔗  
    DEV Community

    📧  Contact: support@modula.digital
    modula Install Digital