donald
donald

Reputation: 23747

Heroku REST API - Is there any?

Is there a Heroku API that allows me to scale up and down my dynos programmatically, etc?

I've found the link for the API docs but it seems that it doesn't exist anymore.

Thanks

Upvotes: 1

Views: 2219

Answers (4)

anshumans
anshumans

Reputation: 4105

It appears Heroku::Client is deprecated now. heroku-api gem has the ability you need. https://github.com/heroku/heroku.rb

Upvotes: 1

Brad
Brad

Reputation: 556

The Heroku gem allows you to add and remove processes easily.

gem "heroku"

You can create a client in ruby that can set the number of workers or dynos, etc

client = Heroku::Client.new(username, password)
client.list  # provides a list of heroku apps
client.info(app) # provides info on the particular app, including dynos and workers
client.workers(app) # returns the number of workers currently running for the app
client.set_workers(app, qty) # sets the number of workers for the app
client.dynos(app) # returns the number of dynos currently running for the app
client.set_dynos(app, qty) # sets the number of dynos

Basically, anything you can do from the command line, you can do with the gem.

Checkout https://github.com/heroku/heroku/blob/master/lib/heroku/client.rb for details.

Upvotes: 4

dazl
dazl

Reputation: 91

This link works at this time for the API. For autoscaling we use hirefire. That's a hosted service which is slightly more capable than the open source gem by the same name.

Upvotes: 4

John Beynon
John Beynon

Reputation: 37507

I'm not sure there's anything documented but the heroku gem itself talks to their API over REST so you can take a peak inside that.

There are auto scaling gems out there for Heroku and I've seen other examples where you include the Heroku gem into your own app to be able to interface to their API without getting too involved of the guts of it.

Upvotes: 0

Related Questions