Library / SDK
arsduo/koala avatar
arsduo/koala

Koala returns Facebook Graph API responses as plain Hashes, and its global config is not threadsafe

A lightweight Facebook library supporting the Graph, Marketing, and Atlas APIs, realtime updates, test users, and OAuth.

3,570 stars456 forksRubyMIT

At a glance

What is it?
Koala is a Ruby gem for the Facebook Graph API, the Marketing and Atlas APIs, realtime updates, test users and OAuth. This page walks through the Graph calls, the paging and batch helpers, and the places where the documentation shows its age or states a hard limit.
Who is it for?
Use Koala when a Ruby app needs thin accessors over the Facebook Graph API that return Hashes and arrays, with OAuth and realtime subscriptions in the same gem. Avoid its global configuration in threaded code, and check the supported Ruby list, which names MRI 2.1 to 2.4, against your runtime before adopting.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 31 days ago.
What is it written in?
Mainly Ruby, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • arsduo/koala3,570 ★ · -4
Star history
Repository2026-11-032026-11-25
arsduo/koala3.6k3.6k

-4 Stars in the last 22 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Four goals: light, fast, flexible and tested

Koala is a Facebook library for Ruby. It covers the Graph API, including batch requests and photo uploads, the Marketing API, the Atlas API, realtime updates, test users and OAuth validation. The authors list four goals.

Lightweight means the gem should be as simple as Facebook's own libraries: API accessors that return simple JSON. Fast means it uses Facebook's faster read-only servers when possible and available, and the Typhoeus gem for snappy requests. Flexible means it should be useful whatever the configuration, and the stated support is every currently supported Ruby version, MRI 2.1 to 2.4, with JRuby and Rubinius expected to work. Tested means complete test coverage, using mocked responses and recorded HTTP interactions.

The repository is MIT licensed and not archived. The last push was on 2026-09-28. There are no GitHub releases, so the gem on RubyGems is the version reference.

A useful reading of the goals: Koala hands you what Facebook returns and does not wrap it in model classes. If you want typed objects per Graph node, you build them.

Two details in the goals deserve a second look. The speed claim depends on Typhoeus being installed and on Facebook offering a read-only server for the request, and both are phrased with when possible and if available, so a plain Ruby install without Typhoeus does not get the faster path. The testing claim is also scoped: the suite uses mocked responses and recorded HTTP interactions, which means it checks Koala against captured Facebook replies, not against Facebook's live API on each run.

Installation is one gem line, with Koala 3.0 described as a drop-in

The install lines are short. Under Bundler:

ruby
gem "koala"

Otherwise:

bash
[sudo|rvm] gem install koala

A note at the top of the install section says Koala 3.0 is out and that most users should see no significant changes. Anyone who hits a problem is asked to file an issue.

The cost of that sentence is that it says nothing about what did change. If you are upgrading from 2.x, the changelog.md file in the repository root is the place to look, and a pinned version in your Gemfile is the safer way to move.

The gemspec is koala.gemspec, and the tests live in spec with an .rspec file at the root, so running the suite from a checkout is a matter of the usual RSpec setup.

The top-level entries also include a Rakefile, a Gemfile, a .yardopts file for generating YARD documentation, and issue and pull request templates. The readme links to the wiki for more details and examples, so deeper usage lives outside the repository tree.

Koala.configure sets global tokens, and it is not threadsafe

Most applications use one set of credentials, so Koala accepts global settings instead of passing them on every call. In Rails, the suggested place is config/initializers/koala.rb:

ruby
# In Rails, you could put this in config/initializers/koala.rb
Koala.configure do |config|
  config.access_token = MY_TOKEN
  config.app_access_token = MY_APP_ACCESS_TOKEN
  config.app_id = MY_APP_ID
  config.app_secret = MY_APP_SECRET
  # See Koala::Configuration for more options, including details on how to send requests through
  # your own proxy servers.
end

The warning that follows is plain: this is not currently threadsafe. Pull requests are welcome as long as they support both threaded and non-threaded configuration.

The consequence is concrete. An app that serves several Facebook users from one Ruby process cannot keep a user access_token in the global block, since another thread may change it. Pass the token to Koala::Facebook::API.new per request instead, and keep only app-level values such as app_id in the global block.

Graph calls return Hashes and an array subclass that pages

Getting started needs an access token, which the project suggests getting from Facebook's Graph API Explorer by clicking Get Access Token. The client is built with Koala::Facebook::API.new(access_token), and the access token and other values are not required if you set the defaults above.

The core calls are get_object("me"), get_connections("me", "friends") and put_connections("me", "feed", message: "I am writing on my wall!"). Three-part queries work too, as in get_connections("me", "mutualfriends/#{friend_id}"), and put_connections("me", "namespace:action", object: object_url) covers the Timeline API.

The response of most requests is the JSON data returned from Facebook as a Hash. A call that returns an array, such as get_connections or search, returns a GraphCollection instead. It is a subclass of Array, so each and the usual enumerators work, and it adds next_page.

Because responses are raw Hashes, a field Facebook renames or removes surfaces as a nil in your code, not as a Koala error.

For reference, the same README also names the Facebook-hosted pages it relies on: the Graph API Explorer for tokens, and Facebook's Timeline API tutorial for the namespace:action form. Those pages belong to Facebook, and the visible README does not say which Graph API version the examples target, so test each example against the version your app is registered for before copying it.

Paging state can be stored as an array of path and arguments

GraphCollection makes paging cheap in a single request. feed.next_page fetches the next page of results. For web apps there is a second route:

ruby
next_page_params = feed.next_page_params
page = @graph.get_page(next_page_params)

next_page_params returns an array describing the URL for the next page, as [path, arguments]. That is useful for storing page state across multiple browser requests, such as putting it in a session or a query string, then handing it back to get_page on the next request.

What this gives you is a way to build a Load more button without keeping the earlier collection in memory. What it does not give you is any cache or retry, because Koala returns what Facebook returns. A stored next_page_params array can hold a token or expire on Facebook's side, and the documentation shows no handling for that case.

Batch calls and post-processing blocks avoid pulling results apart by index

Facebook's batch API is exposed through a block:

ruby
# Returns an array of results as if they were called non-batch
@graph.batch do |batch_api|
  batch_api.get_object('me')
  batch_api.put_wall_post('Making a post in a batch.')
end

The result is an array in call order, as if each call had been made on its own.

Every Graph API method also accepts a post-processing block. It can modify the result, as in get_object("me") { |data| data['education'] }, which returns only the education portion of the profile. It can also consume the data in place, which matters most in a batch: each call gets its own block, such as batch_api.get_connections('me', 'photos') with a block that assigns self.photos.

The gain is that results land directly in the variable that needs them, so you do not index into a long array of responses. The cost is that each block runs as the batch resolves, so an exception inside one block is your code's failure mode to handle.

The batch example in the project uses put_wall_post, a method name that mirrors the wall-posting vocabulary of an earlier Facebook platform. Check that any helper you copy still maps to an endpoint your app is permitted to call.

App tokens, signed requests and realtime updates share the OAuth and Realtime classes

An application's own access token, usable without a user session for subscriptions and certain other requests, comes from the OAuth class:

ruby
@oauth = Koala::Facebook::OAuth.new(app_id, app_secret, callback_url)
@oauth.get_app_access_token

For apps built on Facebook, parse_signed_request(signed_request_string) parses signed requests.

Realtime updates let Facebook reach out to you. The RealtimeUpdates class is built with app_id and secret, and also supports the global defaults. subscribe("user", "first_name, last_name", callback_url, verify_token) adds or modifies a subscription, list_subscriptions returns one hash per subscribed object, and unsubscribe("user") removes one. A static method, meet_challenge(params, your_verify_token), returns the hub.challenge parameter when the verify token in params matches.

Which objects you can subscribe to, and any limits, are Facebook's to define. The project points to Facebook's own realtime documentation for that, so Koala cannot tell you in advance whether a subscription will be accepted.

Editorial conclusion

Use Koala when a Ruby app needs thin accessors over the Facebook Graph API that return Hashes and arrays, with OAuth and realtime subscriptions in the same gem. Avoid its global configuration in threaded code, and check the supported Ruby list, which names MRI 2.1 to 2.4, against your runtime before adopting.

Frequently asked questions

How do I install the Koala gem for Ruby?

Add gem "koala" to your Gemfile for Bundler, or run gem install koala. A note says Koala 3.0 should bring no significant changes for most users.

Is Koala's global configuration threadsafe?

No. Koala.configure is not currently threadsafe, and pull requests are welcome if they support both threaded and non-threaded configuration.

Which Facebook APIs does Koala support?

It supports the Graph API with batch requests and photo uploads, the Marketing API, the Atlas API, realtime updates, test users and OAuth validation.

Official sources

  1. arsduo/koala on GitHub
  2. Issues
  3. License: MIT
  4. Project website
  5. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/arsduo-koala.svg)](https://hysenlabs.com/projects/arsduo-koala)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/arsduo-koala.svg)](https://hysenlabs.com/projects/arsduo-koala)

Was this useful?