20 APIs every developer should know

Printer-friendly versionPrinter-friendly version

(notes from a session at DrupalCon 2010)

  • What's so important about APIs?
    • APIs let your code interface with other authors' code, make maintenance easier and minimizing duplication of work
  • Which APIs should I know? What can I do with them? When should I use them?
    • Hooks provide common naming convention, allow modules to interact with other modules and core, create hooks for other modules to access
    • Theme API allows logic and data to be separated from presentation. use hook_theme_registry_alter to alter output of other modules and add preprocess functions
    • Forms API allows collection of input from users, generating HTML forms from PHP arrays, standard validation and submission functions
    • Taxonomy API allows modules to manipulate taxonomy terms. good example: Geo Taxonomy attaches geo info to taxonomy terms
    • Node API to modify info loaded and saved to nodes. use hook_node_operations to define bulk operations
    • CCK API allows modules to define custom field types
    • Views API lets you expose custom tables to Views, provide custom displays, filters, etc.
    • CTools is a collection of APIs, some of which have been incorporated into D7
    • Token - place strings of text within a larger string.
    • User Relationships API - create social links of various types between users, friend requests, different relationship types.
    • Activity API - keep track of actions people take, provide Facebook-style feeds, define who can see what, integrate with OG
    • OG (Organic Groups) API allows modules to respond to users joining, leaving, requesting membership in groups.
    • Services - allows external systems to communicate with Drupal via XMLRPC, JSON, etc., also define Web services to interact with desktop, mobile, and Flash applications
    • ApacheSolr - provide custom search, sort, and filterability for data
    • Feeds - import or aggregate data as nodes, users, taxonomy, or custom database records. API lets you define new ways to fetch, parse, and process.
    • WYSIWYG API - plug in or extend various editors, for example add a button
    • Domain Access - serve multiple sites from a single Drupal installation, with different blocks, themes, etc.
    • Triggers & Actions - provide flexible hook functionality through the admin interface. When building a module, create triggers so admins can assign actions.
    • Messaging / Notifications - provide new types of subscriptions using hook_notifications
    • Voting API: designed for votes, but can be used to store and retrieve any type of content and react to those events, or to calculate a "score" based on an algorithm.