Skip to content

Instantly share code, notes, and snippets.

@nikhilweee
Last active June 27, 2024 02:12
Show Gist options
  • Save nikhilweee/9efd9731880104dd00ecf2ed8effacc5 to your computer and use it in GitHub Desktop.
Save nikhilweee/9efd9731880104dd00ecf2ed8effacc5 to your computer and use it in GitHub Desktop.
Get vehicle info from an Indian registration number
import sys
import requests
from bs4 import BeautifulSoup, SoupStrainer
home_url = 'https://parivahan.gov.in/rcdlstatus/'
post_url = 'https://parivahan.gov.in/rcdlstatus/vahan/rcDlHome.xhtml'
# Everything before the last four digits: MH02CL
first = sys.argv[1]
# The last four digits: 0555
second = sys.argv[2]
r = requests.get(url=home_url)
cookies = r.cookies
soup = BeautifulSoup(r.text, 'html.parser')
viewstate = soup.select('input[name="javax.faces.ViewState"]')[0]['value']
data = {
'javax.faces.partial.ajax':'true',
'javax.faces.source': 'form_rcdl:j_idt32',
'javax.faces.partial.execute':'@all',
'javax.faces.partial.render': 'form_rcdl:pnl_show form_rcdl:pg_show form_rcdl:rcdl_pnl',
'form_rcdl:j_idt32':'form_rcdl:j_idt32',
'form_rcdl':'form_rcdl',
'form_rcdl:tf_reg_no1': first,
'form_rcdl:tf_reg_no2': second,
'javax.faces.ViewState': viewstate,
}
r = requests.post(url=post_url, data=data, cookies=cookies)
soup = BeautifulSoup(r.text, 'html.parser')
table = SoupStrainer('tr')
soup = BeautifulSoup(soup.get_text(), 'html.parser', parse_only=table)
print(soup.get_text())

Programmatically extract owner info from Indian registration numbers

Usage

$ python registration_info.py MH02CL 0555
Registration No:
MH02CL0555
Registration Date:
20-Jan-2012

Chasi No:
WBAKB42080CY83879
Engine No:
16257849

Owner Name: 
SHAH RUKH KHAN

Vehicle Class: 
LMVIMP
Fuel Type:
PETROL

Maker Model:
BMW INDIA PVT. LTD., BMW 740 L I PETROL

Requirements

requests
beautifulsoup4
@AndroidSoftClub
Copy link

Yes is Work

@vish1234-art
Copy link

it shows index out of value

@Shashwat-05
Copy link

it shows index out of value

check whether the query u gave is right !1
and yes , if anyone found better api source
, mention here

@ashishbudhraja
Copy link

You can Check once for www.apiclub.in

@krishna2917
Copy link

www.apiclub.in
High price per request

@chiru952
Copy link

i want to api vahan info data base

@dhanish-jose
Copy link

You can Check once for www.apiclub.in

ApiClub is asking for 10K just for account activation which is non refundable

@dhanish-jose
Copy link

Can you suggest lower price alternative per request?

Im also looking for an alternative

@prasanna1780
Copy link

Please write to [email protected] : we have rc api at a competitive price

@ak4zh
Copy link

ak4zh commented Feb 1, 2023

I have built a vehicle api for my personal use case using multiple sources.
You can test at https://t.me/VehicleDetailsBot

(sharing as a telegram bot and not an api to keep it free and prevent from abuse)
Some values are obfuscated but can be made available.

@prathams96
Copy link

has anyone figured out a new source for this?

@ZOROsrk
Copy link

ZOROsrk commented Feb 25, 2024

Came across this RC API on Rapid Api, it contains more than 200 fields in the Response and is not expensive as well. After a lot of RnD this seems to be the only RC API that gives real time data and covers all most all the data at a reasonable price.

https://rapidapi.com/aitanlabs0/api/rto-vehicle-information-verification-india

@JaiminPatel345
Copy link

I have built a vehicle api for my personal use case using multiple sources. You can test at https://t.me/VehicleDetailsBot

(sharing as a telegram bot and not an api to keep it free and prevent from abuse) Some values are obfuscated but can be made available.

how this bot works ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment