# Search Station based on the last operator used

**URL:** <https://community.tulip.co/t/search-station-based-on-the-last-operator-used/13585>\
**Category:** Product Suggestions\
**Tags:** feature-request, station\
**Created:** [January 22, 2025, 2:47am UTC](https://community.tulip.co/t/search-station-based-on-the-last-operator-used/13585 "2025-01-22T02:47:32Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ta-aoki](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@ta-aoki](https://community.tulip.co/u/ta-aoki)\
**Post date:** [January 28, 2025, 3:48am UTC](https://community.tulip.co/t/search-station-based-on-the-last-operator-used/13585/3 "2025-01-28T03:48:21Z")

</div>

Just for the record, I can use Station API like this to search for the Stations with the user ID uD7hMd2Hpr2KiD6ZK (blue) using it.  
I can put the id of the station to the last part of the URL to open that Station. (green)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/2/251df38d7cf7e65da8f0977c63d4bf2f74e45801.png)

```auto
async function getJson(url,username,password){
    try {
        const response=await fetch(url,{headers:{Authorization: "Basic " + btoa(`${username}:${password}`)}});
    if(!response.ok){
      throw new Error(`Response status: ${response.status}`);
    }
    return await response.json();
    } catch (error) {
        console.error(error.message);
    }
}
const username='PUT_YOUR_API_KEY_HERE';
const password='PUT_YOUR_SECRET_HERE';
const url ='https://PUT_YOUR_TULIP_SERVER_HERE/api/stations/v1/w/DEFAULT/stations'
async function getAllStations(url,username,password){
    json=await getJson(url,username,password);
    items=json.items;
    while(np=json.nextPage){
        json=await getJson(np,username,password);
        items.push(... json.items); 
    }
    if(json.count != items.length){
        throw new Error(`Wrong count : ${json.count} , ${items.length}`);
    }
    return items;
}
stations=await getAllStations(url,username,password);
console.table(stations.filter(e=>e.operatorId=='uD7hMd2Hpr2KiD6ZK'));

```

---

_[View the full topic](https://community.tulip.co/t/search-station-based-on-the-last-operator-used/13585)._
