Project

halchemy

0.0
The project is in a healthy, maintained state
Do you have an API that serves data following the HAL specification? The **halchemy** library makes it easy for your client to make the most of that API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

halchemy

HAL for humans

Do you have an API that serves data following the HAL specification? The halchemy library makes it easy for your client to make the most of that API.

Getting Started

Install halchemy using the package manager of your chosen language:

Python

pip install halchemy

Javascript

npm install halchemy

Ruby

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})
    print(f"{person['name']} has a new balance of ${account['balance']}")

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})
    console.log(`${person.name} has a new balance of ${account.balance}`)
}

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

Read the docs to learn more!