Web API

Introduction
The ISFDB currently provides 2 web APIs: getpub.cgi which is used to obtain publication metadata, and submission.cgi which is used to submit data to the ISFDB. There are currently no methods for obtaining author, title, series, or awards information from the ISFDB.

License Keys
Since registration is required to edit the ISFDB, the web API enforces that policy. Submitting data to the ISFDB requires a registered user ID, as well as a license key which is your password for accessing the web API. If you are logged into the ISFDB, a license key can be generated by visiting http://www.isfdb.org/cgi-bin/edit/keygen.cgi and clicking on [Generate New Key]. For data submissions this key must appear within a LicenseKey XML tag following the Submitter tag.

getpub.cgi
The getpub.cgi application takes an ISBN for an argument, and returns an XML structure containing the metadata for that particular publication. If more than one publication is associated with that particular ISBN, multiple records will be generated. The Records tag indicates the number of records found, followed by some number of Publication records. A license key is not required to use this API. The URL for getpub.cgi should appear as follows:

http://www.isfdb.org/cgi-bin/rest/getpub.cgi?0439176832

Example XML returned via call to getpub.cgi:

Example python script utilizing getpub.cgi
Although getpub.cgi can be invoked via a browser, a more practical application is to invoke the URL via a programming interface, parsing the result with an XML parser, and then doing something of use with the resulting data. The following example shows the python code needed to obtain the XML data; it does not show an example of parsing the XML:

Error Conditions
In the event of an error condition, getpub.cgi will return an XML structure with the number of records found set to zero:

submission.cgi
The submission.cgi application allows a remote user to post data to the ISFDB. Any of the data payloads defined in the Data Submission Formats article are accepted. The format of the XML data is identical to that used for local submissions, with the exception that the user's license key must be inserted after the Submitter tag. The user's registered login name should be contained within the Submitter tag, and the user's current license key should be contained with the LicenseKey tag. The URL for submission.cgi should appear as follows:

http://www.isfdb.org/cgi-bin/rest/submission.cgi

Submissions are placed in the moderator queue as with an ISFDB edit, and are not integrated into the database until a moderator approves it. As such it is important that you not flood the moderator queue with hundreds of submissions. In general you should only post no more than 20 submissions per session, until they are cleared out by a moderator.

An example submission XML payload follows, with the LicenseKey x'd out:

Example python script utilizing submission.cgi
The submission.cgi application uses the http POST method, so it can not be invoked via a web browser. Once a proper XML payload has been constructed as described above, a connection needs to be made to the ISFDB web server, and the appropriate http header needs to be sent, including content type and length information. This example below shows how this can be implemented in python:

Error Conditions
In the event of an error condition, submission.cgi will return an XML structure with a Status of FAIL (success will return OK). The cause of the error can be found within the Error tag: