Railway's GraphQL API lets you deploy, manage, and scale applications programmatically. No dashboard clicking required — everything from project creation to environment variables can be automated.
Getting Started
Generate an API token at railway.app/account/tokens, then:
curl -X POST https://backboard.railway.app/graphql/v2 \
-H "Authorization: Bearer $RAILWAY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "{ me { name email } }"}'
Key Operations
List Projects
query {
projects {
edges {
node {
id
name
environments {
edges {
node { id name }
}
}
}
}
}
}
Deploy from GitHub
mutation {
serviceCreate(input: {
projectId: "your-project-id"
source: { repo: "user/repo" }
}) {
id
name
}
}
Set Environment Variables
mutation {
variableUpsert(input: {
projectId: "proj-id"
environmentId: "env-id"
serviceId: "svc-id"
name: "DATABASE_URL"
value: "postgres://..."
})
}
Scale a Service
mutation {
serviceInstanceUpdate(input: {
serviceId: "svc-id"
environmentId: "env-id"
numReplicas: 3
})
}
Building a Deploy CLI
import requests
RAILWAY_URL = "https://backboard.railway.app/graphql/v2"
TOKEN = "your-token"
def railway_query(query, variables=None):
r = requests.post(RAILWAY_URL,
headers={"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"},
json={"query": query, "variables": variables or {}}
)
return r.json()
# Get all projects
projects = railway_query('{ projects { edges { node { id name } } } }')
for p in projects["data"]["projects"]["edges"]:
print(f"{p['node']['name']} ({p['node']['id']})")
Why This Matters
Railway's API enables:
- GitOps pipelines that deploy on merge without Railway's built-in CI
- Multi-environment management from scripts
- Cost monitoring by querying usage metrics
- Platform engineering tools for team self-service
Need custom deployment automation or cloud infrastructure tools? I build developer tools and data pipelines. Check out my web scraping actors on Apify or reach out at spinov001@gmail.com for custom solutions.
Top comments (0)