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:
1.2 API Features
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:
2.2 How to Register an App.
Go to the Modula Developer Dashboard:
Create a New App:
Obtain App Credentials:
🔹 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:
There are two types of authentication scenarios:
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:
- They are redirected to Modula’s OAuth authorization page.
- 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:
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:
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:
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_TOKENExample 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
6.2 Use HTTPS for API Requests
6.3 Handle Expired Tokens Gracefully
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. |