Click here to Skip to main content
Click here to Skip to main content

Pillbox Information

, 31 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Pillbox is a resource of the U.S. National Library of Medicine, part of the National Institutes of Health, U.S. Department of Health and Human Services.


In this tip we will see how to get pill information using the Pill Box API. We can make use of the Pill Box REST API and get more information about a pill, its ingredients, and information that can be used to link to the drug label or other pharmacy information resources. 

More information about the Pill Box API can be found at


Healthcare domain knowledge is a plus.

Using the code 

We will be using the Pill Box service - Below are the query string parameters we need to pass in while making a web request.

  1. Security Key - You can give a try with default key e.g., 12345, or else you can raise a request for a free key by sending an email to
  2. Shape - i.e., the shape of the pill.
  3. Color - i.e., the color of the pill.
  4. Ingredient - i.e., the ingredient you wish to search for.

The color is associated with a code and it should be either one of the below.

  • BLACK C48323
  • BLUE C48333
  • BROWN C48332
  • GRAY C48324
  • GREEN C48329
  • ORANGE C48331
  • PINK C48328
  • PURPLE C48327
  • RED C48326
  • TURQUOISE C48334
  • WHITE C48325
  • YELLOW C48330

The Shape is associated with a code, we need to use the below mentioned code while making a request:

  • BULLET C48335
  • CAPSULE C48336
  • CLOVER C48337
  • DIAMOND C48338
  • FREEFORM C48340
  • GEAR C48341
  • HEPTAGON (7 sided) C48342
  • HEXAGON (6 sided) C48343
  • OCTAGON (8 sided) C48344
  • OVAL C48345
  • PENTAGON (5 sided) C48346
  • RECTANGLE C48347
  • ROUND C48348
  • SEMI-CIRCLE C48349
  • SQUARE C48350
  • TEAR C48351
  • TRAPEZOID C48352
  • TRIANGLE C48353 

Below is the code snippet where we are making a web request and processing the response.

static void Main(string[] args)
    string url = "" + 
    XDocument xmlDocument = XDocument.Load(url);

    var pillInfos = from item in xmlDocument.Descendants("pill")
                        select new PillInfoEntity
                            Author = item.Element("AUTHOR").Value,
                            Color = item.Element("SPLCOLOR").Value,
                            HasImage = item.Element("HAS_IMAGE").Value,
                            Imprint = item.Element("SPLIMPRINT").Value,
                            Ingredients = item.Element("INGREDIENTS").Value,
                            NDC9 = item.Element("NDC9").Value,
                            ProductCode = item.Element("PRODUCT_CODE").Value,
                            RxCUI = item.Element("RXCUI").Value,
                            RxString = item.Element("RXSTRING").Value,
                            RxTTY = item.Element("RXTTY").Value,
                            Score = item.Element("SPLSCORE").Value,
                            Shape = item.Element("SPLSHAPE").Value,
                            Size = item.Element("SPLSIZE").Value,
                            SPLID = item.Element("SPL_ID").Value,

    foreach (var pillInfo in pillInfos)


Here's the snapshot of the Pill Information result.

Points of Interest

It was fun coding to fetch pill information. I never thought it would be that easy to consume and parse the response.


  • Version 1.0 - 10/30/2013.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
United States United States
Around 10 years of professional software development experience in analysis, design, development, testing and implementation of enterprise web applications for healthcare domain with good exposure to object-oriented design, software architectures, design patterns, test-driven development and agile practices.
In Brief
Analyse and create High Level , Detailed Design documents.
Use UML Modelling and create Use Cases , Class Diagram , Component Model , Deployment Diagram, Sequence Diagram in HLD.
Area of Working : Dedicated to Microsoft .NET Technologies
Experience with : C# , J2EE , J2ME, Windows Phone 8, Windows Store App
Proficient in: C# , XML , XHTML, XML, HTML5, Javascript, Jquery, CSS, SQL, LINQ, EF
Software Development
Database: Microsoft SQL Server, FoxPro
Development Frameworks: Microsoft .NET 1.1, 2.0, 3.5, 4.5
UI: Windows Forms, Windows Presentation Foundation, ASP.NET Web Forms and ASP.NET MVC3, MVC4
Coding: WinForm , Web Development, Windows Phone, WinRT Programming, WCF, WebAPI
Healthcare Domain Experience
CCD, CCR, QRDA, HIE, HL7 V3, Healthcare Interoperability
B.E (Computer Science)
CodeProject Contest So Far:
1. Windows Azure Developer Contest - HealthReunion - A Windows Azure based healthcare product , link -
2. DnB Developer Contest - DNB Business Lookup and Analytics , link -
3. Intel Ultrabook Contest - Journey from development, code signing to publishing my App to Intel AppUp , link -
4. Intel App Innovation Contest 2013 - eHealthCare -
5. Grand Prize Winner of CodeProject HTML5 &CSS3 Article Contest 2014
6. Grand Prize Winner of CodeProject Android Article Contest 2014

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 31 Oct 2013
Article Copyright 2013 by Ranjan.D
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid