Adding documents

Once you have created a project of your own, the next step you would like to do is to add documents to the project.

There are three ways to add documents to a project:

  1. To add documents from pre-registered databases, e.g. PubMed or PMC.
  2. To import documents from an existing project.
  3. To create a new document.

This page explains the first method.

You can add a document from a pre-registered database by providing a document specification (a pair of the source (sourcedb) and the id (sourceid) of the document), using one of the following ways.

Using Browser GUI

  1. Go to your project page.
    • top > projects > your_project
  2. If you are logged in, you will find the Add menu in the pane, Documents:
    add new document form
  3. Choose one of the pre-registered source DBs, e.g., PubMed or PMC.
  4. Enter source IDs in the source IDs text box: space (‘ ‘), comma (‘,’), vertical bar (‘|’), newline (‘\n’), tab characters (‘\t’) can be used to delimit multiple source IDs.
  5. Click the Add button.

Using REST API

You can use any REST client, e.g. cURL, to “post”” a document specification or a list of document specifications to your project.

Note that most recent major programming languages have modules for REST access, and you can do the same thing using any of your favorite programming languages.

The following example shows a cURL command to include the document PubMed:123456 in the project your_project:

Following is explanation of the option specification:

  • -u “your_email_address:your_password
    • Specifies your login information.
    • You can omit your_password in the command. If necessary it will prompt you to enter password.
  • -d sourcedb=PubMed
    • Specifies the sourcedb to be PubMed.
  • -d sourceid=1234546
    • Specifies the sourceid to be 123456.
  • https://pubannotation.org/projects/your-project/docs/add[.json]
    • The URL for adding new entries to the document list of your project.
    • By adding the suffix .json in the end, you can get the result message in JSON.

You can also send the document specification in JSON:

  • -H “content-type:application/json”
    • Tells the server to interprete the body of the request as JSON.
  • -d ‘{“sourcedb”:”PubMed”,”sourceid”:”123456”}’
    • Tells cURL to send (by the POST method) the document specification in JSON.

Using JSON, it is easy to send multiple document specifications:

  • -d ‘[{“sourcedb”:”PubMed”,”sourceid”:”123456”},{“sourcedb”:”PubMed”,”sourceid”:”123457”}]’
    • Tells cURL to send (by the POST method) the document specifications in JSON.
    • “[…]” means an array in JSON.

When you have a long list of document specifications, you can put it in a separate file, then specify the filename in the cURL command:

  • -d @filename.json
    • Tells cURL to send the content of the file filename.json.