DEV Community

Alex Spinov
Alex Spinov

Posted on

Railway Has a Free API: Deploy Apps Without Thinking About Infrastructure

What is Railway?

Railway is a modern Platform-as-a-Service (PaaS) that deploys your apps directly from GitHub with zero configuration. Push code, get a URL. It supports any language, any framework, and includes databases, cron jobs, and private networking out of the box.

Why Railway?

  • $5 free credit/month — enough for small apps and side projects
  • Zero config — auto-detects language, framework, and build system
  • Instant databases — PostgreSQL, MySQL, Redis, MongoDB in one click
  • Private networking — services communicate securely without public exposure
  • CLI + API — full control programmatically

Quick Start

# Install CLI
npm install -g @railway/cli

# Login and deploy
railway login
railway init
railway up
# That's it. You have a deployed app.
Enter fullscreen mode Exit fullscreen mode

Deploy from GitHub

# Link to a GitHub repo
railway link

# Every push to main auto-deploys
git push origin main
# Railway builds and deploys automatically
Enter fullscreen mode Exit fullscreen mode

Add a Database

# Add PostgreSQL to your project
railway add -p postgresql

# Connection string is automatically injected as DATABASE_URL
# Your app just reads process.env.DATABASE_URL
Enter fullscreen mode Exit fullscreen mode

Railway API

import requests

RAILWAY_TOKEN = "your-api-token"

# Query project info via GraphQL
response = requests.post(
    "https://backboard.railway.app/graphql/v2",
    headers={"Authorization": f"Bearer {RAILWAY_TOKEN}"},
    json={
        "query": """
        query {
          me {
            projects {
              edges {
                node {
                  id
                  name
                  services {
                    edges {
                      node {
                        name
                        serviceInstances {
                          edges {
                            node {
                              domains { serviceDomains { domain } }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        """
    }
)
print(response.json())
Enter fullscreen mode Exit fullscreen mode

Environment Variables

# Set variables
railway variables set NODE_ENV=production
railway variables set API_KEY=your-secret-key

# Variables are encrypted and injected at runtime
Enter fullscreen mode Exit fullscreen mode

Cron Jobs

# Deploy a cron service
# In your railway.toml:
[deploy]
cronSchedule = "0 */6 * * *"  # Every 6 hours
Enter fullscreen mode Exit fullscreen mode

Railway vs Alternatives

Feature Railway Heroku Render Fly.io Vercel
Free tier $5/mo credit Eco $5/mo Free tier $5 credit Free
Auto-detect Yes Buildpacks Yes Dockerfile Framework
Databases PG, MySQL, Redis PG, Redis PG, Redis PG None
Private network Yes No Yes Yes No
Deploy speed ~30 sec ~2 min ~1 min ~30 sec ~15 sec
Docker support Yes Yes Yes Yes No

Real-World Impact

A solo developer was spending 10 hours/week managing a DigitalOcean droplet: updates, SSL, database backups, monitoring. Migrated 3 services to Railway: zero ops, automatic SSL, managed Postgres with backups. Those 10 hours/week went back to building features. Monthly cost went from $48 to $15.


Need hassle-free deployment for your apps? I help teams migrate to modern PaaS platforms. Contact spinov001@gmail.com or explore my data tools on Apify.

Top comments (0)