Guide

JavaScript API

A JavaScript API is available for merchants to be able to:

  • Retrieve users who are currently online – coming soon
  • Retrieve the latest topics
  • Retrieve the leaderboard in points (limited to the top 25) – coming soon

The endpoints described below are not authenticated, and therefore anyone can access them. However, Champ will filter out results that require authentication. For example, if you try to retrieve the latest topics, Champ will not show ones that the user is not authenticated to see.

Fetching latest topics

You can fetch the latest topics using our JavaScript API at the following endpoint. You will need to substitute the values for the domain (yourdomain.com) and the path (/community/champ) if you’ve changed it.

To fetch the latest topics, make a GET call to the following endpoint: https://yourdomain.com/community/champ/latest/topics.json

This endpoint will accept the following URL encoded parameters:

  • number_of_topics (Default: 5)
  • metadata

Fetching posts for a topic

You can fetch all posts (in ascending order of creation) for a particular topic by sending a GET request to the following endpoint: https://yourdomain.com/community/champ/latest/posts.json

This endpoint requires you to send one of the following two URL encoded parameters:

  • topic_id
  • metadata

Let’s say you’ve set a metadata value of the following: metadata[collection_id] = 123. You can then query this endpoint like so: GET https://yourdomain.com/community/champ/latest/posts.json?metadata[collection_id]=123

You can chain multiple metadata parameters together.

This endpoint will return an empty JSON array if no posts are found for the topic. If the topic does not exist, it will return the following:

{"topic":"not found"}