Bookmark Topic Watch Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
If you want to show off your Ranch user profile, one of the Ranch forums, or a particular discussion topic, we have a REST API you can use to get some basic information about those programmatically. You can use them in web pages via JavaScript, or within other languages you use to build web pages, like PHP. The data returned is JSON.


  • https://coderanch.com/rest/n/u/70730 returns basic information about a user that can be used to link to their profile; the last part of the URL is the user ID. The returned data is {"id":70730, "posts":112, "likes":0, "cows":0, "views":171382, "firstName":"Peter", "lastName":"van de Riet"}. That's the user ID again, the number of posts made by that user, the number of "thumbs up" (a.k.a. "Likes") he's received, the number of cows he's received, the combined number of times all his posts have been viewed, and his first and last name.



  • https://coderanch.com/rest/n/f/1 returns basic information about one of the discussion forums; the last part of the URL is the forum ID. The returned data is {"id":1, "name":"Java in General", "topics":46707, "posts":220219, "views":44989124, "likes":5886, "cows":94}. That's the forum ID, the forum name, the number of discussion topics in the forum, the total number of posts made in all topics, the total number of views received by all topics, the total number of thumbs-ups given to posts in that forum, and the total number of cows given to posts in that forum.



  • https://coderanch.com/rest/n/t/637449 returns basic information about a particular discussion topic; the last part of the URL is the topic ID. The returned data is {"id":637449, "views":172, "replies":3, "forumId":10, "cows":2, "likes":0, "title: Journal - July 2014 published!", "firstPost":"2014-07-31 12:52:20.548-06"}. That's the topic ID, the number of views it has received, the number of replies that have been posted, the ID of the forum it's in, the number of cows posts in this topic have earned, the number of thumbs-ups posts in this topic have received, its title, and the date and time of the first post.


  • The URLs also support JSONP so there is no cross-origin problem when used via JavaScript. http://test.javaranch.com/ulf/javascript-badges.html shows how to access them via jQuery and construct URLs that point back to the Ranch. We'd like to see much fancier use including graphic; let us know what you have come up so we can showcase it!

    This API also works on the Permies web site. Just replace "coderanch.com" by "permies.com", and think about apples instead of cows, and you're good to go.


    Badges CategoryJForum
     
    Don't get me started about those stupid light bulbs.
      Bookmark Topic Watch Topic
    • New Topic