0.2.2 • Published 10 months ago
china-railway-lib v0.2.2
china-railway-lib
!WARNING This project is still in development, and its features are not yet complete. Expect any breaking changes!
This is a JavaScript/TypeScript library to provide a simple way to access the China Railway 12306 API.
This project is licensed under the terms of the MIT license.
Installation
pnpm is recommended to install this library.
pnpm add china-railway-libBuilding
This project uses pnpm as the package manager.
To build the project locally, you need to clone the repository and install the dependencies first:
git clone git@github.com:hezicyan/china-railway-lib.git
cd china-railway-lib
pnpm installThen, you can build the project by running:
pnpm buildYou can find the bundled files in the dist/ directory.
Testing
This project uses jest as the testing framework. To run the tests, run:
pnpm testUsage
import { Railway12306, PurposeCodes } from 'china-railway-lib';
const helper = new Railway12306();
const standardTrainList = await helper.getStandardTrainList(
'2025-02-05',
'BJP',
'QYS',
PurposeCodes.STUDENT,
);
console.log(standardTrainList);