wikipedia-sdk
v1.0.1
Published
A typescript wikipedia SDK
Readme
Wikipedia SDK
A TypeScript SDK for interacting with the Wikipedia API. This SDK provides a simple and type-safe way to access Wikipedia's content and user data.
Features
- 📚 Page Services
- Get page summaries
- Fetch full page content
- Retrieve pages by ID
- 👥 User Services
- Get user information
- Fetch user contributions
- 🌐 Multi-language Support
- Configure the SDK for any Wikipedia language version
- 📦 Type Safety
- Full TypeScript support with comprehensive type definitions
Installation
npm install wikipedia-sdk
# or
yarn add wikipedia-sdkUsage
Initialize the Client
import { WikipediaClient } from 'wikipedia-sdk';
const client = new WikipediaClient({
language: 'en', // Language code for the Wikipedia version (e.g., 'en', 'fr', 'es')
});Page Services
// Get a page summary
const summary = await client.pages.getSummary({
title: 'Albert Einstein',
});
// Get full page content
const content = await client.pages.getContent({
title: 'Albert Einstein',
});
// Get page by ID
const page = await client.pages.getPageById({
pageId: 736,
options: {
prop: ['info', 'extracts'],
redirects: true,
},
});User Services
// Get user information
const user = await client.users.get({
username: 'Example',
options: {
usprop: 'blockinfo|groups|editcount|registration|emailable|gender',
},
});
// Get user contributions
const contributions = await client.users.getContributions({
username: 'Example',
options: {
uclimit: 10,
ucprop: ['ids', 'title', 'timestamp', 'comment'],
},
});Documentation
Detailed API documentation is available in the TypeDoc generated documentation.
Development
# Install dependencies
yarn install
# Build the project
yarn build
# Run tests
yarn test
# Generate documentation
yarn docs
# Lint and format code
yarn lint
yarn formatContributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Leo Dumon ([email protected])
