Site iconAxway Blog

Deploy an API Builder container to Railway

Deploy an API Builder Container to Railway

In a prior blog post we looked at how to deploy API Builder Docker containers on Heroku. At the time, Heroku had a “Free and Hobby” plan, but recently announced that this plan is going away and that they will not offer free plans.

A great alternative, Railway, offers a trial plan with 500 hours of run time. This is useful for development, testing and proof of concepts. It supports the following:

How to deploy an API Builder container to Railway

For this tutorial, you will need a working API Builder application tested and working in Docker and a Railway account that can be created by linking Railway to your Github account.

In this blog post, I will use the API Builder Stock Watchlist API project described here.

The basic steps are:

Unfortunately, there is no way to pause your app so as soon as it’s deployed, you are using your pool of 500 hours. However, you will see how easy it is to spin up your app so you can just delete it and re-deploy it as needed.

We will describe the steps from start to finish, and when we are done we will have an API deployed in Railway that can be publicly accessed over the internet.

Create a new Railway project

Generate a domain

As described here, Railway will detect that your app is listening for traffic. This can take several minutes.

Test your API

curl --location --request GET 'https://apibwatchlist-production.up.railway.app/api/watchlist?stocklist=aapl,txn,intc,amzn,t' --header 'accept: application/json' --header 'apikey: <API KEY YOU SET AS AN ENVIRONMENT VARIABLE>'

with result:

[
  {
    "symbol": "AAPL",
    "lastPrice": 157.96,
    "change": 0.7400055
  },
  {
    "symbol": "TXN",
    "lastPrice": 166.16,
    "change": 0.94999695
  },
  {
    "symbol": "INTC",
    "lastPrice": 31.76,
    "change": -0.15999985
  },
  {
    "symbol": "AMZN",
    "lastPrice": 127.82,
    "change": 1.050003
  },
  {
    "symbol": "T",
    "lastPrice": 17.5,
    "change": -0.040000916
  }
]

Summary

As we saw in this blog post, Railway makes it incredibly easy to deploy and test an API Builder Docker image from a Github repo.

Need help with API Builder? Extend your skills with Axway University.

Exit mobile version