All Projects → nikhilkumarsingh → pyinrail

nikhilkumarsingh / pyinrail

Licence: MIT license
A python wrapper for Indian Railways Enquiry API!

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pyinrail

python-crawler
爬虫学习仓库,适合零基础的人学习,对新手比较友好
Stars: ✭ 37 (-7.5%)
Mutual labels:  requests
angular-http-cache
Speed up your remote requests by automatically caching them on client and add support for offline navigation.
Stars: ✭ 25 (-37.5%)
Mutual labels:  requests
proxy ip pool
python编写的爬虫代理ip池
Stars: ✭ 18 (-55%)
Mutual labels:  requests
Geolocator-2
Learn how to find and work with locations in Django, the Yelp API, and Google Maps api.
Stars: ✭ 24 (-40%)
Mutual labels:  requests
flatland-challenge-starter-kit
⚠️ NOTICE: This starter kit was used for 2019 challenge and has been deprecated in favour of 2020 Flatland challenge's starter kit present here
Stars: ✭ 17 (-57.5%)
Mutual labels:  trains
requestsR
R interface to Python requests module
Stars: ✭ 12 (-70%)
Mutual labels:  requests
covid-19
Data ETL & Analysis on the global and Mexican datasets of the COVID-19 pandemic.
Stars: ✭ 14 (-65%)
Mutual labels:  requests
go-tesseract-ocr-service
Golang based microservice for OCR powered by Tesseract.
Stars: ✭ 35 (-12.5%)
Mutual labels:  tesseract-ocr
requests
http requests lib for golang
Stars: ✭ 67 (+67.5%)
Mutual labels:  requests
cpython
Alternative StdLib for Nim for Python targets, hijacks Python StdLib for Nim
Stars: ✭ 75 (+87.5%)
Mutual labels:  python-api
crawler
requests+lxml爬虫,简单爬虫架构
Stars: ✭ 72 (+80%)
Mutual labels:  requests
Email-Crawler-Lead-Generator
This email crawler will visit all pages of a provided website and parse and save emails found to a csv file.
Stars: ✭ 47 (+17.5%)
Mutual labels:  requests
Anjani
🤖 Telegram group management bot with spam protection
Stars: ✭ 45 (+12.5%)
Mutual labels:  tesseract-ocr
python3-concurrency
Python3爬虫系列的理论验证,首先研究I/O模型,分别用Python实现了blocking I/O、nonblocking I/O、I/O multiplexing各模型下的TCP服务端和客户端。然后,研究同步I/O操作(依序下载、多进程并发、多线程并发)和异步I/O(asyncio)之间的效率差别
Stars: ✭ 49 (+22.5%)
Mutual labels:  requests
bestfetch
fetch ⭐️caching ⭐️deduplication
Stars: ✭ 44 (+10%)
Mutual labels:  requests
gists
Methods for working with the GitHub Gist API. Node.js/JavaScript
Stars: ✭ 96 (+140%)
Mutual labels:  requests
premeStock
Monitors for restocks
Stars: ✭ 53 (+32.5%)
Mutual labels:  requests
jr
Putting the "train" in training
Stars: ✭ 58 (+45%)
Mutual labels:  trains
htmx-talk-2021
Code examples and slides from my 2021 talk Server-Side is Dead! Long Live Server-Side (+ HTMX), presented at DjangoCon and Code Code Code
Stars: ✭ 18 (-55%)
Mutual labels:  requests
wc18-cli
An easy command line interface for the 2018 World Cup
Stars: ✭ 15 (-62.5%)
Mutual labels:  requests

PyPI license

pyinrail

A python wrapper for Indian Railways Enquiry API!

  • Get trains between stations
  • Get seat availability
  • Get train fare
  • Get train schedule
  • Get train live running status
  • Get PNR status

...and much more!

Note: This is not an official package and using it for commercial purposes is not recommended.

Installation

To install pyinrail, simply,

$ pip install pyinrail

You will also need to install tesseract-ocr. Find instructions to install tesseract-ocr here.

Usage

  • Importing pyinrail
from pyinrail import pyinrail
  • Create RailwayEnquiry object
enq = pyinrail.RailwayEnquiry(src='new delhi', dest='ahmedabad', date='12-05-2018')
  • Get trains between stations
df = enq.get_trains_between_stations(as_df=True)
print(df)
         trainName trainNumber fromStnCode toStnCode departureTime arrivalTime duration  distance        avlClasses
0  ADI SJ RAJDHANI       12958        NDLS       ADI         19:55       09:40    13:45       935      [1A, 2A, 3A]
1  GUJRAT S KRANTI       12918         NZM       ADI         13:55       06:10    16:15      1085      [2A, 3A, SL]
2   ASHRAM EXPRESS       12916         DLI       ADI         15:20       07:40    16:20       934  [1A, 2A, 3A, SL]
3   ALA HAZRAT EXP       14311         DLI       ADI         11:45       06:15    18:30       933      [2A, 3A, SL]
4     YOGA EXPRESS       19032         DSA       ADI         21:26       17:10    19:44       963  [1A, 2A, 3A, SL]
5  DEE BDTS G RATH       12215         DEE       ADI         09:20       01:10    15:50       951              [3A]
  • Get seat availability
df = enq.get_seat_availability(12958, classc='2A', as_df=True)
print(df)
  availablityDate availablityStatus  availablityType currentBkgFlag reason reasonType  waitListType
0       12-5-2018    TRAIN DEPARTED             8224              Y                 W          8224
1       13-5-2018       GNWL68/WL24             8224              N                 S             9
2       14-5-2018        GNWL41/WL8             8224              N                 S             9
3       15-5-2018        GNWL25/WL6             8224              N                 S             9
4       16-5-2018       GNWL33/WL14             8224              N                 S             9
5       17-5-2018        GNWL20/WL9             8224              N                 S             9
  • Get train schedule
df = enq.get_train_schedule(12958, as_df=True)
print(df)
   stationCode   stationName departureTime arrivalTime routeNumber haltTime distance dayCount stnSerialNumber
0         NDLS     NEW DELHI         19:55          --           1       --        0        1               1
1          DEC   DELHI CANTT         20:25       20:23           1    02:00       16        1               2
2          GGN       GURGAON         20:43       20:41           1    02:00       32        1               3
3           JP        JAIPUR         00:30       00:20           1    10:00      309        2               4
4          AII      AJMER JN         02:29       02:25           1    04:00      443        2               5
5           FA         FALNA         04:53       04:52           1    01:00      650        2               6
6          ABR      ABU ROAD         06:05       06:01           1    04:00      748        2               7
7          PNU   PALANPUR JN         07:12       07:10           1    02:00      801        2               8
8          MSH   MAHESANA JN         08:05       08:03           1    02:00      866        2               9
9         SBIB  SABARMATI BG         09:02       09:00           1    02:00      929        2              10
10         ADI  AHMEDABAD JN            --       09:40           1       --      935        2              11
  • Get train fare
fare_data = enq.get_train_fare(12958, classc='2A')
print(fare_data)
{'baseFare': 1841,
 'cateringCharge': 225,
 'dynamicFare': 921,
 'fuelAmount': 0.0,
 'goodsServiceTax': 143.0,
 'otherCharge': 0,
 'reservationCharge': 50,
 'superfastCharge': 45,
 'tatkalFare': 0,
 'totalCollectibleAmount': 3225.0,
 'totalConcession': 0,
 'totalFare': 3225,
 'travelInsuranceCharge': 0.0,
 'travelInsuranceServiceTax': 0.0,
 'wpServiceCharge': 0.0,
 'wpServiceTax': 0.0}
  • Get train's live running status
train_detail, instances, detailed_instances = enq.get_train_status(12958, as_df=True)
print(train_detail)
print(instances)
print(detailed_instances[0])
{'dayCnt': '1',
 'from': 'NDLS',
 'runsOn': '1111111',
 'schArrTime': '09:40',
 'schDepTime': '19:55',
 'to': 'ADI',
 'trainName': 'ADI SJ RAJDHANI',
 'trainNo': '12958'}


     startDate  departed curStn  terminated        lastUpdated  totalLateMins
0  12 May 2018      True     RE       False  12 May 2018 21:43              6
1  11 May 2018      True    ADI        True   12 May 2018 9:27            -14


   stnCode    arr schArrTime actArr  delayArr    dep schDepTime actDep  delayDep  dayCnt  schDayCnt  distance
0     NDLS  False      00:00  00:00         0   True      19:55  19:55         0       0          0         0
1      DEC   True      20:23  20:27         4   True      20:25  20:29         4       0          0        15
2      GGN   True      20:41  20:47         6   True      20:43  20:49         6       0          0        32
3       RE   True      21:30  21:41        11   True      21:30  21:41        11       0          0        83
4       JP  False      00:20  00:20         0  False      00:30  00:30         0       1          1       308
5      AII  False      02:25  02:25         0  False      02:29  02:29         0       1          1       442
6       FA  False      04:52  04:52         0  False      04:53  04:53         0       1          1       649
7      ABR  False      06:01  06:01         0  False      06:05  06:05         0       1          1       747
8      PNU  False      07:10  07:10         0  False      07:12  07:12         0       1          1       800
9      MSH  False      08:03  08:03         0  False      08:05  08:05         0       1          1       865
10    SBIB  False      09:00  09:00         0  False      09:02  09:02         0       1          1       927
11     ADI  False      09:40  09:40         0  False      00:00  00:00         0       1          1       934

TODOs

  • A command line client
  • A GUI interface

Want to contribute?

  • Clone the repository

     $ git clone http://github.com/nikhilkumarsingh/pyinrail
    
  • Install dependencies

     $ pip install -r requirements.txt
    
  • To test local version of pyinrail:

     $ pip install -U .
    

    OR :

     $ pip install -e <project dir.> .
    
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].