Drupal has no API

I've been using Drupal for a couple of years now, and know my way around it pretty well.

One of my biggest frustrations though is that it doesn't really have an API.

Much of the functionality is only really available through the application, you can do things pretty easily by pointing and clicking, but try and automate part of this and you have to step through code, find form handlers, copy-paste parts of the functions and work out what parameters are required.

The example I found most recently was creating a translated version of a page.

My client is using a translation agency, we send them XML, they translate it and return the translated text in XML. 

So I start with an English page, send off an XML version, and when I get the XML translation back I need to add a new node related to the original.

But Drupal has no function "translation_add()" instead the functionality is embedded in "translation_nodapi()".

If Drupal had an API there would be a well thought out set of functions to add, delete, and update translations of a node.

The name of Drupal's documentation site http://api.drupal.org/ is misleading, this is just general documentation of Drupal functions, it isn't an API.

 

Tags

Comments

Interesting point

I think you're being a little harsh, but I see where you're coming from. Perhaps the separation of core from features will help. You should see Jeff Eaton's comments about it on my blog:
http://www.drupaler.co.uk/blog/framework-product-or-both/438#comment-250

Ps - hope you're well! I haven't been in London for ages, but will ring you for a beer when I am. And if you find yourself in the south of France, drop by! Good walking in the Cevennes, not far from me. ;-)

Comments

if there is a Drupal API - where is it documented?

api.drupal.org is just a complete(ish) documentation of all Drupal functions.

It even includes "private" functions  http://api.drupal.org/api/function/_translation_tab_access/6

I'm not saying that Drupal "ought" to have an API - but let's be honest about where it is now....

Drupal development means using the GUI - with all the problems that brings for team working, deployment, rollback, testing etc.

and whenever you want to step outside of existing functionality (e.g. using a translation service) you have to go direct to the database.

See also  http://walkah.net/blog/walkah/why-i-hate-drupal

Comments

No API to add a file to a node

Another example...

There are no functions to add a files to a node.

This function in the devel module shows how to achieve the result.

devel_generate_add_upload

But in the Drupal way - you have to insert directly into the database.

Post new comment

Got something to add - just enter a comment
all other fields are optional.

Your email address will not be published.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.