This article explains how to programmatically retrieve information from the KAKEN (Grants-in-Aid for Scientific Research) database.
1. Introduction
KAKEN is a database for Grants-in-Aid for Scientific Research provided by the National Institute of Informatics (NII). By using the OpenSearch API, you can programmatically retrieve information about research projects.
2. Preparation: Obtaining an Application ID
To use the KAKEN API, you need to obtain an Application ID from CiNii.
- Access the CiNii API Registration page
- Fill in the required information and submit your registration request
- After approval, you will receive an Application ID (appid) by email
Note: It may take some time from registration to approval.
3. API Endpoints
Search for Research Projects
https://kaken.nii.ac.jp/opensearch/
Search for Researchers
https://nrid.nii.ac.jp/opensearch/
4. Main Parameters (Search for Research Projects)
| Parameter | Description | Required | Example |
|---|---|---|---|
appid | Application ID | Yes | 82RKpPlZiIjbqKwFDO3D |
qb | Search by project number | * | 19K20626 |
kw | Free keyword search | * | IIIF |
qa | Search by project title | * | デジタルアーカイブ |
qg | Search by researcher name | * | 中村覚 |
qm | Search by researcher number | * | 80802743 |
format | Response format | - | xml (default: html5) |
rw | Number of items per page | - | 20, 50, 100, 200, 500 |
lang | Language | - | ja, en |
*: At least one of these is required
Other Search Parameters
| Parameter | Description |
|---|---|
qc | Search by research category |
qd | Search by review section/research field |
qe | Search by research institution |
s1, s2 | Search by grant period (From/To) |
qf | Search by keyword |
For details, please refer to the official documentation.
5. Usage Examples
Example 1: Search by Project Number
curl "https://kaken.nii.ac.jp/opensearch/?appid=YOUR_APPID&qb=19K20626&format=xml"
Example 2: Search by Keyword
curl "https://kaken.nii.ac.jp/opensearch/?appid=YOUR_APPID&kw=IIIF&format=xml&rw=50"
Example 3: Search by Researcher Number
curl "https://kaken.nii.ac.jp/opensearch/?appid=YOUR_APPID&qm=80802743&format=xml"
6. Response Format
When format=xml is specified, an XML response like the following is returned.
Response Example (19K20626)
<?xml version="1.0" encoding="UTF-8"?>
<grantAwards>
<totalResults>1</totalResults>
<startIndex>1</startIndex>
<itemsPerPage>20</itemsPerPage>
<grantAward id="KAKENHI-PROJECT-19K20626"
recordSet="kakenhi"
projectType="project"
awardNumber="19K20626">
<urlList>
<url>https://kaken.nii.ac.jp/grant/KAKENHI-PROJECT-19K20626/</url>
</urlList>
<summary xml:lang="ja">
<title>IIIFとTEIを用いたオンライン翻刻支援システムの開発</title>
<awardNumber awardNumber="19K20626" sequence="1"/>
<category niiCode="252">若手研究</category>
<member sequence="1" eradCode="80802743" role="principal_investigator">
<institution>東京大学</institution>
<department>史料編纂所</department>
<jobTitle>助教</jobTitle>
<personalName sequence="1">
<fullName>中村 覚</fullName>
<familyName yomi="ナカムラ">中村</familyName>
<givenName yomi="サトル">覚</givenName>
</personalName>
<enriched>
<researcherNumber type="erad">80802743</researcherNumber>
</enriched>
</member>
<projectStatus fiscalYear="2022" statusCode="project_closed"/>
<keywordList>
<keyword sequence="1">IIIF</keyword>
<keyword sequence="2">TEI</keyword>
<keyword sequence="3">RDF</keyword>
<keyword sequence="4">OCR</keyword>
<keyword sequence="5">Omeka</keyword>
<keyword sequence="6">人文情報学</keyword>
<keyword sequence="7">デジタルアーカイブ</keyword>
<keyword sequence="8">翻刻</keyword>
</keywordList>
<periodOfAward>
<startDate>2019-04-01</startDate>
<endDate>2023-03-31</endDate>
</periodOfAward>
<overallAwardAmount>
<directCost>3500000</directCost>
<indirectCost>1050000</indirectCost>
<totalCost>4550000</totalCost>
</overallAwardAmount>
</summary>
</grantAward>
</grantAwards>
7. Main Information Available
| Element | Description |
|---|---|
awardNumber | Project number |
title | Research project title |
category | Research category (Early-Career Research, Grant-in-Aid for Scientific Research, etc.) |
member | Researcher information (name, affiliation, researcher number, role) |
projectStatus | Project status (granted: ongoing, project_closed: completed) |
keywordList | Keywords |
periodOfAward | Research period |
overallAwardAmount | Budget allocation (direct costs, indirect costs, total) |
paragraphList | Research summary |
Researcher Roles (role attribute)
| Value | Description |
|---|---|
principal_investigator | Principal Investigator |
co_investigator_buntan | Co-Investigator (sharing responsibilities) |
co_investigator_renkei | Co-Investigator (collaboration) |
8. Programmatic Usage Examples
JavaScript/TypeScript (Next.js)
type KakenMember = {
name: string;
researcherId: string;
role: 'pi' | 'coi';
institution: string;
department: string;
jobTitle?: string;
};
type KakenProject = {
grantId: string;
title: string;
category?: string;
period?: { start?: string; end?: string };
members: KakenMember[];
keywords?: string[];
};
async function fetchKakenProject(
grantId: string,
appId: string
): Promise<KakenProject | null> {
const url = new URL('https://kaken.nii.ac.jp/opensearch/');
url.searchParams.set('appid', appId);
url.searchParams.set('qb', grantId);
url.searchParams.set('format', 'xml');
const response = await fetch(url.toString());
if (!response.ok) return null;
const xml = await response.text();
return parseKakenXml(xml, grantId);
}
function parseKakenXml(xml: string, grantId: string): KakenProject | null {
// XML parsing logic
// ...
}
Python
import requests
import xml.etree.ElementTree as ET
def fetch_kaken_project(grant_id: str, app_id: str) -> dict | None:
url = "https://kaken.nii.ac.jp/opensearch/"
params = {
"appid": app_id,
"qb": grant_id,
"format": "xml"
}
response = requests.get(url, params=params)
if response.status_code != 200:
return None
root = ET.fromstring(response.content)
# XML parsing logic
# ...
# Usage example
project = fetch_kaken_project("19K20626", "YOUR_APPID")
9. Notes
- Comply with Terms of Use: Avoid making a large number of requests in a short period of time
- Use Caching: If you need to retrieve the same data repeatedly, use caching
- About Affiliation Information: The affiliation available through the API is from the time the grant was awarded. It may differ from the current affiliation
- Error Handling: Implement fallback processing for cases when the API is unavailable