百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

discourse_api

> 编程语言
开源

演讲的Ruby API

304 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

演讲的Ruby API

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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubyrubygem

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

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