DEV Community

Alex Spinov
Alex Spinov

Posted on

Railway Has a Free API You Should Know About

Railway deploys anything from a Git repo — and its GraphQL API lets you manage infrastructure programmatically.

The GraphQL API

# List projects
query {
  me {
    projects {
      edges {
        node {
          id
          name
          environments {
            edges {
              node {
                name
                deployments(first: 1) {
                  edges {
                    node {
                      status
                      createdAt
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Deploy via API

# Trigger a deployment
curl -X POST https://backboard.railway.app/graphql/v2 \
  -H "Authorization: Bearer $RAILWAY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "mutation { serviceDeploymentRedeploy(input: { environmentId: "ENV_ID", serviceId: "SVC_ID" }) { id status } }"
  }'
Enter fullscreen mode Exit fullscreen mode

One-Click Services

# Deploy PostgreSQL
railway add --plugin postgresql

# Deploy Redis
railway add --plugin redis

# Your app gets connection strings as env vars automatically
Enter fullscreen mode Exit fullscreen mode

Environment Variables API

# Set variables
curl -X POST https://backboard.railway.app/graphql/v2 \
  -H "Authorization: Bearer $RAILWAY_TOKEN" \
  -d '{
    "query": "mutation { variableUpsert(input: { projectId: "...", environmentId: "...", serviceId: "...", name: "API_KEY", value: "secret123" }) }"
  }'
Enter fullscreen mode Exit fullscreen mode

railway.json — Infrastructure as Code

{
  "$schema": "https://railway.app/railway.schema.json",
  "build": { "builder": "NIXPACKS" },
  "deploy": {
    "startCommand": "node dist/server.js",
    "healthcheckPath": "/health",
    "restartPolicyType": "ON_FAILURE"
  }
}
Enter fullscreen mode Exit fullscreen mode

Real-World Use Case

A team was using Heroku for 3 services + add-ons (PostgreSQL, Redis, cron). Monthly bill: $75. After Heroku killed free tier, they moved to Railway: same setup, connected via internal networking, preview environments per PR. Monthly bill: $10. Migration took 1 hour.

Railway is Heroku done right for 2026.


Build Smarter Data Pipelines

Need to scrape websites, extract APIs, or automate data collection? Check out my ready-to-use scrapers on Apify — no coding required.

Custom scraping solution? Email me at spinov001@gmail.com — fast turnaround, fair prices.

Top comments (0)