Difference between revisions of "API"

From Freephile Wiki
Jump to navigation Jump to search
(adds local resources)
(Adds API Sandbox links)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
API documentation for software like mediawiki, drupal and web services.  Both API documentation and API tools. OS and Internet API references.
+
Commentary and examples of using the APIs (Application Programming Interface) for software like [http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API CiviCRM], [[MediaWiki]], Drupal and web services.  Both API documentation and API tools. OS and Internet API references.
  
[[wp:ApplicationProgrammingInterface|Application Programming Interface]] ([[wp:API]]) is the information about the exposed or 'public' variables, methods and objects or classes that a system makes available to the developer who wishes to enhance the system or interface with the system programmaticlyDocumenting the API is a critical software development function.  Publishing those documents makes the 'API Docs' available for easy reference.  Sometimes called Developer Docs, they are often used not just as a reference material, but also as a faster way to get familiar with a codebase than by reading the full source code itself.
+
[[wp:ApplicationProgrammingInterface|Application Programming Interface]] ([[wp:API|API]]) is the information about the exposed or 'public' variables, methods and objects or classes that a system makes available to the developer who wishes to interface with the system programmaticallyIf you make an API, documenting the API is a critical software development function.  In documentation terms, the API must almost be treated like a separate piece of software within or "attached" to the main program.
  
== Best Practices ==
+
== Programming APIs ==
Having good API/Developer documentation is a "Best Practice" that has several important positive effects. For adoption (meaning success) of your software, good API docs are essentialActual experience in using the phpDocumentor tool, PyDoc, or other documentation tools is a quality that separates developers from non-developers or senior developers from jr. developers. Writing (good) (formatted) comments into your source code so that API docs can be automatically generated on a nightly basis is not optional if you are really interested in your software being successful.
+
SWIG [[wp:Swig]] ([http://www.swig.org/exec.html Executive Summary]) helps application developers create an API.  Several open source projects leverage SWIG, such as Subversion, wxPython and wxWindows.  In turn, other developers can enhance these generic APIs to customize them for a particular programming language.  For example Python developers can use [http://pysvn.tigris.org/docs/pysvn_prog_guide.html pySVN] while work is underway to expand the PHP interface.  See more in the Subversion manual http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.developer.usingapi
  
 +
== Resources ==
 +
* http://gotapi.com publishes several API references for everything from HTML and CSS to DocBook and Drupal.  This organized list of API references also features fast, as-you-type search.
 +
* Some other documentation resources:
 +
** http://api.kde.org/ APIs of the K Desktop Environment
 +
** http://doc.trolltech.com/ APIs of the Qt GUI Toolkit
  
== Tools / Generators ==
+
== MediaWiki API ==
phpDocumentor is the best documentation tool for PHP sources with inspiration from JavaDoc.
+
MediaWiki has a strong '''action''' API (also called the web service API) which has it's endpoint at api.php. See the docs at https://www.mediawiki.org/wiki/API:Main_page 
  
The PyDoc tool is used to generate documentation on the language itself, and is also leveraged as a framework for developers of help systems and obviously used to document any classes, and methods of source code.
+
Since MW 1.27, there is also a SpecialPage [[mw:Special:ApiSandbox|Special:ApiSandbox]] [https://demo.qualitybox.us/wiki/Special:ApiSandbox Demo site] for interacting with the API - just like the API explorer for CiviCRM. (previously it was an extension)
  
See http://phpdoc.org/ and http://en.wikipedia.org/wiki/Javadoc
+
An example of the MediaWiki API in use is at the "[https://freephile.org/wikireport/index.php Wiki Report]" project.  Another very interesting example is the [https://wikiapiary.com/wiki/Freephile_Wiki Wiki Apiary] (clever name!)
  
== Documenting PHP Code ==
+
Similarly, there is a [[wp:Module:Sandbox|Module:Sandbox]] for testing Lua scripts
The main resource is the [http://www.phpdoc.org Project website], including tutorials and full Documentation.  The system can be installed via the PEAR installer, but should not be setup in an Internet-facing environment.  See the [[PhpDocumentor]] article for details on our installation and usage.
 
  
== Documenting other languages ==
+
===Example Questions ===
Aside from the Python-specific PyDoc, there are [http://www.xs4all.nl/~rfsber/Robo/robodoc.html ROBODoc] (Windows and Fink) and [http://www.stack.nl/~dimitri/doxygen Doxygen] tools which should prove to meet all needs. For doxygen, you can
+
Here are some example requests to the API
<source lang="bash">
+
# https://freephile.org/w/api.php?action=query&meta=siteinfo&siprop=extensions With no 'format' argument, you will get a "pretty" HTML output that you can read in your browser.
sudo apt-get install doxygen-gui doxygen doxygen-doc
+
# https://freephile.org/w/api.php?action=query&meta=siteinfo&siprop=extensions&format=json With *json* explicitly requested as the format, you can get values suitable for actual programming.
</source>
 
  
== Programming APIs ==
+
== Developer Tools ==
SWIG [[wp:Swig]] ([http://www.swig.org/exec.html Executive Summary]) helps application developers reveal an API.  Several open source projects leverage SWIG, such as Subversion, wxPython and wxWindows. In turn, other developers can enhance these generic APIs to customize them for a particular programming language.  For example Python developers can use [http://pysvn.tigris.org/docs/pysvn_prog_guide.html pySVN] while work is underway to expand the PHP interface.  See more in the Subversion manual http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.developer.usingapi
+
Among other tools, you're going to need to look at HTTP requests and responses to develop web services using APIs.  So, check out tools like [[Wireshark]] (https://www.wireshark.org/),  the [https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor Network Monitor]<ref>The "Live HTTP Headers" add-on still exists, but that is no longer neccessary given the development of the core features of the in-browser developer tools</ref> in [https://developer.mozilla.org/en-US/docs/Tools Developer Tools] for [[Firefox]], or [https://developer.chrome.com/devtools Chrome Developer Tools]
  
== Resources ==
+
== Integrators ==
* http://gotapi.com publishes several API references for everything from HTML and CSS to DocBook and Drupal.  This organized list of API references also features fast, as-you-type search.
+
Companies like [https://platform.ifttt.com/docs IFTTT] (If This Then That) and [https://www.crunchbase.com/organization/zapier#/entity Zapier] offer API integrations so that you can tie together applications via their APIs without any coding.
* Some other documentation resources:
 
** [http://svn.wikimedia.org/doc/ MediaWiki Doxygen docs]
 
** http://api.kde.org/ APIs of the K Desktop Environment
 
** http://doc.trolltech.com/ APIs of the Qt GUI Toolkit
 
  
== Local Resources ==
+
{{References}}
These tips may not be strictly "API" documents, but they do reveal man pages, howtos, and other help; plus programmatic interfaces.
 
* Create your own internal-use API Documentation by creating a symbolic link from /usr/share/docs to /var/www/docs
 
* info:/dir (type this into the location bar of Konqueror) browse the Info system.  You can of course type "info" in your shell, but I find that browsing "info" through Konqueror is a lot nicer.
 
* man:/command (type this into the location bar of Konqueror) browse the Man system.  You can of course type "man command" in your shell, but I find that browsing "manuals" through Konqueror is a lot nicer.
 
  
 
[[Category:Applications]]
 
[[Category:Applications]]

Latest revision as of 12:36, 19 December 2017

Commentary and examples of using the APIs (Application Programming Interface) for software like CiviCRM, MediaWiki, Drupal and web services. Both API documentation and API tools. OS and Internet API references.

Application Programming Interface (API) is the information about the exposed or 'public' variables, methods and objects or classes that a system makes available to the developer who wishes to interface with the system programmatically. If you make an API, documenting the API is a critical software development function. In documentation terms, the API must almost be treated like a separate piece of software within or "attached" to the main program.

Programming APIs[edit | edit source]

SWIG wp:Swig (Executive Summary) helps application developers create an API. Several open source projects leverage SWIG, such as Subversion, wxPython and wxWindows. In turn, other developers can enhance these generic APIs to customize them for a particular programming language. For example Python developers can use pySVN while work is underway to expand the PHP interface. See more in the Subversion manual http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.developer.usingapi

Resources[edit | edit source]

  • http://gotapi.com publishes several API references for everything from HTML and CSS to DocBook and Drupal. This organized list of API references also features fast, as-you-type search.
  • Some other documentation resources:

MediaWiki API[edit | edit source]

MediaWiki has a strong action API (also called the web service API) which has it's endpoint at api.php. See the docs at https://www.mediawiki.org/wiki/API:Main_page

Since MW 1.27, there is also a SpecialPage Special:ApiSandbox Demo site for interacting with the API - just like the API explorer for CiviCRM. (previously it was an extension)

An example of the MediaWiki API in use is at the "Wiki Report" project. Another very interesting example is the Wiki Apiary (clever name!)

Similarly, there is a Module:Sandbox for testing Lua scripts

Example Questions[edit | edit source]

Here are some example requests to the API

  1. https://freephile.org/w/api.php?action=query&meta=siteinfo&siprop=extensions With no 'format' argument, you will get a "pretty" HTML output that you can read in your browser.
  2. https://freephile.org/w/api.php?action=query&meta=siteinfo&siprop=extensions&format=json With *json* explicitly requested as the format, you can get values suitable for actual programming.

Developer Tools[edit | edit source]

Among other tools, you're going to need to look at HTTP requests and responses to develop web services using APIs. So, check out tools like Wireshark (https://www.wireshark.org/), the Network Monitor[1] in Developer Tools for Firefox, or Chrome Developer Tools

Integrators[edit | edit source]

Companies like IFTTT (If This Then That) and Zapier offer API integrations so that you can tie together applications via their APIs without any coding.

References[edit source]

  1. The "Live HTTP Headers" add-on still exists, but that is no longer neccessary given the development of the core features of the in-browser developer tools