kaken_api package
Subpackages
Submodules
kaken_api.cache module
Cache module for the KAKEN API client.
- class kaken_api.cache.ResponseCache(cache_dir=None, enabled=True)[source]
Bases:
object
Cache for API responses.
- Parameters:
cache_dir (str | None)
enabled (bool)
- get(url)[source]
Get a cached response for the given URL.
- Parameters:
url (str) – The URL.
- Returns:
The cached response, or None if not found.
- Return type:
bytes | None
kaken_api.client module
Main client for the KAKEN API.
- class kaken_api.client.KakenApiClient(app_id=None, timeout=30, max_retries=3, session=None, use_cache=True, cache_dir=None)[source]
Bases:
object
Client for the KAKEN API.
This client provides access to the KAKEN API, which allows searching for research projects and researchers funded by KAKEN (Grants-in-Aid for Scientific Research).
Example
>>> from kaken_api import KakenApiClient >>> client = KakenApiClient(app_id="your_app_id") >>> projects = client.projects.search(keyword="人工知能") >>> for project in projects.projects: ... print(project.title)
- Parameters:
app_id (str | None)
timeout (int)
max_retries (int)
session (Session | None)
use_cache (bool)
cache_dir (str | None)
kaken_api.constants module
Constants for the KAKEN API client.
kaken_api.exceptions module
Exceptions for the KAKEN API client.
- exception kaken_api.exceptions.KakenApiError(message, response=None)[source]
Bases:
Exception
Base exception for all KAKEN API errors.
- exception kaken_api.exceptions.KakenApiRequestError(message, response=None)[source]
Bases:
KakenApiError
Exception raised when there is an error with the request.
- exception kaken_api.exceptions.KakenApiResponseError(message, response=None)[source]
Bases:
KakenApiError
Exception raised when there is an error with the response.
- exception kaken_api.exceptions.KakenApiAuthError(message, response=None)[source]
Bases:
KakenApiError
Exception raised when there is an authentication error.
- exception kaken_api.exceptions.KakenApiRateLimitError(message, response=None)[source]
Bases:
KakenApiError
Exception raised when the API rate limit is exceeded.
- exception kaken_api.exceptions.KakenApiNotFoundError(message, response=None)[source]
Bases:
KakenApiError
Exception raised when a resource is not found.
kaken_api.models module
Data models for the KAKEN API client.
- class kaken_api.models.KakenApiResponse(raw_data, total_results=None, start_index=None, items_per_page=None)[source]
Bases:
object
Base class for KAKEN API responses.
- Parameters:
raw_data (Any)
total_results (int | None)
start_index (int | None)
items_per_page (int | None)
- raw_data: Any
- total_results: int | None = None
- start_index: int | None = None
- items_per_page: int | None = None
- class kaken_api.models.Institution(name, code=None, type=None)[source]
Bases:
object
Institution information.
- Parameters:
name (str)
code (str | None)
type (str | None)
- name: str
- code: str | None = None
- type: str | None = None
- class kaken_api.models.Department(name, code=None)[source]
Bases:
object
Department information.
- Parameters:
name (str)
code (str | None)
- name: str
- code: str | None = None
- class kaken_api.models.JobTitle(name, code=None)[source]
Bases:
object
Job title information.
- Parameters:
name (str)
code (str | None)
- name: str
- code: str | None = None
- class kaken_api.models.Affiliation(institution=None, department=None, job_title=None, start_date=None, end_date=None)[source]
Bases:
object
Affiliation information.
- Parameters:
institution (Institution | None)
department (Department | None)
job_title (JobTitle | None)
start_date (datetime | None)
end_date (datetime | None)
- institution: Institution | None = None
- department: Department | None = None
- start_date: datetime | None = None
- end_date: datetime | None = None
- class kaken_api.models.PersonName(full_name, family_name=None, given_name=None, family_name_reading=None, given_name_reading=None)[source]
Bases:
object
Person name information.
- Parameters:
full_name (str)
family_name (str | None)
given_name (str | None)
family_name_reading (str | None)
given_name_reading (str | None)
- full_name: str
- family_name: str | None = None
- given_name: str | None = None
- family_name_reading: str | None = None
- given_name_reading: str | None = None
- class kaken_api.models.Researcher(id=None, name=None, affiliations=<factory>, researcher_number=None, erad_researcher_number=None, jglobal_id=None, researchmap_id=None, orcid=None, projects=<factory>, products=<factory>, raw_data=None)[source]
Bases:
object
Researcher information.
- Parameters:
id (str | None)
name (PersonName | None)
affiliations (List[Affiliation])
researcher_number (str | None)
erad_researcher_number (str | None)
jglobal_id (str | None)
researchmap_id (str | None)
orcid (str | None)
projects (List[Project])
products (List[Product])
raw_data (Any)
- id: str | None = None
- name: PersonName | None = None
- affiliations: List[Affiliation]
- researcher_number: str | None = None
- erad_researcher_number: str | None = None
- jglobal_id: str | None = None
- researchmap_id: str | None = None
- orcid: str | None = None
- raw_data: Any = None
- class kaken_api.models.ResearcherRole(researcher, role, participate=None)[source]
Bases:
object
Researcher role information.
- Parameters:
researcher (Researcher)
role (str)
participate (str | None)
- researcher: Researcher
- role: str
- participate: str | None = None
- class kaken_api.models.Category(name, path=None, code=None)[source]
Bases:
object
Category information.
- Parameters:
name (str)
path (str | None)
code (str | None)
- name: str
- path: str | None = None
- code: str | None = None
- class kaken_api.models.Field(name, path=None, code=None, field_table=None)[source]
Bases:
object
Field information.
- Parameters:
name (str)
path (str | None)
code (str | None)
field_table (str | None)
- name: str
- path: str | None = None
- code: str | None = None
- field_table: str | None = None
- class kaken_api.models.Keyword(text, language=None)[source]
Bases:
object
Keyword information.
- Parameters:
text (str)
language (str | None)
- text: str
- language: str | None = None
- class kaken_api.models.ProjectStatus(status_code, date=None, note=None)[source]
Bases:
object
Project status information.
- Parameters:
status_code (str)
date (datetime | None)
note (str | None)
- status_code: str
- date: datetime | None = None
- note: str | None = None
- class kaken_api.models.PeriodOfAward(start_date=None, end_date=None, start_fiscal_year=None, end_fiscal_year=None)[source]
Bases:
object
Period of award information.
- Parameters:
start_date (datetime | None)
end_date (datetime | None)
start_fiscal_year (int | None)
end_fiscal_year (int | None)
- start_date: datetime | None = None
- end_date: datetime | None = None
- start_fiscal_year: int | None = None
- end_fiscal_year: int | None = None
- class kaken_api.models.AwardAmount(total_cost=None, direct_cost=None, indirect_cost=None, fiscal_year=None, currency='JPY', planned=False)[source]
Bases:
object
Award amount information.
- Parameters:
total_cost (int | None)
direct_cost (int | None)
indirect_cost (int | None)
fiscal_year (int | None)
currency (str | None)
planned (bool)
- total_cost: int | None = None
- direct_cost: int | None = None
- indirect_cost: int | None = None
- fiscal_year: int | None = None
- currency: str | None = 'JPY'
- planned: bool = False
- class kaken_api.models.Project(id=None, award_number=None, title=None, title_en=None, title_abbreviated=None, categories=<factory>, fields=<factory>, institutions=<factory>, keywords=<factory>, period_of_award=None, project_status=None, project_type=None, allocation_type=None, members=<factory>, award_amounts=<factory>, raw_data=None)[source]
Bases:
object
Project information.
- Parameters:
id (str | None)
award_number (str | None)
title (str | None)
title_en (str | None)
title_abbreviated (str | None)
categories (List[Category])
fields (List[Field])
institutions (List[Institution])
keywords (List[Keyword])
period_of_award (PeriodOfAward | None)
project_status (ProjectStatus | None)
project_type (str | None)
allocation_type (str | None)
members (List[ResearcherRole])
award_amounts (List[AwardAmount])
raw_data (Any)
- id: str | None = None
- award_number: str | None = None
- title: str | None = None
- title_en: str | None = None
- title_abbreviated: str | None = None
- institutions: List[Institution]
- period_of_award: PeriodOfAward | None = None
- project_status: ProjectStatus | None = None
- project_type: str | None = None
- allocation_type: str | None = None
- members: List[ResearcherRole]
- award_amounts: List[AwardAmount]
- raw_data: Any = None
- class kaken_api.models.ProductIdentifier(type, value, authenticated=False)[source]
Bases:
object
Product identifier information.
- Parameters:
type (str)
value (str)
authenticated (bool)
- type: str
- value: str
- authenticated: bool = False
- class kaken_api.models.ProductAuthor(name, sequence=None, researcher_id=None)[source]
Bases:
object
Product author information.
- Parameters:
name (str)
sequence (int | None)
researcher_id (str | None)
- name: str
- sequence: int | None = None
- researcher_id: str | None = None
- class kaken_api.models.Product(id=None, type=None, title=None, title_en=None, authors=<factory>, journal_title=None, journal_title_en=None, volume=None, issue=None, pages=None, publication_date=None, language=None, reviewed=False, invited=False, foreign=False, open_access=False, acknowledgement=False, joint_international=False, identifiers=<factory>, raw_data=None)[source]
Bases:
object
Product information.
- Parameters:
id (str | None)
type (str | None)
title (str | None)
title_en (str | None)
authors (List[ProductAuthor])
journal_title (str | None)
journal_title_en (str | None)
volume (str | None)
issue (str | None)
pages (str | None)
publication_date (datetime | None)
language (str | None)
reviewed (bool)
invited (bool)
foreign (bool)
open_access (bool)
acknowledgement (bool)
joint_international (bool)
identifiers (List[ProductIdentifier])
raw_data (Any)
- id: str | None = None
- type: str | None = None
- title: str | None = None
- title_en: str | None = None
- authors: List[ProductAuthor]
- journal_title: str | None = None
- journal_title_en: str | None = None
- volume: str | None = None
- issue: str | None = None
- pages: str | None = None
- publication_date: datetime | None = None
- language: str | None = None
- reviewed: bool = False
- invited: bool = False
- foreign: bool = False
- open_access: bool = False
- acknowledgement: bool = False
- joint_international: bool = False
- identifiers: List[ProductIdentifier]
- raw_data: Any = None
- class kaken_api.models.ProjectsResponse(raw_data, total_results=None, start_index=None, items_per_page=None, projects=<factory>)[source]
Bases:
KakenApiResponse
Response for projects search.
- Parameters:
raw_data (Any)
total_results (int | None)
start_index (int | None)
items_per_page (int | None)
projects (List[Project])
- class kaken_api.models.ResearchersResponse(raw_data, total_results=None, start_index=None, items_per_page=None, researchers=<factory>)[source]
Bases:
KakenApiResponse
Response for researchers search.
- Parameters:
raw_data (Any)
total_results (int | None)
start_index (int | None)
items_per_page (int | None)
researchers (List[Researcher])
- researchers: List[Researcher]
- class kaken_api.models.ProductsResponse(raw_data, total_results=None, start_index=None, items_per_page=None, products=<factory>)[source]
Bases:
KakenApiResponse
Response for products search.
- Parameters:
raw_data (Any)
total_results (int | None)
start_index (int | None)
items_per_page (int | None)
products (List[Product])
kaken_api.utils module
Utility functions for the KAKEN API client.
- kaken_api.utils.build_url(base_url, params)[source]
Build a URL with query parameters.
- Parameters:
base_url (str) – The base URL.
params (Dict[str, Any]) – The query parameters.
- Returns:
The URL with query parameters.
- Return type:
str
- kaken_api.utils.ensure_list(value)[source]
Ensure that a value is a list.
- Parameters:
value (List | Any) – The value to ensure is a list.
- Returns:
The value as a list.
- Return type:
List
- kaken_api.utils.clean_text(text)[source]
Clean text by removing extra whitespace.
- Parameters:
text (str | None) – The text to clean.
- Returns:
The cleaned text.
- Return type:
str | None
Module contents
KAKEN API Client Library for Python.
This library provides a Python interface to the KAKEN (Grants-in-Aid for Scientific Research) API.
- class kaken_api.KakenApiClient(app_id=None, timeout=30, max_retries=3, session=None, use_cache=True, cache_dir=None)[source]
Bases:
object
Client for the KAKEN API.
This client provides access to the KAKEN API, which allows searching for research projects and researchers funded by KAKEN (Grants-in-Aid for Scientific Research).
Example
>>> from kaken_api import KakenApiClient >>> client = KakenApiClient(app_id="your_app_id") >>> projects = client.projects.search(keyword="人工知能") >>> for project in projects.projects: ... print(project.title)
- Parameters:
app_id (str | None)
timeout (int)
max_retries (int)
session (Session | None)
use_cache (bool)
cache_dir (str | None)