Skip navigation

MedlinePlus Web Service

MedlinePlus offers a search-based Web service that provides access to MedlinePlus health topic data in XML format. Using the Web service, software developers can build applications that utilize MedlinePlus health topic information. The service accepts keyword searches as requests and returns relevant health topics in ranked order. The service also returns health topic summaries, search result snippets and other associated data.

To ensure that the latest information is readily available, the data in the Web service is updated daily, Tuesday - Saturday. Currently, the Web service is only available for English health topics.

The Web service is free of charge, does not require registration or licensing, and allows for unlimited data calls. If you use data from the Web service or build an interface using the Web service, please indicate that the information is from MedlinePlus.gov. If you have questions about the MedlinePlus Web service, or if you would like to share an application that you have built using the service, please contact us.

To receive notification when MedlinePlus releases enhancements to the service or updates the documentation, sign up for our Web service email updates:


Please note that the Web service only returns the subset of MedlinePlus health topic records that are relevant to the query in the request. If you need the full set of MedlinePlus health topics in XML format, see our XML files page. If you want to link patients or healthcare providers from electronic health record (EHR) systems to relevant MedlinePlus information, use MedlinePlus Connect. For a complete list of MedlinePlus resources available in XML format, see our XML data sources handout.

Description

Returns MedlinePlus health topic search results for an input query string.

Base URL

http://wsearch.nlm.nih.gov/ws/query

Parameters

Required Parameters for Initial Search Request

Parameter Name Description
db Database to search. Value is always healthTopics.
term Text query submitted to the Web service. All special characters must be URL encoded. Spaces may be replaced by '+' signs, which represent the AND operator. Represent the OR operator as +OR+. To send a query as a phrase, enclose the phrase in quotes using %22 to represent quotation marks.

Examples:

http://wsearch.nlm.nih.gov/ws/query?db=healthTopics&term=asthma

http://wsearch.nlm.nih.gov/ws/query?db=healthTopics&term=%22diabetes+medicines%22+OR+%22diabetes+drugs%22

Required Parameters for Subsequent Requests

Parameter Name Description
file Name of the file containing the document references for the current search. This parameter is required when retstart is being used. The value is obtained from the XML returned from the initial search. The file will expire after a certain period of inactivity, after which, a new request must be initiated. If the file is expired, the XML output will contain an error message.
server Name of the server with the file referenced by the file parameter. This is required when the file parameter is being used.
retstart Sequential index of the first document in the retrieved set to be shown in the XML output (default=0, corresponding to the first record of the entire set). This parameter can be used in conjunction with retmax to download an arbitrary subset of documents retrieved from a search.

Example:

http://wsearch.nlm.nih.gov/ws/query?file=viv_0Uu9LP&server=qvlbsrch04&retstart=20

Optional Parameter

Parameter Name Description
retmax Total number of documents from the retrieved set to be shown in the XML output (default=10). By default, the web service only includes the first 10 documents retrieved in the XML output. Increasing retmax allows more of the retrieved documents to be included in the XML output.

Examples:
http://wsearch.nlm.nih.gov/ws/query?db=healthTopics&term=diabetes&retmax=50
http://wsearch.nlm.nih.gov/ws/query?file=viv_0Uu9LP&server=qvlbsrch04&retstart=30&retmax=20

Output

Output Type

XML

XML Response Format

The following is the basic structure of the XML returned:

<nlmSearchResult>

</term>

</file>

</server>

</count>

</retstart>

</retmax>

</spellingCorrection>

<list>

<document>

<content />

</document>
</list>

</nlmSearchResult>

Descriptions of Tags

Tag Name Description
nlmSearchResult Basic XML node that contains the response (has no attributes)
term Text query submitted to the Web service
file Name of the file containing the document references for the current search
server Name of the server with the file referenced by the file parameter
retstart Sequential index of the first document in the retrieved set shown in the XML output
retmax Total number of documents from the retrieved set shown in the XML output
count The number of documents in the current result set (non-negative integer)
spellingCorrection Suggested alternative search with a different spelling of the word(s) in the query term(s). This element is not always present.
list The containing element for all of the retrieved documents
document An individual document (MedlinePlus health topic record)

Document Node Description

Attribute Type Description
url Text MedlinePlus health topic page URL
rank Non-negative integer Rank of the document in the results. The rank is based on the relevance score as determined by the search engine. Generally, the first document in the first results set will have a rank of zero, and the next document will have a rank of 1, 2, 3, etc. However, if the query string matches a health topic's title or altTitle, that topic will be boosted to the top, regardless of the rank. In these cases the first document in the first results set may have a rank greater than zero.
content Text Specifies some text associated with its parent document, the MedlinePlus health topic record. The value of content nodes will contain query term identification in the form of <span> tags. The query term will be identified in the <span> tag as qt0, qt1, qt2, etc.

Content Node Description

Attribute Type Description
name Text The name of the content node. Allowed values are: title, organizationName, altTitle, fullSummary, mesh, groupName, snippet. (See below for a description of content node values.)

Description of content node values:

Content Node Value Description
title Name of the MedlinePlus health topic page
organizationName Organization that produced the MedlinePlus topic page. Value will always be "National Library of Medicine"
altTitle See reference(s) and synonym(s) for the topic. See references and synonyms are undifferentiated in the XML.
fullSummary Text summary of the topic. HTML formatting will be present.
mesh Medical Subject Heading(s) assigned to the topic.
groupName Group(s) to which the topic belongs. A complete list of groups can be found on the MedlinePlus health topics main page.
snippet Brief result summary generated by the search engine, that provides a preview of the relevant content on the topic page.

Example:

- <document rank="0" url="http://www.nlm.nih.gov/medlineplus/diabetesmedicines.html">
  <content name="title"><span class="qt0">Diabetes</span> <span class="qt1">Medicines</span></content>
  <content name="organizationName">National Library of Medicine</content>
  <content name="altTitle">Insulin</content>
  <content name="altTitle">Hypoglycemic <span class="qt1">Medicines</span></content>
  <content name="FullSummary"><p><span class="qt0">Diabetes</span> means your blood glucose, or blood sugar, is too high. If you can't control your <span class="qt0">diabetes</span> with wise food choices and physical activity, you may need <span class="qt0">diabetes</span> <span class="qt1">medicines. The kind of medicine</span> you take depends on your type of <span class="qt0">diabetes</span>, your schedule, and your other health conditions. </p><p>With Type 1 <span class="qt0">diabetes</span>, your pancreas does not make insulin. Insulin is a hormone that helps glucose get into your cells to give them energy. Without insulin, too much glucose stays in your blood. If you have type 1 <span class="qt0">diabetes</span>, you will need to take insulin. </p><p>Type 2 <span class="qt0">diabetes</span>, the most common type, can start when the body doesn't use insulin as it should. If your body can't keep up with the need for insulin, you may need to take pills. Some people need both insulin and pills. Along with meal planning and physical activity, <span class="qt0">diabetes</span> pills help people with type 2 <span class="qt0">diabetes</span> or gestational <span class="qt0">diabetes</span> keep their blood glucose levels on target. Several kinds of pills are available. Each works in a different way. Many people take two or three kinds of pills. Some people take combination pills. Combination pills contain two kinds of <span class="qt0">diabetes</span> <span class="qt1">medicine</span> in one tablet. Some people take pills and insulin.</p><p>NIH: National Institute of <span class="qt0">Diabetes</span> and Digestive and Kidney Diseases</p></content>
  <content name="mesh">Hypoglycemic Agents</content>
  <content name="mesh">Insulin</content>
  <content name="groupName">Endocrine System</content>
  <content name="groupName">Drug Therapy</content>
  <content name="groupName"><span class="qt0">Diabetes Mellitus</span></content>
  <content name="snippet">... food choices and physical activity, you may need <span class="qt0">diabetes</span> <span class="qt1">medicines. The kind of medicine</span> you take depends on ... combination pills. Combination pills contain two kinds of <span class="qt0">diabetes</span> <span class="qt1">medicine</span> in one tablet. Some people take pills and ...</content>
  </document>