Getting Started
Install halchemy using the package manager of your chosen language:
bash
pip install halchemy
bash
npm install halchemy
bash
gem install halchemy
In your code, create an Api
object with the URL of your API.
python
from halchemy import Api
api = Api('http://example.org/api')
root = api.root.get() # get the root resource
people = api.follow(root).to('people').get() # follow the people rel to get the list of people
# Issue a refund of $5 to everyone
for person in people['_items']:
account = api.follow(person).to('account').get()
api.follow(account).to('deposit').post({'amount':5.00})
javascript
import { Api } from 'halchemy'
const api = new Api('http://example.org/api')
const root = api.root.get() // get the root resource
const people = api.follow(root).to('people').get() // follow the people rel to get the list of people
// Issue a refund of $5 to everyone
for (const person of people._items) {
const account = async api.follow(person).to('account').get()
async api.follow(account).to('deposit').post({amount:5.00})
}
ruby
require "halchemy"
api = Halchemy::Api.new "http://example.org/api"
root = api.root.get # get the root resource
people = api.follow(root).to("people").get # follow the people rel to get the list of people
# Issue a refund of $5 to everyone
people["_items"].each do |person|
account = api.follow(person).to("account").get
api.follow(account).to("deposit").post("amount"=> 5.00)
end