This guide provides a process for directly inspecting Railway services using the GraphQL API, bypassing the Railway CLI which has authentication limitations in the current environment.
The Railway CLI (railway command) does NOT work with RAILWAY_API_TOKEN in the current environment, despite documentation suggesting otherwise. However, direct GraphQL API calls work perfectly.
We've created scripts/railway_inspect.py - a Python script that provides comprehensive Railway service inspection capabilities using the GraphQL API directly.
# Ensure requests library is installed
pip install requests
# Set your Railway API token
export RAILWAY_API_TOKEN="your-token-here"The easiest way to inspect the yoto-smart-stream service:
python scripts/railway_inspect.py interactiveThis automatically:
- Finds the yoto-smart-stream service
- Shows project and environment details
- Displays recent production deployments
- Shows latest deployment logs
Example Output:
🔍 Finding yoto-smart-stream service...
✅ Found service!
Project: zippy-encouragement (f92d5fa2-484e-4d93-9b1f-91c33cc33d0e)
Service: yoto-smart-stream (e63186e3-4ff7-4d6f-b448-a5b5e1590e79)
Environments:
• production (c4477d57-96c3-49b5-961d-a456819dedf2)
• yoto-smart-stream-pr-49 (159c71a2-74ce-4bca-ac71-c8ab2a13d829)
• yoto-smart-stream-pr-50 (72f83a58-1146-453b-8b3d-5a1a5d3c03b2)
📦 Recent Production Deployments:
✅ SUCCESS: 2026-01-11 16:16:49 UTC
URL: https://yoto-smart-stream-production.up.railway.app
📋 Recent Logs (latest 20 lines):
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8080
...
python scripts/railway_inspect.py list-projectspython scripts/railway_inspect.py list-services \
--project-id f92d5fa2-484e-4d93-9b1f-91c33cc33d0e# All deployments in a project
python scripts/railway_inspect.py deployments \
--project-id f92d5fa2-484e-4d93-9b1f-91c33cc33d0e \
--limit 10
# Deployments for a specific environment
python scripts/railway_inspect.py deployments \
--project-id f92d5fa2-484e-4d93-9b1f-91c33cc33d0e \
--environment production \
--limit 5# Get logs from a specific deployment
python scripts/railway_inspect.py logs \
--deployment-id 45bbeb97-238c-480d-ba0b-c2a13e7d72f6 \
--limit 100
# Raw logs (no timestamp formatting)
python scripts/railway_inspect.py logs \
--deployment-id 45bbeb97-238c-480d-ba0b-c2a13e7d72f6 \
--limit 50 \
--rawpython scripts/railway_inspect.py health \
--project-id f92d5fa2-484e-4d93-9b1f-91c33cc33d0e \
--service-id e63186e3-4ff7-4d6f-b448-a5b5e1590e79This checks:
- Latest deployment status
- Service URL accessibility
/api/healthendpoint response- Recent deployment history
-
Find the failed deployment:
python scripts/railway_inspect.py deployments \ --project-id <PROJECT_ID> \ --environment production \ --limit 10 -
Get the deployment logs:
python scripts/railway_inspect.py logs \ --deployment-id <DEPLOYMENT_ID> \ --limit 200 -
Check service health:
python scripts/railway_inspect.py health \ --project-id <PROJECT_ID> \ --service-id <SERVICE_ID>
# Quick production check
python scripts/railway_inspect.py interactive
# Detailed production deployments
python scripts/railway_inspect.py deployments \
--project-id f92d5fa2-484e-4d93-9b1f-91c33cc33d0e \
--environment production \
--limit 5
# Get latest production logs
# (first get latest deployment ID from above, then:)
python scripts/railway_inspect.py logs \
--deployment-id <LATEST_DEPLOYMENT_ID> \
--limit 100# List all environments
python scripts/railway_inspect.py list-services \
--project-id f92d5fa2-484e-4d93-9b1f-91c33cc33d0e
# Check PR-50 deployments
python scripts/railway_inspect.py deployments \
--project-id f92d5fa2-484e-4d93-9b1f-91c33cc33d0e \
--environment yoto-smart-stream-pr-50 \
--limit 3The script can be easily integrated into automated agent workflows:
#!/usr/bin/env python3
import subprocess
import json
import os
# Set token
os.environ["RAILWAY_API_TOKEN"] = "your-token-here"
# Get deployment info
result = subprocess.run(
["python", "scripts/railway_inspect.py", "deployments",
"--project-id", "f92d5fa2-484e-4d93-9b1f-91c33cc33d0e",
"--environment", "production",
"--limit", "1"],
capture_output=True,
text=True
)
print(result.stdout)
# Get logs
result = subprocess.run(
["python", "scripts/railway_inspect.py", "logs",
"--deployment-id", "45bbeb97-238c-480d-ba0b-c2a13e7d72f6",
"--limit", "50"],
capture_output=True,
text=True
)
print(result.stdout)#!/bin/bash
# Set token
export RAILWAY_API_TOKEN="your-token-here"
# Quick health check
python scripts/railway_inspect.py interactive
# Get recent logs and filter for errors
python scripts/railway_inspect.py logs \
--deployment-id "45bbeb97-238c-480d-ba0b-c2a13e7d72f6" \
--limit 200 \
--raw | grep -i errorThe script provides a RailwayInspector class that can be imported and used directly:
from scripts.railway_inspect import RailwayInspector
# Initialize
inspector = RailwayInspector(api_token="your-token")
# Or use environment variable
inspector = RailwayInspector() # Uses RAILWAY_API_TOKEN
# List projects
projects = inspector.list_projects()
# Get services
project_details = inspector.get_project_services(project_id)
# Get deployments
deployments = inspector.get_deployments(
project_id,
environment_id="...",
limit=10
)
# Get logs
logs = inspector.get_deployment_logs(deployment_id, limit=100)
# Find yoto-smart-stream automatically
result = inspector.find_yoto_project()The script uses these Railway GraphQL queries:
query {
projects {
edges {
node {
id
name
description
createdAt
}
}
}
}query($projectId: String!) {
project(id: $projectId) {
id
name
services {
edges {
node {
id
name
createdAt
}
}
}
environments {
edges {
node {
id
name
}
}
}
}
}query($input: DeploymentListInput!, $limit: Int!) {
deployments(first: $limit, input: $input) {
edges {
node {
id
status
createdAt
staticUrl
meta
}
}
}
}query($deploymentId: String!, $limit: Int!) {
deploymentLogs(deploymentId: $deploymentId, limit: $limit) {
message
timestamp
severity
}
}- zippy-encouragement:
f92d5fa2-484e-4d93-9b1f-91c33cc33d0e- Contains yoto-smart-stream service
- yoto-smart-stream:
e63186e3-4ff7-4d6f-b448-a5b5e1590e79
- production:
c4477d57-96c3-49b5-961d-a456819dedf2 - yoto-smart-stream-pr-49:
159c71a2-74ce-4bca-ac71-c8ab2a13d829 - yoto-smart-stream-pr-50:
72f83a58-1146-453b-8b3d-5a1a5d3c03b2
Set the environment variable:
export RAILWAY_API_TOKEN="your-token-here"Or create a .env file in the project root (make sure it's in .gitignore):
RAILWAY_API_TOKEN=your-token-here
Install the required dependency:
pip install requestsYour Railway API token may be invalid or expired. Generate a new one at: https://railway.app/account/tokens
The Railway API may be temporarily unavailable. Try again in a few moments.
- Works with API Tokens: Direct API access works with
RAILWAY_API_TOKEN - No Authentication Issues: Bypasses CLI login problems
- Programmatic Access: Easy to integrate into scripts and automation
- Flexible Querying: Direct GraphQL access for custom queries
- Agent-Friendly: Perfect for autonomous agent workflows
- Never commit your
RAILWAY_API_TOKENto version control - Use environment variables or secret management systems
- Rotate tokens periodically
- Use project-specific tokens when possible (scope limitation)
Created: 2026-01-11
Purpose: Direct Railway service inspection for development and troubleshooting
Method: Railway GraphQL API (bypasses CLI authentication issues)