{"id":18707540,"url":"https://github.com/discourse/discourse_api","last_synced_at":"2025-05-15T05:08:12.795Z","repository":{"id":9450540,"uuid":"11329533","full_name":"discourse/discourse_api","owner":"discourse","description":"Ruby API for Discourse","archived":false,"fork":false,"pushed_at":"2024-06-19T18:04:06.000Z","size":606,"stargazers_count":287,"open_issues_count":4,"forks_count":166,"subscribers_count":39,"default_branch":"main","last_synced_at":"2025-05-15T05:07:59.059Z","etag":null,"topics":["rubygem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/discourse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-07-11T01:31:01.000Z","updated_at":"2025-04-23T16:06:39.000Z","dependencies_parsed_at":"2024-05-08T19:57:32.852Z","dependency_job_id":"f4665357-398d-4cb4-9cbf-9134452a3dfb","html_url":"https://github.com/discourse/discourse_api","commit_stats":{"total_commits":418,"total_committers":78,"mean_commits":5.358974358974359,"dds":0.6722488038277512,"last_synced_commit":"a19fdd8e456d422e0ccb07360d3edfd8f63a917d"},"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fdiscourse_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fdiscourse_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fdiscourse_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discourse%2Fdiscourse_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discourse","download_url":"https://codeload.github.com/discourse/discourse_api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276447,"owners_count":22043867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rubygem"],"created_at":"2024-11-07T12:18:49.094Z","updated_at":"2025-05-15T05:08:07.787Z","avatar_url":"https://github.com/discourse.png","language":"Ruby","readme":"# DiscourseApi\n\nThe Discourse API gem allows you to consume the Discourse API\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'discourse_api'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install discourse_api\n\n## Usage\n\nOver time this project intends to have a full Discourse API. At the moment there are only a\nfew endpoints available:\n\n```ruby\nclient = DiscourseApi::Client.new(\"http://try.discourse.org\")\nclient.api_key = \"YOUR_API_KEY\"\nclient.api_username = \"YOUR_USERNAME\"\n\nclient.ssl(...)                                 #=\u003e specify SSL connection settings if needed\n\n# Topic endpoints\nclient.latest_topics                            #=\u003e Gets a list of the latest topics\nclient.new_topics                               #=\u003e Gets a list of new topics\nclient.topics_by(\"sam\")                         #=\u003e Gets a list of topics created by user \"sam\"\nclient.topic(57)                                #=\u003e Gets the topic with id 57\n\n# Search endpoint\nclient.search(\"sandbox\")                        #=\u003e Gets a list of topics that match \"sandbox\"\n\n# Categories endpoint\nclient.categories                               #=\u003e Gets a list of categories\nclient.category_latest_topics(category_slug: \"lounge\")  #=\u003e Gets a list of latest topics in a category\n\n# SSO endpoint\nclient.sync_sso(                                #=\u003e Synchronizes the SSO record\n  sso_secret: \"discourse_sso_rocks\",\n  name: \"Test Name\",\n  username: \"test_name\",\n  email: \"name@example.com\",\n  external_id: \"2\",\n  custom_fields: {\n    field_1: 'potato'\n  }\n)\n\n# Private messages\nclient.private_messages(\"test_user\")            #=\u003e Gets a list of private messages received by \"test_user\"\nclient.sent_private_messages(\"test_user\")       #=\u003e Gets a list of private messages sent by \"test_user\"\nclient.create_private_message(                  #=\u003e Creates a private messages by api_username user\n  title: \"Confidential: Hello World!\",\n  raw: \"This is the raw markdown for my private message\",\n  target_usernames: \"user1,user2\"\n)\n\n```\n\nYou can handle some basic errors by rescuing from certain error classes and inspecting the response object passed to those errors:\n\n```ruby\nbegin\n  client.create_group({ name: 'NO' })\nrescue DiscourseApi::UnprocessableEntity =\u003e error\n  # `body` is something like `{ errors: [\"Name must be at least 3 characters\"] }`\n  # This outputs \"Name must be at least 3 characters\"\n  puts error.response.body['errors'].first\nend\n```\n\nCheck out [lib/discourse_api/error.rb](lib/discourse_api/error.rb) and [lib/discourse_api/client.rb](lib/discourse_api/client.rb)'s `handle_error` method for the types of errors raised by the API.\n\nIf your forum has a basic HTTP authentication enabled, set user and password:\n\n```ruby\nclient.basic_auth = {\n  user: \"test\",\n  password: \"secret\"\n}\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Testing\n\n1. Install discourse locally\n2. Inside of your discourse directory, run: `bundle exec rake db:api_test_seed`\n3. Start discourse: `bundle exec rails s`\n4. Install bundler in the discourse_api directory, run `gem install bundler`\n5. Inside of your discourse_api directory, run: `bundle exec rspec spec/`\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscourse%2Fdiscourse_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscourse%2Fdiscourse_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscourse%2Fdiscourse_api/lists"}