
A Real Time Information Using Andorra's Government APIs
For those who don't know it, Andorra is a tiny country of 80k people located in the Pyrenees. I've been living here for 3 years and built a guide for people moving here. The downside of living here? Snowstorms and traffic jams. Andorra only has two road entrances, so when there's heavy snow or a holiday weekend, it's chaos. You need to know which roads are clear, whether snowplows are out, and if there's an alternative route. Turns out the Andorran government has quite good public APIs. No keys or auth, so I used them to make my life easier. Architecture Built this with Next.js on Vercel. Each API route caches for 3 minutes so I don't overload the government APIs: let cache = null ; const CACHE_TTL = 3 * 60 * 1000 ; export async function GET () { if ( cache && Date . now () - cache . timestamp < CACHE_TTL ) { return NextResponse . json ( cache ); } const data = await fetch ( ` ${ MOBILITAT_BASE } /cameras` ). then ( r => r . json ()); cache = { ... data , timestamp : Date . now () }; r
Continue reading on Dev.to
Opens in a new tab



![[MM’s] Boot Notes — The Day Zero Blueprint — Test Smarter on Day One](/_next/image?url=https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1368%2F1*AvVpFzkFJBm-xns4niPLAA.png&w=1200&q=75)