Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: suryavaddiraju/irctc-api
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.7
Choose a base ref
...
head repository: suryavaddiraju/irctc-api
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.8
Choose a head ref
  • 6 commits
  • 7 files changed
  • 2 contributors

Commits on Apr 20, 2024

  1. Updated Readme

    More brief explaination and added broken links issue
    suryavaddiraju committed Apr 20, 2024
    Copy the full SHA
    c8dc12c View commit details
  2. Merge pull request #3 from suryavaddiraju/development

    Updated Readme
    suryavaddiraju authored Apr 20, 2024
    Copy the full SHA
    d6f25c6 View commit details
  3. update for github pages

    update correct part for github page
    suryavaddiraju committed Apr 20, 2024
    Copy the full SHA
    5625ebd View commit details
  4. Merge pull request #4 from suryavaddiraju/development

    update for github pages
    suryavaddiraju authored Apr 20, 2024
    Copy the full SHA
    05f2b7c View commit details

Commits on Apr 21, 2024

  1. Added Global UTC Support

    The function now supports users to book train tickets from anywhere in the world by following IRCTC timings
    suryavaddiraju committed Apr 21, 2024
    Copy the full SHA
    4072549 View commit details
  2. Merge pull request #5 from suryavaddiraju/development

    Added Global UTC Support
    suryavaddiraju authored Apr 21, 2024
    Copy the full SHA
    55fc42e View commit details
Showing with 87 additions and 35 deletions.
  1. +2 −0 .npmignore
  2. +30 −18 README.md
  3. +21 −0 api_reference.md
  4. +17 −0 contribution.md
  5. +14 −14 lib/time_work.mjs
  6. +1 −1 lib/workings.mjs
  7. +2 −2 package.json
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -2,3 +2,5 @@
examples/
test/
.gitignore
api_reference.md
contribution.md
48 changes: 30 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
# irctc-api
A package built on top of IRCTC Website APIs to make train tickets , managing user profile faster and simpler. Currently this package only works on NodeJs environment and we were not recommending this to use on browser or any other Javascript environment.
A package built on top of IRCTC Website APIs to book train tickets, managing user profile faster and simpler. Currently this package only works on NodeJs environment and we were not recommending this to use on browser or any other Javascript environment.

[![NPM Downloads](https://img.shields.io/npm/dw/irctc-api)](https://www.npmjs.com/package/irctc-api)
[![Node Current](https://img.shields.io/node/v/irctc-api)](https://www.npmjs.com/package/irctc-api)
[![Contributors](https://img.shields.io/github/contributors/suryavaddiraju/irctc-api.svg)](https://github.com/suryavaddiraju/irctc-api/graphs/contributors)
[![GitHub License](https://img.shields.io/github/license/suryavaddiraju/irctc-api)](http://www.apache.org/licenses/LICENSE-2.0)
[![NPM Version](https://img.shields.io/npm/v/irctc-api)](https://www.npmjs.com/package/irctc-api)
[![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/suryavaddiraju/irctc-api)](https://github.com/suryavaddiraju/irctc-api/issues)
[![GitHub last commit](https://img.shields.io/github/last-commit/suryavaddiraju/irctc-api)](https://github.com/suryavaddiraju/irctc-api)

## Useful Links

<a href="https://github.com/suryavaddiraju/irctc-api"><img src="https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png" alt="GitHub Logo" width="50" height="50"/></a> <a href="https://www.npmjs.com/package/irctc-api"><img src="https://upload.wikimedia.org/wikipedia/commons/d/db/Npm-logo.svg" alt="npm Logo" width="50" height="50"/></a> <a href="https://dev.vaddiraju.in/irctc-api/api_reference"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Read-the-docs.png/330px-Read-the-docs.png" alt="Documentation Logo" width="50" height="50"/></a>

## Installing

To install the this package, simply type i or install irctc-api using the node package manager

- `npm install irctc-api`
```shell
npm install irctc-api
```

## Prerequisite

This Package uses [viu](https://github.com/atanunq/viu), A rust module uses iterm image protocol for displaying images.
This Package uses [viu](https://github.com/atanunq/viu), A rust module uses iterm image protocol for displaying images within System Terminal.

We use that for displaying captcha images on command line for login and bookings as to make your booking flow in a seamless way.

Hence you are required to download the viu executable file related to your OS and Processor Architecture from the [viu release Assets](https://github.com/atanunq/viu/releases/latest) then add the folder where the `viu` is stored in your environment variables.
Hence you are required to download the viu executable file related to your OS and Processor Architecture from the [viu release Assets](https://github.com/atanunq/viu/releases/latest) then add the folder where the `viu` is stored to your environment variables.

Remeber to add the folder path and not the viu.exe file path in your environment variables.

@@ -24,8 +38,8 @@ Remeber to add the folder path and not the viu.exe file path in your environment

- We request to verify whether viu is working or not by giving the below command

```console
$ viu example.jpeg -t
```shell
viu example.jpeg -t
```

### Import
@@ -43,7 +57,7 @@ To send a request, you only need to import the `IRCTC`.
const { IRCTC } = require("irctc-api");
```

```ts
```js
// ES6+ example
import { IRCTC } from "irctc-api";
```
@@ -91,13 +105,13 @@ as compared to using Promise chains or callbacks.
## Getting Help

Please use these community resources for getting help.
We use the GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.
We use the [GitHub issues](https://github.com/suryavaddiraju/irctc-api/issues) for tracking bugs and feature requests, but have limited bandwidth to address them.

- Visit [Developer Guide](https://example.com/developer_guide.html) or [API Reference](https://example.com/api_reference.html).
- Visit [API Reference](https://dev.vaddiraju.in/irctc-api/api_reference).

## Contributing

Any modifications will be overwritten the next time the `irctc-api` package is updated. To contribute to the package you can check our [generate clients scripts](https://example.com/generate-clients.html).
Any modifications will be overwritten the next time the `irctc-api` package is updated. To contribute to the package you can check our [contribution](https://dev.vaddiraju.in/irctc-api/contribution) page.

## License

@@ -111,23 +125,21 @@ see LICENSE for more information.
<summary>
book
</summary>

[Command API Reference](https://example.com/api_reference.html#book) / [Input](https://example.com/api_reference.html#book_input) / [Output](https://example.com/api_reference.html#book_output)

<a href="https://dev.vaddiraju.in/irctc-api/api_reference#book">Command API Reference</a> / <a href="https://dev.vaddiraju.in/irctc-api/api_reference#book_input">Input</a> / <a href="https://dev.vaddiraju.in/irctc-api/api_reference#book_output">Output</a>
</details>
<details>
<summary>
last_transaction
</summary>

[Command API Reference](https://example.com/api_reference.html#last_transaction) / [Input](https://example.com/api_reference.html#last_transaction_input) / [Output](https://example.com/api_reference.html#last_transaction_output)

<a href="https://dev.vaddiraju.in/irctc-api/api_reference#last_transaction">Command API Reference</a> / <a href="https://dev.vaddiraju.in/irctc-api/api_reference#last_transaction_input">Input</a> / <a href="https://dev.vaddiraju.in/irctc-api/api_reference#last_transaction_output">Output</a>
</details>
<details>
<summary>
pnr_status
</summary>
<a href="https://dev.vaddiraju.in/irctc-api/api_reference#pnr_status">Command API Reference</a> / <a href="https://dev.vaddiraju.in/irctc-api/api_reference#pnr_status_input">Input</a> / <a href="https://dev.vaddiraju.in/irctc-api/api_reference#pnr_status_output">Output</a>
</details>

[Command API Reference](https://example.com/api_reference.html#pnr_status) / [Input](https://example.com/api_reference.html#pnr_status_input) / [Output](https://example.com/api_reference.html#pnr_status_output)
## Copyright

</details>
All Rights Reserved. &copy; Vaddiraju Surya Teja, 2024
21 changes: 21 additions & 0 deletions api_reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
layout: page
title: "API Reference | irctc-api | A Node Js Package to book tickets within system terminal"
permalink: /api_reference
---

# API Reference

To install the this package, simply type i or install irctc-api using the node package manager

```shell
npm install irctc-api
```

## Useful Links

<a href="https://github.com/suryavaddiraju/irctc-api"><img src="https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png" alt="GitHub Logo" width="50" height="50"/></a> <a href="https://www.npmjs.com/package/irctc-api"><img src="https://upload.wikimedia.org/wikipedia/commons/d/db/Npm-logo.svg" alt="npm Logo" width="50" height="50"/></a> <a href="https://dev.vaddiraju.in/irctc-api/api_reference"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Read-the-docs.png/330px-Read-the-docs.png" alt="Documentation Logo" width="50" height="50"/></a>

## Copyright

All Rights Reserved. &copy; Vaddiraju Surya Teja, 2024
17 changes: 17 additions & 0 deletions contribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
layout: page
title: "Contribution | irctc-api | A Node Js Package to book tickets within system terminal"
permalink: /contribution
---

# Contribution

You need to fork the repository and then rasie a pull request and when the pull request is approved your changes will be applied to next scheduled release

## Useful Links

<a href="https://github.com/suryavaddiraju/irctc-api"><img src="https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png" alt="GitHub Logo" width="50" height="50"/></a> <a href="https://www.npmjs.com/package/irctc-api"><img src="https://upload.wikimedia.org/wikipedia/commons/d/db/Npm-logo.svg" alt="npm Logo" width="50" height="50"/></a> <a href="https://dev.vaddiraju.in/irctc-api/api_reference"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Read-the-docs.png/330px-Read-the-docs.png" alt="Documentation Logo" width="50" height="50"/></a>

## Copyright

All Rights Reserved. &copy; Vaddiraju Surya Teja, 2024
28 changes: 14 additions & 14 deletions lib/time_work.mjs
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@ function sleep(ms){
async function sleep_for_login(ticket_time){
if (ticket_time === 1 || ticket_time === 2){
if (ticket_time === 1){
const targetTime = new Date();
targetTime.setHours(9, 58, 0, 0); // Set target time to 09:58:00.000 AM
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 28, 0, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
}
@@ -16,9 +16,9 @@ async function sleep_for_login(ticket_time){
}
}
else if (ticket_time === 2){
const targetTime = new Date();
targetTime.setHours(10, 58, 0, 0); // Set target time to 10:58:00.000 AM
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 28, 0, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
}
@@ -38,17 +38,17 @@ async function sleep_for_login(ticket_time){
async function sleep_for_availability_check(ticket_time){
if (ticket_time === 1 || ticket_time === 2){
if (ticket_time === 1){
const targetTime = new Date();
targetTime.setHours(10, 0, 1, 0); // Set target time to 10:00:00.000 AM
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 30, 1, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
}
}
if (ticket_time === 2){
const targetTime = new Date();
targetTime.setHours(11, 0, 1, 0); // Set target time to 11:00:00.000 AM
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 30, 1, 0);
if (currentTime < targetTime) {
await sleep(targetTime - currentTime);
}
@@ -63,22 +63,22 @@ async function sleep_for_availability_check(ticket_time){
}
function start_before_3_minutes(ticket_time){
if (ticket_time === 1) {
const targetTime = new Date();
targetTime.setHours(9, 57, 0, 0);
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(4, 27, 0, 0);
if (currentTime < targetTime) {
throw new Error("Please Start the booking after 09:57:00.000 AM");
throw new Error("Please Start the booking after 09:57:00.000 AM IST");
}
else{
return "Proceeding to Book Tickets";
}
}
else if (ticket_time === 2) {
const targetTime = new Date();
targetTime.setHours(10, 57, 0, 0);
const currentTime = new Date();
const targetTime = new Date(currentTime);
targetTime.setUTCHours(5, 27, 0, 0);
if (currentTime < targetTime) {
throw new Error("Please Start the booking after 10:57:00.000 AM");
throw new Error("Please Start the booking after 10:57:00.000 AM IST");
}
else{
return "Proceeding to Book Tickets";
2 changes: 1 addition & 1 deletion lib/workings.mjs
Original file line number Diff line number Diff line change
@@ -310,7 +310,7 @@ class IRCTC{
headers['spa-csrf-token'] = this.csrf_token;
headers.bmiyek = this.user_hash;
headers["Content-Length"] = postdata_string.length.toString();
await sleep(22000);
await sleep(21000);
const response = await this.axios_instance.post(
"https://www.irctc.co.in/eticketing/protected/mapps1/allLapAvlFareEnq/Y",
postdata_string,
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "irctc-api",
"description": "A package built on top of IRCTC Website APIs to make train tickets , managing user profile faster and simpler. Currently this package only works on NodeJs environment and we were not recommending this to use on browser or any other Javascript environment.",
"version": "1.0.7",
"description": "An exclusive NodeJs only package built on top of IRCTC Website APIs to book train tickets, managing user profile faster and simpler from anywhere in the world",
"version": "1.0.8",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},