Overview

GakuNin RDM is a research data management platform provided by the National Institute of Informatics (NII). It is built on the Open Science Framework (OSF) and allows automating project operations through its API.

This article introduces how to perform the following operations using the GakuNin RDM API from Node.js.

  • Creating and configuring projects
  • Creating and updating wikis
  • Adding members
  • GitHub integration + automatic deployment with Vercel

Prerequisites

Obtaining a Personal Access Token

  1. Log in to GakuNin RDM
  2. Navigate to Settings > Personal Access Tokens
  3. Create a new token (scopes: osf.full_read, osf.full_write)

Project Initialization

mkdir rdm && cd rdm
npm init -y
npm install dotenv

Save the token in a .env file.

GRDM_TOKEN=your_personal_access_token_here

Also create a .gitignore file.

.env
node_modules/

Creating the API Client

The GakuNin RDM API uses the JSON:API format. First, create a generic client as lib/client.js.

lib/client.js

require("dotenv").config();

const BASE_URL = "https://api.rdm.nii.ac.jp/v2";
const TOKEN = process.env.GRDM_TOKEN;

if (!TOKEN) {
  throw new Error("GRDM_TOKEN is not set in .env");
}

const headers = {
  Authorization: `Bearer ${TOKEN}`,
  "Content-Type": "application/vnd.api+json",
};

async function request(method, path, body) {
  const url = `${BASE_URL}${path}`;
  const options = { method, headers };
  if (body) {
    options.body = JSON.stringify(body);
  }
  const res = await fetch(url, options);
  if (!res.ok) {
    const text = await res.text();
    throw new Error(`${method} ${path} failed (${res.status}): ${text}`);
  }
  if (res.status === 204) return null;
  return res.json();
}

module.exports = { request, headers, BASE_URL };

Key points:

  • Authentication: Authenticated via Authorization: Bearer {token} header
  • Content-Type: application/vnd.api+json (JSON:API specification)
  • Uses the built-in fetch in Node.js 18+ (no additional packages required)

Creating a Project

const { request } = require("./lib/client");

// Create project
const data = await request("POST", "/nodes/", {
  data: {
    type: "nodes",
    attributes: {
      title: "My Research Project",
      category: "project",
    },
  },
});

const nodeId = data.data.id;
console.log("Project ID:", nodeId);
console.log("URL:", data.data.links.html);
// => Project ID: abc12
// => URL: https://rdm.nii.ac.jp/abc12/

Updating Project Information (Description and License)

A newly created project has no description or license set. Update it with PATCH.

await request("PATCH", `/nodes/${nodeId}/`, {
  data: {
    type: "nodes",
    id: nodeId,
    attributes: {
      description: "Enter your project description here.",
      node_license: {
        copyright_holders: ["Your Organization"],
        year: "2026",
      },
    },
    relationships: {
      license: {
        data: { type: "licenses", id: "5f8935e4b8b8270007b1efaa" },
      },
    },
  },
});

The list of available licenses can be obtained with GET /v2/licenses/. The main IDs are as follows.

LicenseID
CC-By Attribution 4.05f8935e4b8b8270007b1efaa
CC0 1.0 Universal5f8935e4b8b8270007b1efac
MIT License5f8935e5b8b8270007b1efb4

Creating and Updating Wikis

Creating a Wiki Page

Create a wiki page with POST /nodes/{node_id}/wikis/. Specify the initial content in Markdown via the content attribute.

const wiki = await request("POST", `/nodes/${nodeId}/wikis/`, {
  data: {
    type: "wikis",
    attributes: {
      name: "home",
      content: "# My Research Project\n\nProject overview goes here.",
    },
  },
});

const wikiId = wiki.data.id;
console.log("Wiki ID:", wikiId);

Updating Wiki Content

Wiki content is updated by creating a new version via POST. It cannot be updated directly with PATCH.

await request("POST", `/wikis/${wikiId}/versions/`, {
  data: {
    type: "wiki-versions",
    attributes: {
      content: "# My Research Project\n\nUpdated content goes here.",
    },
  },
});

!

Note: The home page cannot be deleted or renamed. Content changes are made by adding versions.

Retrieving Wiki Content

const res = await fetch(
  `https://api.rdm.nii.ac.jp/v2/wikis/${wikiId}/content/`,
  { headers: { Authorization: `Bearer ${TOKEN}` } }
);
const content = await res.text(); // Returns Markdown text

Adding Members

Adding by User ID

await request("POST", `/nodes/${nodeId}/contributors/`, {
  data: {
    type: "contributors",
    attributes: {
      permission: "write",  // "read" | "write" | "admin"
      bibliographic: true,
    },
    relationships: {
      users: { data: { type: "users", id: "user-id" } },
    },
  },
});

Inviting by Email Address

Users who do not have a GakuNin RDM account can also be invited by email.

await request("POST", `/nodes/${nodeId}/contributors/`, {
  data: {
    type: "contributors",
    attributes: {
      full_name: "Taro Yamada",
      email: "yamada@example.com",
      permission: "write",
      bibliographic: true,
    },
  },
});

GitHub Integration + Vercel Auto-Deploy

From here, we will build a system where uploading files to RDM automatically deploys to Vercel using GakuNin RDM’s GitHub Add-on.

Overall Flow

GakuNin RDM (Storage)
    ↕ GitHub Add-on (bidirectional sync)
GitHub Repository
    ↓ Triggered by push
Vercel (automatic build & deploy)
Public site (https://your-project.vercel.app)

1. Creating a GitHub Repository

First, create a GitHub repository for the integration.

gh repo create your-org/your-repo --public --clone

2. Configuring the GakuNin RDM GitHub Add-on

The GitHub Add-on configuration cannot be done via API, so it must be set up through the Web UI.

  1. Open the project page (e.g., https://rdm.nii.ac.jp/{node_id}/)
  2. Navigate to Settings -> Add-ons
  3. Enable GitHub and authenticate your GitHub account
  4. Select the repository and branch to link

!

The Add-on configuration requires an OAuth authentication flow, so it cannot currently be operated via API.

Once configured, the contents of the GitHub repository will appear in GakuNin RDM’s file storage. When files are added or updated on RDM, the changes are reflected in the GitHub repository as well.

3. Linking Vercel with the GitHub Repository

Configure this from the Vercel dashboard.

  1. Log in to Vercel -> Add New Project
  2. Import the GitHub repository created earlier
  3. Configure build settings (auto-detected based on framework)
  4. Deploy

With just this, Vercel will automatically build and deploy whenever there is a push to the GitHub repository.

4. Verification

You can verify the automatic deployment with the following flow.

  1. Upload a file to the GitHub storage on the GakuNin RDM project page
  2. A commit is automatically created in the GitHub repository
  3. Vercel detects the push and automatically builds and deploys
  4. The public site is updated within seconds to minutes
Upload file on RDM
  → Auto-commit to GitHub
    → Vercel auto-deploys
      → Site update complete

Use Cases

For example, in a project that manages research data (XML, JSON) and a web frontend in the same repository, researchers can simply update data on RDM to automatically update the website, without needing technical knowledge.

API Operations Summary

Here is a list of operations supported by the Node.js client created in this article.

OperationMethodEndpoint
Create projectPOST/v2/nodes/
Update projectPATCH/v2/nodes/{id}/
Delete projectDELETE/v2/nodes/{id}/
Create wikiPOST/v2/nodes/{id}/wikis/
Update wikiPOST/v2/wikis/{id}/versions/
Get wiki contentGET/v2/wikis/{id}/content/
Add memberPOST/v2/nodes/{id}/contributors/
Remove memberDELETE/v2/nodes/{id}/contributors/{user_id}/
List licensesGET/v2/licenses/
List filesGET/v2/nodes/{id}/files/{provider}/
!

Add-on management (GitHub integration, etc.) cannot be operated with a PAT (returns 403). Please configure through the Web UI.

Conclusion

The GakuNin RDM API conforms to the OSF APIv2 and allows a wide range of operations from project creation to various configurations in JSON:API format. By combining the GitHub Add-on with Vercel, you can build a pipeline from research data management to website publication.

The code from this article is available at:

https://github.com/nakamura196/grdm-api-client

References