Difference between revisions of "API"

From Mibbit Wiki
Jump to: navigation, search
(tools. is gone)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{articles}}
 
{{articles}}
 
{{widget}}
 
{{widget}}
<h3>this feature seems to be broken, will be fixed as soon as possible</h3>
+
{{RightTOC}}
== How many people are using my widget? ==
 
  
 +
==What is an API==
  
If you run a site, and are using the widget, you might want to show elsewhere on your site how many people are using it. Well now you can do that easily.
+
An application programming interface (API) is an interface implemented by a software program that enables it to interact with other software. It facilitates interaction between different software programs similar to the way the user interface facilitates interaction between humans and computers.
  
{{notice|The results are '''updated every 20 minutes''', so should give you a reasonable '''idea''' of how many mibbitians are chatting but '''not''' the '''exact''' number.}}
+
===Accessing the API===
  
First thing you need, is the settingsID. This is in the widget URL you are using (last line in [[Manager]] "Prefs").
+
The Mibbit API allows you to gather information on your widget.  You have to have a manager account, and a settings ID for the API to work.  Where you see <settingsID> in this document, replace it with your own settings ID. This is in the widget URL you are using or in the example links on the [[Manager]]'s "Connection" page).
  
 
For example:
 
For example:
 
widget.mibbit.com/?settings='''42c110f3cbbaea489c0b0e40a40e6e18'''&channel=%23chat
 
widget.mibbit.com/?settings='''42c110f3cbbaea489c0b0e40a40e6e18'''&channel=%23chat
  
The section in bold is the settingsID
+
==Number of Users on a Widget==
  
Just replace <settingsID> with your particular ID.
+
If you run a site, and are using the widget, you might want to show elsewhere on your site how many people are using it. We provide multiple formats for this information.
  
===Using the API===
+
{{notice|The results are '''updated every 20 minutes''', so should give you a reasonable '''idea''' of how many mibbitians are chatting but '''not''' the '''exact''' number.}}
  
The link below outputs just the number of mibbitians using your widget. You could use this from PHP,Python,etc and get it to output in the page.
+
In the example output section, we assume there are 15 users using the widget.
  
'''<nowiki>http://api.mibbit.com/<settingsID></nowiki>'''
+
===Direct Number===
 +
 
 +
A file containing only the number.
 +
 
 +
Format:  '''<nowiki>http://api.mibbit.com/<settingsID></nowiki>'''
 +
 
 +
This is most useful for server side languages, such as PHP.
  
 
Output:
 
Output:
 
  15
 
  15
Examples:<br>
+
Example:<br>
 
[http://api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18 api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18]<br>
 
[http://api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18 api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18]<br>
[http://tools.mibbit.com/pub/api-demo-xhr.php ajax api demo]
 
  
  
----
+
===Javascript Function===
  
This one outputs a snippet of javascript which will write to the document the current number. So you can include this in your HTML, without any backend changes needed.
+
This format outputs a snippet of javascript which will write to the document the current number. So you can include this in your HTML, without any server-side changes needed.
  
'''<nowiki>http://api.mibbit.com/<settingsID>.js</nowiki>'''
+
Format:  '''<nowiki>http://api.mibbit.com/<settingsID>.js</nowiki>'''
  
Usage (on your html-page):
+
Usage (in an HTML page):
 
  There are <nowiki><script src="http://api.mibbit.com/42c...e18.js"></script></nowiki> people chatting  
 
  There are <nowiki><script src="http://api.mibbit.com/42c...e18.js"></script></nowiki> people chatting  
  
Line 46: Line 51:
 
[http://tools.mibbit.com/pub/api-demo.htm api-demo] (full blown example)
 
[http://tools.mibbit.com/pub/api-demo.htm api-demo] (full blown example)
  
----
+
===JSON Object===
  
 
You might prefer to use this link, it’s likely that later on this one will contain more useful info as well.
 
You might prefer to use this link, it’s likely that later on this one will contain more useful info as well.
Line 56: Line 61:
 
Example: [http://api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18.json api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18.json]
 
Example: [http://api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18.json api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18.json]
  
----
+
===JSONP====
 +
 
 +
Also available, as requested:
 +
 
 +
'''<nowiki>http://api.mibbit.com/<settingsID>.jsonp</nowiki>'''
 +
 
 +
(details will follow)
 +
 
 +
Example: http://api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18.jsonp?callback=some_function
  
There are also a couple of graphs updated at
+
===Graphical Image===
 +
 
 +
The following formats give you access to an image showing the amount of users in the pass week of month.
  
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_week_mini.png</nowiki>''' (thumbnail)
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_week_mini.png</nowiki>''' (thumbnail)
  
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_month_mini.png</nowiki>''' (thumbnail)
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_month_mini.png</nowiki>''' (thumbnail)
 +
 +
The following graphs may have a wrong scaling (will be fixed as soon as possible)
  
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_month.png</nowiki>'''
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_month.png</nowiki>'''
Line 73: Line 90:
 
user stats.</nowiki>
 
user stats.</nowiki>
  
== Request a Feature ==
+
==View Settings==
 +
 
 +
When the Mibbit Widget loads, it makes an API call that returns the settings changed from the default values.  The settings change is a Javascript file that sets a few global variables.
 +
 
 +
Format:  '''<nowiki>http://api.mibbit.com/settings/<settingsID>.js</nowiki>'''
 +
 
 +
Usage:  Used internally, does not seem to be a current usage externally.
 +
 
 +
Output:  var LOADED_SETTINGS={/* modified settings */}; var PREMIUM_DOMAIN=""; var CONNECT_SERVER=""; var CONNECT_CHANNEL="";
 +
 
 +
==Request a Feature==
  
 
New API features are in the works, and this page will be updated when they are available.
 
New API features are in the works, and this page will be updated when they are available.
  
For any feature requests for the new API, ask at [http://mibbit.com/chat/?channel=%23help&server=irc.mibbit.net #help on irc.mibbit.net] or add them to the [[WishList]]
+
For any feature requests for the new API, ask axod at [http://chat.mibbit.com/#help #help on irc.mibbit.net] or add them to the [[WishList]]
 
 
  
 
[[Category:Features]]
 
[[Category:Features]]

Latest revision as of 20:13, 11 February 2012

Wiki Home | FAQ | Features | IRC Commands | IRC Modes | Widget Information | Widget: WebIRC Server Setup | URI Parameters | Wish List | Registration Information | Mibbit Staff

Home | Quick Start Guide | Live Mibbit Help


API | URI Parameters | Auto Connect


What is an API

An application programming interface (API) is an interface implemented by a software program that enables it to interact with other software. It facilitates interaction between different software programs similar to the way the user interface facilitates interaction between humans and computers.

Accessing the API

The Mibbit API allows you to gather information on your widget. You have to have a manager account, and a settings ID for the API to work. Where you see <settingsID> in this document, replace it with your own settings ID. This is in the widget URL you are using or in the example links on the Manager's "Connection" page).

For example: widget.mibbit.com/?settings=42c110f3cbbaea489c0b0e40a40e6e18&channel=%23chat

Number of Users on a Widget

If you run a site, and are using the widget, you might want to show elsewhere on your site how many people are using it. We provide multiple formats for this information.

The results are updated every 20 minutes, so should give you a reasonable idea of how many mibbitians are chatting but not the exact number.

In the example output section, we assume there are 15 users using the widget.

Direct Number

A file containing only the number.

Format: http://api.mibbit.com/<settingsID>

This is most useful for server side languages, such as PHP.

Output:

15

Example:
api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18


Javascript Function

This format outputs a snippet of javascript which will write to the document the current number. So you can include this in your HTML, without any server-side changes needed.

Format: http://api.mibbit.com/<settingsID>.js

Usage (in an HTML page):

There are <script src="http://api.mibbit.com/42c...e18.js"></script> people chatting 

Output:

document.write("15")

Examples:
api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18.js (Javascript example)
api-demo (full blown example)

JSON Object

You might prefer to use this link, it’s likely that later on this one will contain more useful info as well.

http://api.mibbit.com/<settingsID>.json

Delivers data as json object to be processed by your javascript (e.g. ajax call):

{mibbitians:15}

Example: api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18.json

JSONP=

Also available, as requested:

http://api.mibbit.com/<settingsID>.jsonp

(details will follow)

Example: http://api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18.jsonp?callback=some_function

Graphical Image

The following formats give you access to an image showing the amount of users in the pass week of month.

http://api.mibbit.com/graphs/<settingsID>_week_mini.png (thumbnail)

http://api.mibbit.com/graphs/<settingsID>_month_mini.png (thumbnail)

The following graphs may have a wrong scaling (will be fixed as soon as possible)

http://api.mibbit.com/graphs/<settingsID>_month.png

http://api.mibbit.com/graphs/<settingsID>_week.png

Usage:

Last 4 weeks 
<img src="http://api.mibbit.com/graphs/42c...e18_month_mini.png">
user stats.

View Settings

When the Mibbit Widget loads, it makes an API call that returns the settings changed from the default values. The settings change is a Javascript file that sets a few global variables.

Format: http://api.mibbit.com/settings/<settingsID>.js

Usage: Used internally, does not seem to be a current usage externally.

Output: var LOADED_SETTINGS={/* modified settings */}; var PREMIUM_DOMAIN=""; var CONNECT_SERVER=""; var CONNECT_CHANNEL="";

Request a Feature

New API features are in the works, and this page will be updated when they are available.

For any feature requests for the new API, ask axod at #help on irc.mibbit.net or add them to the WishList