Difference between revisions of "API"

From Mibbit Wiki
Jump to: navigation, search
m (Starting with a cleanup of this page.)
(Major Updates)
Line 1: Line 1:
 
{{articles}}
 
{{articles}}
 
{{widget}}
 
{{widget}}
 +
{{RightTOC}}
  
== What is an API ==
+
==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.
 
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.
  
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.  If you cannot find yours, it is located on the widget [[manager]].
+
===Accessing the API===
  
== How many people are using my widget? ==
+
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 the last line in [[Manager]]'s "Advanced").
  
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.
+
For example:
 +
widget.mibbit.com/?settings='''42c110f3cbbaea489c0b0e40a40e6e18'''&channel=%23chat
  
{{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.}}
+
==Number of Users on a Widget==
  
First thing you need, is the settingsID. This is in the widget URL you are using (last line in [[Manager]] "Prefs").
+
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.
  
For example:
+
{{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.}}
widget.mibbit.com/?settings='''42c110f3cbbaea489c0b0e40a40e6e18'''&channel=%23chat
+
  
The section in bold is the settingsID
+
In the example output section, we assume there are 15 users using the widget.
  
Just replace <settingsID> with your particular ID.
+
===Direct Number===
  
===Using the API===
+
A file containing only the 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.
+
Format:  '''<nowiki>http://api.mibbit.com/<settingsID></nowiki>'''
  
'''<nowiki>http://api.mibbit.com/<settingsID></nowiki>'''
+
This is most useful for server side languages, such as PHP.
  
 
Output:
 
Output:
Line 35: Line 36:
 
[http://tools.mibbit.com/pub/api-demo-xhr.php ajax api demo]
 
[http://tools.mibbit.com/pub/api-demo-xhr.php ajax api demo]
  
 +
===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.
  
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.
+
Format:  '''<nowiki>http://api.mibbit.com/<settingsID>.js</nowiki>'''
  
'''<nowiki>http://api.mibbit.com/<settingsID>.js</nowiki>'''
+
Usage (in an HTML page):
 
+
Usage (on your 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 51: 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 62: 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:
 
+
also availabe, as requested:
+
  
 
'''<nowiki>http://api.mibbit.com/<settingsID>.jsonp</nowiki>'''
 
'''<nowiki>http://api.mibbit.com/<settingsID>.jsonp</nowiki>'''
Line 73: Line 71:
 
Example: http://api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18.jsonp?callback=some_function
 
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.
 
+
There are also a couple of graphs updated at
+
  
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_week_mini.png</nowiki>''' (thumbnail)
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_week_mini.png</nowiki>''' (thumbnail)
Line 82: Line 79:
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_month_mini.png</nowiki>''' (thumbnail)
 
'''<nowiki>http://api.mibbit.com/graphs/<settingsID>_month_mini.png</nowiki>''' (thumbnail)
  
thefollowing graphs may have a wrong scaling (will be fixed as soon as possible)
+
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 93: 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 axod at [http://chat.mibbit.com/#help #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]]

Revision as of 08:41, 20 November 2010

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 | Blog & News | 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 the last line in Manager's "Advanced").

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

Examples:
api.mibbit.com/42c110f3cbbaea489c0b0e40a40e6e18
ajax api demo

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