So you want to use Discourse API? Great! Let’s get started.
Set up Discourse development environment
Set up Discourse development environment using our Windows, OS X or Ubuntu guide.
Clone Discourse API Gem
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
Generate Master API Key
Generate Master API Key for your Discourse instance by visiting
/admin/api, to interact with Discourse API.
Provide API Credentials
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:
Access Discourse API
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.