Transport for Sao Paulo, Brazil API

Varies by plan (check documentation)

Overview

The SPTrans Olho Vivo API provides real-time bus tracking data for São Paulo's massive municipal bus system in Brazil, one of the largest in the world. Authentication uses OAuth and requires registering on the SPTrans developer portal to receive credentials. Once authenticated, you can track bus positions, find arrivals at stops, and query route information.

💡

Beginner Tip

Start by calling the authentication endpoint with your credentials to obtain a session token, then use that token in a cookie for all subsequent requests. The API documentation (in Portuguese) is available at sptrans.com.br and explains all available endpoints with parameter details.

Available Data

match scores and results
team standings
player statistics
schedule and fixtures
Use case: Integrate sptrans data into web and mobile applications

Example Response

JSON Response
{
  "route": "Line 1",
  "origin": "Station A",
  "destination": "Station B",
  "departure": "08:30",
  "arrival": "09:15",
  "status": "On Time",
  "delays_min": 0
}

Field Reference

hr Timestamp of the data snapshot in HH:MM format, indicating when the position data was last captured.
l List of active bus lines, each containing the line code, destination, and list of vehicle positions.
c Line code identifier for the bus route, such as 8000-10.
lt0 Primary destination sign text for the bus line, indicating the main terminus.
vs Array of vehicles (buses) currently active on the line, each with GPS coordinates and prefix ID.
py Latitude coordinate of the bus vehicle in decimal degrees, used to plot it on a map.

Implementation Example

const url = "http://www.sptrans.com.br/desenvolvedores/api-do-olho-vivo-guia-de-referencia/documentacao-api/";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "Authorization": "Bearer YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

"false" returned by the authentication endpoint The token (API key) is incorrect or the account is not yet approved by SPTrans.
Register at sptrans.com.br/desenvolvedores and wait for approval; use the exact token provided in your confirmation email.
Empty bus position results No buses are actively transmitting GPS data for the requested line at that moment.
Query during peak hours (7-10 AM or 5-8 PM) and verify the line code using the Linha endpoint to ensure the route is active.
Session expired after short idle time The SPTrans API session cookie expires after a period of inactivity.
Re-authenticate before each session or implement automatic re-login when you receive an authentication error response.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 10/20
🔒 Security 5/15
🛠 Developer XP 3/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth OAuth
HTTPS NO
CORS UNKNOWN
Category Transportation
Difficulty Advanced
Verified: 2026-04-04

Similar APIs

View All →