So you want to use Discourse API? Great! Let’s get started.
Now that you have set up Discourse development environment, you should already have Git and Ruby installed on your system. You can install Discourse API gem by running following command from console:
git clone https://github.com/discourse/discourse_api.git ~/discourse_api
discourse_api directory and type:
This will install any required gem dependencies.
Generate Master API Key for your Discourse instance by visiting
/admin/api, to interact with Discourse API.
Now that you have cloned Discourse API gem and generated master API key, let’s start using it!
discourse_api/examples/example.rb file, and modify following information:
client = DiscourseApi::Client.new("http://localhost:3000") client.api_key = "YOUR_API_KEY" client.api_username = "YOUR_USERNAME"
http://localhost:3000 with the url of your discourse instance, eg:
YOUR_API_KEY with the master API key of your discourse instance, eg:
YOUR_USERNAME with the Admin username of your discourse instance, eg:
Now in console, from
discourse_api directory run:
This command will print out latest topics from your Discourse instance.
That’s it. Start using Discourse API today.
Discourse API Documentation
Last Reviewed by @AlexDev on 2022-07-13T01:00:00Z