annict-graphql
v1.0.0-beta.19
Published
Annict GraphQL API client library for JavaScript.
Readme
annict-graphql
Annict GraphQL API client library for JavaScript
[!WARNING] The Annict GraphQL API is currently in beta.
Install
npm install annict-graphqlUsage
import { AnnictClient } from "annict-graphql";
const annict = new AnnictClient("<ANNICT_ACCESS_TOKEN>");
const viewer = await annict.Viewer.get();
console.log(`${viewer.name} (@${viewer.username})`);
// Output:
// Shimba, Koji (@shimbaco)More examples for every endpoint are available in examples/.
Viewer
Viewer.get()Viewer.library()Viewer.records()Viewer.works()Viewer.programs()Viewer.followers()Viewer.following()
User
Search and node lookup
Node.get()/Node.getMany()Work.search()Episode.search()Character.search()Person.search()Organization.search()
Mutations
OAuth
OAuth
For applications acting on behalf of other users, use AnnictOAuth to
implement the OAuth 2.0 flow
instead of a personal access token.
import { AnnictOAuth, AnnictClient } from "annict-graphql";
const oauth = new AnnictOAuth({
clientId: "<CLIENT_ID>",
clientSecret: "<CLIENT_SECRET>",
redirectUri: "urn:ietf:wg:oauth:2.0:oob",
});
const authorizeUrl = oauth.getAuthorizeUrl({ scope: "read write" });
// redirect the user to authorizeUrl, then:
const token = await oauth.token({ code: "<AUTH_CODE>" });
const annict = new AnnictClient(token.accessToken);See oauth-flow.ts for a full example.
Migrating from annict.js
If you're coming from annict.js (a REST API client, no longer maintained), see MIGRATION.md for a mapping of methods and parameters.
Contributing
See CONTRIBUTING.md.
