A TypeScript library that provides a simple and easy-to-use wrapper for accessing the Shikimori API. The library supports all endpoints and types of the Shikimori API and provides OAuth2 authorization functionality using an access token.
See the node-shikimori API documentation rendered with TypeDoc.
See the official documentation for the Shikimori API.
$ npm i --save node-shikimori
$ yarn add node-shikimori
To use the library, simply import it into your project and create an instance of a client
. You can then use the various methods provided by the client
to access the Shikimori API.
import { client } from 'node-shikimori';
const shikimori = client();
const result = await shikimori.animes.byId({
id: 1
});
console.log(result);
For more additional information see the Official Shikimori OAuth2 Guide.
Register your Shikimori Application: This will provide you with a client_id
and client_secret
that you will need to use OAuth2.
Redirect user to the Shikimori authorization endpoint: This endpoint will prompt the user to grant your application access to their resources. After the user grants access, Shikimori will redirect them back to your application with an authorization code.
https://shikimori.one/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&scope=
AccessToken
. Shikimori will respond with an access token that your application can use to access the restricted resources/endpoints.import { auth } from 'node-shikimori';
const { getAccessToken } = auth({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
});
const accessToken = await getAccessToken('YOUR_AUTH_CODE');
const shikimori = client();
shikimori.setAccessToken(YOUR_ACCESS_TOKEN);
const currentUser = await shikimori.users.whoami();
console.log(currentUser)
5.Refresh access token: Access tokens have a limited lifespan of 1 day, so your application will need to refresh them periodically to maintain access to the user's resources. To do this use a refreshAccessToken
function with the refresh token. Shikimori will respond with a new access token and refresh token that your application can use to continue accessing the user's resources.
const newAccessToken = await refreshAccessToken('YOUR_REFRESH_TOKEN');
Contributions to this library are always welcome and highly encouraged.
This library is licensed under MIT. Please see LICENSE for licensing details.
Generated using TypeDoc