Introduction
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 automation of project operations through its API.
In this article, I introduce how to perform the following operations using the GakuNin RDM API from Node.js.
- Project creation and configuration
- Wiki creation and updating
- Adding members
- GitHub integration + automatic deployment with Vercel
Prerequisites
Obtaining a Personal Access Token
- Log in to GakuNin RDM
- Navigate to Settings > Personal Access Tokens
- Create a new token (scopes:
osf.full_read,osf.full_write)
Project Initialization
Save the token in a .env file.
Also create a .gitignore.
Creating the API Client
The GakuNin RDM API adopts the JSON:API format. First, create a generic client as lib/client.js.
Key points:
- Authentication: Authenticates with the
Authorization: Bearer {token}header - Content-Type:
application/vnd.api+json(JSON:API specification) - Uses Node.js 18+ built-in
fetch(no additional packages required)
Creating a Project
Updating Project Information (Description and License)
A newly created project has no description or license set. Update with PATCH.
The list of available licenses can be obtained with GET /v2/licenses/. The main IDs are as follows.
| License | ID |
|---|---|
| CC-By Attribution 4.0 | 5f8935e4b8b8270007b1efaa |
| CC0 1.0 Universal | 5f8935e4b8b8270007b1efac |
| MIT License | 5f8935e5b8b8270007b1efb4 |
Wiki Creation and Updating
Creating a Wiki Page
Create a Wiki page with POST /nodes/{node_id}/wikis/. Specify the initial content in Markdown using the content attribute.
Updating Wiki Content
Wiki content updates work by creating a new version via POST. Direct updates via PATCH are not supported.
!
Note: The home page cannot be deleted or renamed. Content changes are made by adding versions.
Retrieving Wiki Content
Adding Members
Adding by User ID
Inviting by Email
Users who do not have a GakuNin RDM account can also be invited by email.
0
GitHub Integration + Vercel Auto-Deploy
From here, we build a system where uploading files to RDM automatically deploys to Vercel by utilizing GakuNin RDM’s GitHub Add-on.
Overall Flow
1
1. Creating a GitHub Repository
First, create a GitHub repository for the integration.
2
2. Configuring GakuNin RDM’s GitHub Add-on
GitHub Add-on configuration cannot be done via the API, so it must be configured from the Web UI.
- Open the project page (e.g.,
https://rdm.nii.ac.jp/{node_id}/) - Navigate to Settings -> Add-ons
- Enable GitHub and authenticate your GitHub account
- Select the repository and branch to integrate
!
Since Add-on configuration requires an OAuth authentication flow, it cannot currently be operated via the API.
Once configured, the contents of the GitHub repository will be displayed in GakuNin RDM’s file storage. When files are added or updated on RDM, the changes are also reflected in the GitHub repository.
3. Connecting Vercel with the GitHub Repository
Configure from the Vercel dashboard.
- Log in to Vercel -> Add New Project
- Import the GitHub repository created earlier
- Configure build settings (auto-detected based on framework)
- Deploy
With just this, Vercel performs automatic builds and deployments triggered by pushes to the GitHub repository.
4. Verification
You can verify the auto-deploy with the following flow.
- Upload files to GitHub storage on the GakuNin RDM project page
- A commit is automatically created in the GitHub repository
- Vercel detects the push and automatically builds and deploys
- After a few tens of seconds to a few minutes, it is reflected on the published site
3
Use Cases
For example, in a project that manages research data (XML or JSON) and a web frontend in the same repository, researchers can simply update data on RDM and the website is automatically updated without requiring technical knowledge.
API Operations Summary
Here is a list of operations supported by the Node.js client created in this article.
| Operation | Method | Endpoint |
|---|---|---|
| Create project | POST | /v2/nodes/ |
| Update project | PATCH | /v2/nodes/{id}/ |
| Delete project | DELETE | /v2/nodes/{id}/ |
| Create Wiki | POST | /v2/nodes/{id}/wikis/ |
| Update Wiki | POST | /v2/wikis/{id}/versions/ |
| Get Wiki content | GET | /v2/wikis/{id}/content/ |
| Add member | POST | /v2/nodes/{id}/contributors/ |
| Remove member | DELETE | /v2/nodes/{id}/contributors/{user_id}/ |
| List licenses | GET | /v2/licenses/ |
| List files | GET | /v2/nodes/{id}/files/{provider}/ |
| ! |
Add-on management (such as GitHub integration) cannot be operated with PAT (403). Please configure from the Web UI.
Conclusion
The GakuNin RDM API conforms to OSF APIv2 and supports a wide range of operations from project creation to various settings 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