> For the complete documentation index, see [llms.txt](https://til.aldrinjenson.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.aldrinjenson.com/tools-and-workflow/fetching-train-availability-in-irctc.md).

# Fetching train availability in IRCTC

### Problem

When you search for trains in [irctc](https://www.irctc.co.in) page, it never shows the seat availability directly. You'll have to manually go and click the refresh button of every listed train

<figure><img src="/files/wfiJdpkkDXXqMtHFr5lf" alt=""><figcaption><p>List of trains, but availability is not present</p></figcaption></figure>

### Steps to fix

1. Search for trains in <https://www.irctc.co.in>
2. Apply filters to narrow down the list of trains

   <figure><img src="/files/19TPzjipnWWIXwKU9y4N" alt=""><figcaption><p>Narrow down list of trains using filters</p></figcaption></figure>
3. Paste the following script in console to get the availability status of all trains at once

```javascript
document.querySelectorAll('.fa.fa-repeat').forEach(el=>el.click())
```

4. The end. Tada!

### Note:

Ensure that you always try this out after narrowing down the list using filters. Else it'll be too many requests going on at once.
