Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

discourse_api

> 编程语言
Open source

Ruby API for Discourse

304 stars0 likes2 views
WebsiteGitHub

About

Ruby API for Discourse

DiscourseApi

The Discourse API gem allows you to consume the Discourse API

Installation

Add this line to your application's Gemfile:

gem 'discourse_api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install discourse_api

Usage

Over time this project intends to have a full Discourse API. At the moment there are only a few endpoints available:

…

You can handle some basic errors by rescuing from certain error classes and inspecting the response object passed to those errors:

ruby
begin
  client.create_group({ name: 'NO' })
rescue DiscourseApi::UnprocessableEntity => error
  # `body` is something like `{ errors: ["Name must be at least 3 characters"] }`
  # This outputs "Name must be at least 3 characters"
  puts error.response.body['errors'].first
end

Check out lib/discourse_api/error.rb and lib/discourse_api/client.rb's handle_error method for the types of errors raised by the API.

If your forum has a basic HTTP authentication enabled, set user and password:

ruby
client.basic_auth = {
  user: "test",
  password: "secret"
}

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Testing

  1. Install discourse locally
  2. Inside of your discourse directory, run: bundle exec rake db:api_test_seed
  3. Start discourse: bundle exec rails s
  4. Install bundler in the discourse_api directory, run gem install bundler
  5. Inside of your discourse_api directory, run: bundle exec rspec spec/

Issues· 2 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubyrubygem

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言